From c9f79130ee81d820961cbb581b4bf14f50d038fa Mon Sep 17 00:00:00 2001 From: Onyx_i7 Date: Sat, 11 Jul 2026 20:44:31 -0400 Subject: [PATCH 01/11] Refactor bottle interaction logic in BlockFluidBasic --- .../block/BlockFluidBasic.java | 24 ++++++++----------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/charles445/simpledifficulty/block/BlockFluidBasic.java b/src/main/java/com/charles445/simpledifficulty/block/BlockFluidBasic.java index 5664993..359711b 100644 --- a/src/main/java/com/charles445/simpledifficulty/block/BlockFluidBasic.java +++ b/src/main/java/com/charles445/simpledifficulty/block/BlockFluidBasic.java @@ -57,27 +57,23 @@ public BlockFluidBasic(Fluid fluid, Material material, String iceBlock) { @Override public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { - if (worldIn.isRemote) { - return true; - } - ItemStack heldItem = playerIn.getHeldItem(hand); // Handle empty bottle interaction - if (heldItem.getItem() == Items.GLASS_BOTTLE) { + if (!heldItem.isEmpty() && heldItem.getItem() == Items.GLASS_BOTTLE) { ItemStack resultBottle = getBottleResult(); if (!resultBottle.isEmpty()) { - // Consume the empty bottle - heldItem.shrink(1); - - // Add the filled bottle to inventory or drop it - if (heldItem.isEmpty()) { - playerIn.setHeldItem(hand, resultBottle); - } else if (!playerIn.inventory.addItemStackToInventory(resultBottle)) { - playerIn.dropItem(resultBottle, false); + if (!worldIn.isRemote) { + // Server side: consume bottle and give result + heldItem.shrink(1); + + if (heldItem.isEmpty()) { + playerIn.setHeldItem(hand, resultBottle); + } else if (!playerIn.inventory.addItemStackToInventory(resultBottle)) { + playerIn.dropItem(resultBottle, false); + } } - return true; } } From dd5f0262207fd1c79a329c8ec0e129aa36c2d0ce Mon Sep 17 00:00:00 2001 From: Onyx_i7 Date: Sat, 11 Jul 2026 20:45:04 -0400 Subject: [PATCH 02/11] Refactor neighborChanged and onBlockAdded methods --- .../simpledifficulty/block/BlockFluidBasicMixable.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/charles445/simpledifficulty/block/BlockFluidBasicMixable.java b/src/main/java/com/charles445/simpledifficulty/block/BlockFluidBasicMixable.java index 4543f70..7ff5b5e 100644 --- a/src/main/java/com/charles445/simpledifficulty/block/BlockFluidBasicMixable.java +++ b/src/main/java/com/charles445/simpledifficulty/block/BlockFluidBasicMixable.java @@ -34,9 +34,8 @@ public void updateTick(World world, BlockPos pos, IBlockState state, Random rand @Override public void neighborChanged(IBlockState state, World world, BlockPos pos, Block neighborBlock, BlockPos neighbourPos) { - if (world.isRemote) return; // Only process physical mixtures on the server + if (world.isRemote) return; - // Check if the chunk is ready to prevent chunk load leaks if (!world.isBlockLoaded(pos)) return; world.scheduleUpdate(pos, this, tickRate); @@ -48,7 +47,7 @@ public void neighborChanged(IBlockState state, World world, BlockPos pos, Block @Override public void onBlockAdded(World world, BlockPos pos, IBlockState state) { - if (world.isRemote) return; // Only process on the server + if (world.isRemote) return; world.scheduleUpdate(pos, this, tickRate); From e403ea610cee8f5a38d4ad963c72ff2c1e2021b7 Mon Sep 17 00:00:00 2001 From: Onyx_i7 Date: Sat, 11 Jul 2026 20:45:51 -0400 Subject: [PATCH 03/11] Add BlockFluidSaltWater class for salt water fluid --- .../block/BlockFluidSaltWater.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/main/java/com/charles445/simpledifficulty/block/BlockFluidSaltWater.java diff --git a/src/main/java/com/charles445/simpledifficulty/block/BlockFluidSaltWater.java b/src/main/java/com/charles445/simpledifficulty/block/BlockFluidSaltWater.java new file mode 100644 index 0000000..52bcbe9 --- /dev/null +++ b/src/main/java/com/charles445/simpledifficulty/block/BlockFluidSaltWater.java @@ -0,0 +1,17 @@ +package com.charles445.simpledifficulty.block; + +import com.charles445.simpledifficulty.api.SDItems; +import net.minecraft.block.material.Material; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.Fluid; + +public class BlockFluidSaltWater extends BlockFluidBasic { + public BlockFluidSaltWater(Fluid fluid, Material material, String iceBlock) { + super(fluid, material, iceBlock); + } + + @Override + protected ItemStack getBottleResult() { + return new ItemStack(SDItems.saltWaterBottle); + } +} From 8e49597d24b30351b7b91e0c6af1ba9ae4cd2b02 Mon Sep 17 00:00:00 2001 From: Onyx_i7 Date: Sat, 11 Jul 2026 20:48:09 -0400 Subject: [PATCH 04/11] Replace BlockFluidBasic with BlockFluidSaltWater --- .../charles445/simpledifficulty/register/RegisterFluids.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/charles445/simpledifficulty/register/RegisterFluids.java b/src/main/java/com/charles445/simpledifficulty/register/RegisterFluids.java index 281102c..31b504c 100644 --- a/src/main/java/com/charles445/simpledifficulty/register/RegisterFluids.java +++ b/src/main/java/com/charles445/simpledifficulty/register/RegisterFluids.java @@ -3,6 +3,7 @@ import com.charles445.simpledifficulty.SimpleDifficulty; import com.charles445.simpledifficulty.block.BlockFluidBasic; import com.charles445.simpledifficulty.block.BlockFluidBasicMixable; +import com.charles445.simpledifficulty.block.BlockFluidSaltWater; import com.charles445.simpledifficulty.fluid.FluidBasic; import com.ferreusveritas.dynamictrees.systems.DirtHelper; import net.minecraft.block.Block; @@ -56,7 +57,7 @@ public static void registerFluidsAndFluidBlocks(RegistryEvent.Register ev //Create Fluid Blocks blockPurifiedWater = new BlockFluidBasicMixable(purifiedWater, Material.WATER, "purifiedwater_ice"); - blockSaltWater = new BlockFluidBasic(saltWater, Material.WATER, "saltwater_ice"); + blockSaltWater = new BlockFluidSaltWater(saltWater, Material.WATER, "saltwater_ice"); for(String key : fluidBlocks.keySet()) { From 534fa5167234661500675278f45c24bde86adbd8 Mon Sep 17 00:00:00 2001 From: Onyx_i7 Date: Sat, 11 Jul 2026 21:02:51 -0400 Subject: [PATCH 05/11] Add bottle interaction for mod fluid blocks Intercept bottle interactions with mod fluid blocks to provide purified and salt water bottles. --- .../handler/ThirstHandler.java | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/src/main/java/com/charles445/simpledifficulty/handler/ThirstHandler.java b/src/main/java/com/charles445/simpledifficulty/handler/ThirstHandler.java index dad68c6..9cd7e72 100644 --- a/src/main/java/com/charles445/simpledifficulty/handler/ThirstHandler.java +++ b/src/main/java/com/charles445/simpledifficulty/handler/ThirstHandler.java @@ -1,6 +1,8 @@ package com.charles445.simpledifficulty.handler; import com.charles445.simpledifficulty.api.SDCapabilities; +import com.charles445.simpledifficulty.api.SDFluids; +import com.charles445.simpledifficulty.api.SDItems; import com.charles445.simpledifficulty.api.SDPotions; import com.charles445.simpledifficulty.api.config.JsonConfig; import com.charles445.simpledifficulty.api.config.QuickConfig; @@ -15,6 +17,7 @@ import com.charles445.simpledifficulty.network.PacketHandler; import com.charles445.simpledifficulty.util.SoundUtil; import com.charles445.simpledifficulty.util.internal.ThirstUtilInternal; +import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; @@ -25,6 +28,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.potion.PotionType; import net.minecraft.potion.PotionUtils; +import net.minecraft.util.EnumActionResult; import net.minecraft.util.EnumHand; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; @@ -36,6 +40,7 @@ import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.event.world.BlockEvent; import net.minecraftforge.fml.common.Loader; +import net.minecraftforge.fml.common.eventhandler.EventPriority; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import java.util.List; @@ -136,6 +141,51 @@ public void onLivingEntityUseItemFinish(LivingEntityUseItemEvent.Finish event) { } } + // Intercept bottle interactions with mod fluid blocks + @SubscribeEvent(priority = EventPriority.HIGH) + public void onRightClickBlockBottle(PlayerInteractEvent.RightClickBlock event) { + if (event.getWorld().isRemote) { + return; // Only process on server + } + + EntityPlayer player = event.getEntityPlayer(); + ItemStack heldItem = player.getHeldItem(event.getHand()); + + // Only handle empty bottles + if (heldItem.isEmpty() || heldItem.getItem() != Items.GLASS_BOTTLE) { + return; + } + + BlockPos pos = event.getPos(); + IBlockState state = event.getWorld().getBlockState(pos); + Block block = state.getBlock(); + + // Check if clicking on mod fluid blocks + ItemStack resultBottle = null; + + if (block == SDFluids.blockPurifiedWater) { + resultBottle = new ItemStack(SDItems.purifiedWaterBottle); + } else if (block == SDFluids.blockSaltWater) { + resultBottle = new ItemStack(SDItems.saltWaterBottle); + } + + // If found a valid bottle result, handle it + if (resultBottle != null) { + // Cancel the vanilla interaction + event.setCanceled(true); + event.setCancellationResult(EnumActionResult.SUCCESS); + + // Give the player the bottle + heldItem.shrink(1); + + if (heldItem.isEmpty()) { + player.setHeldItem(event.getHand(), resultBottle); + } else if (!player.inventory.addItemStackToInventory(resultBottle)) { + player.dropItem(resultBottle, false); + } + } + } + // Both Sides @SubscribeEvent public void onRightClickBlock(PlayerInteractEvent.RightClickBlock event) { From 177bc8b50afe7fe30462380dc202e8803664b229 Mon Sep 17 00:00:00 2001 From: Onyx_i7 Date: Sat, 11 Jul 2026 21:11:07 -0400 Subject: [PATCH 06/11] Add TODO for ThirstHandler improvements Added a TODO comment regarding future improvements. --- .../com/charles445/simpledifficulty/handler/ThirstHandler.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/charles445/simpledifficulty/handler/ThirstHandler.java b/src/main/java/com/charles445/simpledifficulty/handler/ThirstHandler.java index 9cd7e72..8727391 100644 --- a/src/main/java/com/charles445/simpledifficulty/handler/ThirstHandler.java +++ b/src/main/java/com/charles445/simpledifficulty/handler/ThirstHandler.java @@ -140,7 +140,8 @@ public void onLivingEntityUseItemFinish(LivingEntityUseItemEvent.Finish event) { */ } } - + + // TODO: This needs to be improved and corrected, it will be included in a future update, I'm not sure yet // Intercept bottle interactions with mod fluid blocks @SubscribeEvent(priority = EventPriority.HIGH) public void onRightClickBlockBottle(PlayerInteractEvent.RightClickBlock event) { From c2b45bef8e57decde17fc12570fde4278ee01216 Mon Sep 17 00:00:00 2001 From: Onyx_i7 Date: Sat, 11 Jul 2026 21:31:06 -0400 Subject: [PATCH 07/11] Refactor thirst handling logic in ThirstUtilInternal --- .../util/internal/ThirstUtilInternal.java | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/main/java/com/charles445/simpledifficulty/util/internal/ThirstUtilInternal.java b/src/main/java/com/charles445/simpledifficulty/util/internal/ThirstUtilInternal.java index 53621fe..ca066cd 100644 --- a/src/main/java/com/charles445/simpledifficulty/util/internal/ThirstUtilInternal.java +++ b/src/main/java/com/charles445/simpledifficulty/util/internal/ThirstUtilInternal.java @@ -61,28 +61,28 @@ public static ThirstEnumBlockPos traceWaterToDrink(EntityPlayer player) { //Empty-handed and thirsty ThirstEnumBlockPos traceResult = ThirstUtil.traceWater(player); - if(traceResult==null) - return null; + if(traceResult.thirstEnum == ThirstEnum.PURIFIED) { + if(!ServerConfig.instance.getBoolean(ServerOptions.THIRST_DRINK_BLOCKS)) + return null; - if(traceResult.thirstEnum == ThirstEnum.PURIFIED && !ServerConfig.instance.getBoolean(ServerOptions.THIRST_DRINK_RAIN)) - { - return null; + if(!ServerConfig.instance.getBoolean(ServerOptions.INFINITE_PURIFIED_WATER)) + player.world.setBlockToAir(traceResult.pos); } - else if(traceResult.thirstEnum == ThirstEnum.RAIN && !ServerConfig.instance.getBoolean(ServerOptions.THIRST_DRINK_RAIN)) - { - return null; + else if(traceResult.thirstEnum == ThirstEnum.RAIN && !ServerConfig.instance.getBoolean(ServerOptions.THIRST_DRINK_RAIN)) { + return null; } - else if(traceResult.thirstEnum == ThirstEnum.NORMAL) - { - if(!ServerConfig.instance.getBoolean(ServerOptions.THIRST_DRINK_BLOCKS)) - return null; - - if(!ServerConfig.instance.getBoolean(ServerOptions.INFINITE_PURIFIED_WATER)) - player.world.setBlockToAir(traceResult.pos); + else if(traceResult.thirstEnum == ThirstEnum.NORMAL) { + if(!ServerConfig.instance.getBoolean(ServerOptions.THIRST_DRINK_BLOCKS)) + return null; + + player.world.setBlockToAir(traceResult.pos); } - else if(traceResult.thirstEnum == ThirstEnum.SALT && !ServerConfig.instance.getBoolean(ServerOptions.THIRST_DRINK_BLOCKS)) - { - return null; + else if(traceResult.thirstEnum == ThirstEnum.SALT && !ServerConfig.instance.getBoolean(ServerOptions.THIRST_DRINK_BLOCKS)) { + return null; + } + else if(traceResult.thirstEnum == ThirstEnum.CLEAN) { + tryAddDose(stack, ThirstEnum.CLEAN); + success = true; } return traceResult; From 0c78fd48788d9144b81911618aa83d37f0dc40e4 Mon Sep 17 00:00:00 2001 From: Onyx_i7 Date: Sat, 11 Jul 2026 21:31:56 -0400 Subject: [PATCH 08/11] Send local server config to API during initialization --- .../java/com/charles445/simpledifficulty/SimpleDifficulty.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/charles445/simpledifficulty/SimpleDifficulty.java b/src/main/java/com/charles445/simpledifficulty/SimpleDifficulty.java index 38f2fa9..a8e503e 100644 --- a/src/main/java/com/charles445/simpledifficulty/SimpleDifficulty.java +++ b/src/main/java/com/charles445/simpledifficulty/SimpleDifficulty.java @@ -48,6 +48,7 @@ public void preInit(FMLPreInitializationEvent event) proxy.preInit(); com.charles445.simpledifficulty.compat.mod.Weather2Compat.init(); + ModConfig.sendLocalServerConfigToAPI(); } @Mod.EventHandler From fbf18d8a2a4e40a86fc10556d0393e80a61863e2 Mon Sep 17 00:00:00 2001 From: Onyx_i7 Date: Sat, 11 Jul 2026 21:39:25 -0400 Subject: [PATCH 09/11] Refactor thirst handling in ThirstUtilInternal --- .../util/internal/ThirstUtilInternal.java | 52 +++++++++---------- 1 file changed, 24 insertions(+), 28 deletions(-) diff --git a/src/main/java/com/charles445/simpledifficulty/util/internal/ThirstUtilInternal.java b/src/main/java/com/charles445/simpledifficulty/util/internal/ThirstUtilInternal.java index ca066cd..73915d7 100644 --- a/src/main/java/com/charles445/simpledifficulty/util/internal/ThirstUtilInternal.java +++ b/src/main/java/com/charles445/simpledifficulty/util/internal/ThirstUtilInternal.java @@ -57,35 +57,31 @@ public static ThirstEnumBlockPos traceWaterToDrink(EntityPlayer player) if(player.getHeldItemMainhand().isEmpty()) { IThirstCapability capability = SDCapabilities.getThirstData(player); - if(capability.isThirsty()) + if(traceResult.thirstEnum == ThirstEnum.PURIFIED) { - //Empty-handed and thirsty - ThirstEnumBlockPos traceResult = ThirstUtil.traceWater(player); - if(traceResult.thirstEnum == ThirstEnum.PURIFIED) { - if(!ServerConfig.instance.getBoolean(ServerOptions.THIRST_DRINK_BLOCKS)) - return null; - - if(!ServerConfig.instance.getBoolean(ServerOptions.INFINITE_PURIFIED_WATER)) - player.world.setBlockToAir(traceResult.pos); - } - else if(traceResult.thirstEnum == ThirstEnum.RAIN && !ServerConfig.instance.getBoolean(ServerOptions.THIRST_DRINK_RAIN)) { - return null; - } - else if(traceResult.thirstEnum == ThirstEnum.NORMAL) { - if(!ServerConfig.instance.getBoolean(ServerOptions.THIRST_DRINK_BLOCKS)) - return null; - - player.world.setBlockToAir(traceResult.pos); - } - else if(traceResult.thirstEnum == ThirstEnum.SALT && !ServerConfig.instance.getBoolean(ServerOptions.THIRST_DRINK_BLOCKS)) { - return null; - } - else if(traceResult.thirstEnum == ThirstEnum.CLEAN) { - tryAddDose(stack, ThirstEnum.CLEAN); - success = true; - } - - return traceResult; + if(!ServerConfig.instance.getBoolean(ServerOptions.THIRST_DRINK_BLOCKS)) + return null; + + if(!ServerConfig.instance.getBoolean(ServerOptions.INFINITE_PURIFIED_WATER)) + player.world.setBlockToAir(traceResult.pos); + } + else if(traceResult.thirstEnum == ThirstEnum.RAIN && !ServerConfig.instance.getBoolean(ServerOptions.THIRST_DRINK_RAIN)) + { + return null; + } + else if(traceResult.thirstEnum == ThirstEnum.NORMAL) + { + if(!ServerConfig.instance.getBoolean(ServerOptions.THIRST_DRINK_BLOCKS)) + return null; + + player.world.setBlockToAir(traceResult.pos); + } + else if(traceResult.thirstEnum == ThirstEnum.SALT && !ServerConfig.instance.getBoolean(ServerOptions.THIRST_DRINK_BLOCKS)) + { + return null; + } + + return traceResult; } } From 252a896d432bff7bc881a932ffb76e8a51bf530e Mon Sep 17 00:00:00 2001 From: Onyx_i7 Date: Sat, 11 Jul 2026 21:44:51 -0400 Subject: [PATCH 10/11] Refactor thirst handling in ThirstUtilInternal --- .../util/internal/ThirstUtilInternal.java | 55 +++++++++++-------- 1 file changed, 31 insertions(+), 24 deletions(-) diff --git a/src/main/java/com/charles445/simpledifficulty/util/internal/ThirstUtilInternal.java b/src/main/java/com/charles445/simpledifficulty/util/internal/ThirstUtilInternal.java index 73915d7..cb73a06 100644 --- a/src/main/java/com/charles445/simpledifficulty/util/internal/ThirstUtilInternal.java +++ b/src/main/java/com/charles445/simpledifficulty/util/internal/ThirstUtilInternal.java @@ -57,31 +57,38 @@ public static ThirstEnumBlockPos traceWaterToDrink(EntityPlayer player) if(player.getHeldItemMainhand().isEmpty()) { IThirstCapability capability = SDCapabilities.getThirstData(player); - if(traceResult.thirstEnum == ThirstEnum.PURIFIED) + if(capability.isThirsty()) { - if(!ServerConfig.instance.getBoolean(ServerOptions.THIRST_DRINK_BLOCKS)) - return null; - - if(!ServerConfig.instance.getBoolean(ServerOptions.INFINITE_PURIFIED_WATER)) - player.world.setBlockToAir(traceResult.pos); - } - else if(traceResult.thirstEnum == ThirstEnum.RAIN && !ServerConfig.instance.getBoolean(ServerOptions.THIRST_DRINK_RAIN)) - { - return null; - } - else if(traceResult.thirstEnum == ThirstEnum.NORMAL) - { - if(!ServerConfig.instance.getBoolean(ServerOptions.THIRST_DRINK_BLOCKS)) - return null; - - player.world.setBlockToAir(traceResult.pos); - } - else if(traceResult.thirstEnum == ThirstEnum.SALT && !ServerConfig.instance.getBoolean(ServerOptions.THIRST_DRINK_BLOCKS)) - { - return null; - } - - return traceResult; + //Empty-handed and thirsty + ThirstEnumBlockPos traceResult = ThirstUtil.traceWater(player); + if(traceResult==null) + return null; + + if(traceResult.thirstEnum == ThirstEnum.PURIFIED) + { + if(!ServerConfig.instance.getBoolean(ServerOptions.THIRST_DRINK_BLOCKS)) + return null; + + if(!ServerConfig.instance.getBoolean(ServerOptions.INFINITE_PURIFIED_WATER)) + player.world.setBlockToAir(traceResult.pos); + } + else if(traceResult.thirstEnum == ThirstEnum.RAIN && !ServerConfig.instance.getBoolean(ServerOptions.THIRST_DRINK_RAIN)) + { + return null; + } + else if(traceResult.thirstEnum == ThirstEnum.NORMAL) + { + if(!ServerConfig.instance.getBoolean(ServerOptions.THIRST_DRINK_BLOCKS)) + return null; + + player.world.setBlockToAir(traceResult.pos); + } + else if(traceResult.thirstEnum == ThirstEnum.SALT && !ServerConfig.instance.getBoolean(ServerOptions.THIRST_DRINK_BLOCKS)) + { + return null; + } + + return traceResult; } } From 913c8f69b994be97427e79ca17f24a692e1c1bdd Mon Sep 17 00:00:00 2001 From: Onyx_i7 Date: Sat, 11 Jul 2026 21:47:44 -0400 Subject: [PATCH 11/11] Add import for ModConfig in SimpleDifficulty.java --- .../java/com/charles445/simpledifficulty/SimpleDifficulty.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/charles445/simpledifficulty/SimpleDifficulty.java b/src/main/java/com/charles445/simpledifficulty/SimpleDifficulty.java index a8e503e..1492997 100644 --- a/src/main/java/com/charles445/simpledifficulty/SimpleDifficulty.java +++ b/src/main/java/com/charles445/simpledifficulty/SimpleDifficulty.java @@ -1,5 +1,6 @@ package com.charles445.simpledifficulty; +import com.charles445.simpledifficulty.config.ModConfig; import com.charles445.simpledifficulty.command.CommandSimpleDifficulty; import com.charles445.simpledifficulty.debug.DebugVerifier; import com.charles445.simpledifficulty.network.PacketHandler;