From 5a27c4ab2e1666822dc5bace1b0ce24549cd035f Mon Sep 17 00:00:00 2001 From: dragonruler1000 Date: Wed, 28 May 2025 17:43:08 -0500 Subject: [PATCH] Introduce dimensional event handling and improve loot table configuration Added `ModWorldEvents` class to manage custom dimensional events and ensure proper spacing in server world generation. Enhanced block_of_dust loot table with weighted drop chances and refined access transformer configuration in `build.gradle`. Integrated structure setup initialization in pre-loading event. Signed-off-by: dragonruler1000 --- build.gradle | 1 + .../us/minecraftchest2/hdm_mod/Hdm_mod.java | 4 +++ .../hdm_mod/world/ModWorldEvents.java | 31 +++++++++++++++++++ .../loot_tables/blocks/block_of_dust.json | 6 ++-- 4 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 src/main/java/us/minecraftchest2/hdm_mod/world/ModWorldEvents.java diff --git a/build.gradle b/build.gradle index a0ab1e4..816dfc4 100644 --- a/build.gradle +++ b/build.gradle @@ -31,6 +31,7 @@ minecraft { // Use non-default mappings at your own risk. They may not always work. // Simply re-run your setup task after changing the mappings to update your workspace. mappings channel: mapping_channel, version: mapping_version + accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') // When true, this property will have all Eclipse/IntelliJ IDEA run configurations run the "prepareX" task for the given run configuration before launching the game. // In most cases, it is not necessary to enable. diff --git a/src/main/java/us/minecraftchest2/hdm_mod/Hdm_mod.java b/src/main/java/us/minecraftchest2/hdm_mod/Hdm_mod.java index 4032970..d9e4bea 100644 --- a/src/main/java/us/minecraftchest2/hdm_mod/Hdm_mod.java +++ b/src/main/java/us/minecraftchest2/hdm_mod/Hdm_mod.java @@ -67,6 +67,10 @@ public class Hdm_mod { // some preinit code LOGGER.info("HELLO FROM PREINIT"); LOGGER.info("DIRT BLOCK >> {}", Blocks.DIRT.getRegistryName()); + + event.enqueueWork(() ->{ + ModStructures.setupStructures(); + }); } private void doClientStuff(final FMLClientSetupEvent event) { diff --git a/src/main/java/us/minecraftchest2/hdm_mod/world/ModWorldEvents.java b/src/main/java/us/minecraftchest2/hdm_mod/world/ModWorldEvents.java new file mode 100644 index 0000000..5497ffe --- /dev/null +++ b/src/main/java/us/minecraftchest2/hdm_mod/world/ModWorldEvents.java @@ -0,0 +1,31 @@ +package us.minecraftchest2.hdm_mod.world; + +import com.mojang.serialization.Codec; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.registry.Registry; +import net.minecraft.world.gen.ChunkGenerator; +import net.minecraft.world.server.ServerWorld; +import net.minecraftforge.event.world.WorldEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; +import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.fml.common.ObfuscationReflectionHelper; +import us.minecraftchest2.hdm_mod.Hdm_mod; + +import java.lang.reflect.Method; + +@Mod.EventBusSubscriber(modid = Hdm_mod.MOD_ID) +public class ModWorldEvents { + @SubscribeEvent + public static void addDimensinalSpacing(final WorldEvent.Load event) { + if(event.getWorld() instanceof ServerWorld) { + ServerWorld serverWorld = (ServerWorld) event.getWorld(); + + try { + Method GETCODEC_METHOD = + ObfuscationReflectionHelper.findMethod(ChunkGenerator.class, "func_230347_a_"); + ResourceLocation cgRL = Registry.CHUNK_GENERATOR_CODEC.getKey( + (Codec)GETCODEC_METHOD.invoke(serverWorld.getChunkProvider().generator)); + } + } + } +} diff --git a/src/main/resources/data/hdm_mod/loot_tables/blocks/block_of_dust.json b/src/main/resources/data/hdm_mod/loot_tables/blocks/block_of_dust.json index 3424ef6..a333168 100644 --- a/src/main/resources/data/hdm_mod/loot_tables/blocks/block_of_dust.json +++ b/src/main/resources/data/hdm_mod/loot_tables/blocks/block_of_dust.json @@ -3,10 +3,12 @@ "pools": [ { "rolls": 1, - "entries":[ + "entries": [ { "type": "minecraft:item", - "name": "hdm_mod:dust" + "name": "hdm_mod:dust", + "weight": 4, + "quality": 9 } ] }