Skip to content

Commit

Permalink
Added an option to remove source blocks with the canteen. Closes #666
Browse files Browse the repository at this point in the history
  • Loading branch information
Adubbz committed Jan 8, 2024
1 parent f5053d9 commit a4d19c8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions common/src/main/java/toughasnails/config/ThirstConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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.");

Expand Down
5 changes: 5 additions & 0 deletions common/src/main/java/toughasnails/item/EmptyCanteenItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -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> biome = player.level().getBiome(player.blockPosition());
Item canteenItem;

Expand Down

0 comments on commit a4d19c8

Please sign in to comment.