From ff4a00c609fa868815ecd13e2b804e723b7452e2 Mon Sep 17 00:00:00 2001 From: thedarkcolour <30441001+thedarkcolour@users.noreply.github.com> Date: Thu, 15 Feb 2024 17:19:13 -0800 Subject: [PATCH] Add option (disabled by default) to make dirt from witch water and water flowing together --- .../java/thedarkcolour/exdeorum/config/EConfig.java | 4 ++++ .../thedarkcolour/exdeorum/event/EventHandler.java | 11 ++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/main/java/thedarkcolour/exdeorum/config/EConfig.java b/src/main/java/thedarkcolour/exdeorum/config/EConfig.java index 76fd968d..5275394f 100644 --- a/src/main/java/thedarkcolour/exdeorum/config/EConfig.java +++ b/src/main/java/thedarkcolour/exdeorum/config/EConfig.java @@ -125,6 +125,7 @@ public class EConfig { public final IntValue simultaneousSieveUsageRange; public final BooleanValue automatedSieves; public final DoubleValue barrelProgressStep; + public final BooleanValue witchWaterDirtGenerator; public final BooleanValue witchWaterNetherrackGenerator; public final ConfigValue defaultSpawnTreeFeature; public final BooleanValue useBiomeAppropriateTree; @@ -158,6 +159,9 @@ public class EConfig { this.barrelProgressStep = builder .comment("The progress to increment by each tick for barrel composting.") .defineInRange("barrel_progress_step", 0.004, 0.0f, 1.0f); + this.witchWaterDirtGenerator = builder + .comment("Whether Witch Water forms dirt when water flows into it, allowing for a dirt version of a cobblestone generator.") + .define("witch_water_dirt_generator", false); this.witchWaterNetherrackGenerator = builder .comment("Whether Witch Water forms netherrack when lava flows into it, allowing for a netherrack version of a cobblestone generator.") .define("witch_water_netherrack_generator", true); diff --git a/src/main/java/thedarkcolour/exdeorum/event/EventHandler.java b/src/main/java/thedarkcolour/exdeorum/event/EventHandler.java index 2018dd78..9c4eb414 100644 --- a/src/main/java/thedarkcolour/exdeorum/event/EventHandler.java +++ b/src/main/java/thedarkcolour/exdeorum/event/EventHandler.java @@ -18,6 +18,7 @@ package thedarkcolour.exdeorum.event; +import net.minecraft.Util; import net.minecraft.client.Minecraft; import net.minecraft.core.BlockPos; import net.minecraft.core.Holder; @@ -28,12 +29,15 @@ import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; +import net.minecraft.util.RandomSource; import net.minecraft.util.Unit; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraft.world.level.GameRules; +import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.levelgen.Heightmap; import net.minecraft.world.level.levelgen.XoroshiroRandomSource; import net.minecraft.world.level.levelgen.feature.ConfiguredFeature; @@ -170,6 +174,12 @@ public final class EventHandler { EFluids.WITCH_WATER_TYPE.get(), fluidState -> fluidState.isSource() ? Blocks.OBSIDIAN.defaultBlockState() : (EConfig.SERVER.witchWaterNetherrackGenerator.get() ? Blocks.NETHERRACK.defaultBlockState() : Blocks.COBBLESTONE.defaultBlockState()) )); + var dirtVariants = new BlockState[]{Blocks.DIRT.defaultBlockState(), Blocks.PODZOL.defaultBlockState(), Blocks.COARSE_DIRT.defaultBlockState()}; + var rng = RandomSource.create(); + FluidInteractionRegistry.addInteraction(EFluids.WITCH_WATER_TYPE.get(), new FluidInteractionRegistry.InteractionInformation( + (level, pos, relative, state) -> level.getFluidState(relative).getFluidType() == ForgeMod.WATER_TYPE.get() && EConfig.SERVER.witchWaterDirtGenerator.get(), + fluidState -> Util.getRandom(dirtVariants, rng) + )); }); } @@ -230,7 +240,6 @@ public final class EventHandler { if (ModList.get().isLoaded(ModIds.THE_ONE_PROBE)) { InterModComms.sendTo(ModIds.THE_ONE_PROBE, "getTheOneProbe", ExDeorumTopCompat::new); } - // todo instead of doing this, figure out the real reason sorting voids items if (ModList.get().isLoaded(ModIds.INVENTORY_SORTER)) { InterModComms.sendTo(ModIds.INVENTORY_SORTER, "slotblacklist", ItemHelper.Slot.class::getName); }