From a4d19c89e7dee46171871873be1dbb42edabd1b0 Mon Sep 17 00:00:00 2001 From: Adubbz Date: Mon, 8 Jan 2024 13:18:10 +1100 Subject: [PATCH] Added an option to remove source blocks with the canteen. Closes #666 --- common/src/main/java/toughasnails/config/ThirstConfig.java | 2 ++ common/src/main/java/toughasnails/item/EmptyCanteenItem.java | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/common/src/main/java/toughasnails/config/ThirstConfig.java b/common/src/main/java/toughasnails/config/ThirstConfig.java index 391f33d6..661117af 100644 --- a/common/src/main/java/toughasnails/config/ThirstConfig.java +++ b/common/src/main/java/toughasnails/config/ThirstConfig.java @@ -14,6 +14,7 @@ public class ThirstConfig extends Config { public boolean enableThirst; public boolean enableHandDrinking; + public boolean removeSourceBlocks; public boolean thirstPreventSprint; public boolean thirstPreventHealthRegen; public double thirstExhaustionThreshold; @@ -31,6 +32,7 @@ public void load() // Toggles enableThirst = add("toggles.enable_thirst", true, "Enable or disable thirst."); enableHandDrinking = add("toggles.enable_hand_drinking", false, "Enable or disable hand drinking."); + removeSourceBlocks = add("toggles.remove_source_blocks", false, "Remove source blocks when filling the canteen."); thirstPreventSprint = add("toggles.thirst_prevent_sprint", true, "Prevent sprinting when thirsty."); thirstPreventHealthRegen = add("toggles.thirst_prevent_health_regen", true, "Prevent health regeneration when thirsty."); diff --git a/common/src/main/java/toughasnails/item/EmptyCanteenItem.java b/common/src/main/java/toughasnails/item/EmptyCanteenItem.java index a4e8c0ba..ccf0abd1 100644 --- a/common/src/main/java/toughasnails/item/EmptyCanteenItem.java +++ b/common/src/main/java/toughasnails/item/EmptyCanteenItem.java @@ -20,6 +20,7 @@ import net.minecraft.world.level.ClipContext; import net.minecraft.world.level.Level; import net.minecraft.world.level.biome.Biome; +import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.LayeredCauldronBlock; import net.minecraft.world.level.block.state.BlockState; @@ -30,6 +31,7 @@ import toughasnails.api.enchantment.TANEnchantments; import toughasnails.api.item.TANItems; import toughasnails.block.RainCollectorBlock; +import toughasnails.init.ModConfig; import toughasnails.init.ModTags; public class EmptyCanteenItem extends Item @@ -89,6 +91,9 @@ else if (level.getFluidState(pos).is(FluidTags.WATER)) // Fill the canteen with water in the world level.playSound(player, player.getX(), player.getY(), player.getZ(), SoundEvents.BOTTLE_FILL, SoundSource.NEUTRAL, 1.0F, 1.0F); + if (ModConfig.thirst.removeSourceBlocks) + level.setBlock(pos, Blocks.AIR.defaultBlockState(), Block.UPDATE_ALL_IMMEDIATE); + Holder biome = player.level().getBiome(player.blockPosition()); Item canteenItem;