Skip to content

Commit

Permalink
Allowed canteens to take water from cauldrons (Closes #809)
Browse files Browse the repository at this point in the history
  • Loading branch information
Forstride committed Jan 4, 2024
1 parent aee061e commit 9796860
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion common/src/main/java/toughasnails/item/EmptyCanteenItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.ItemUtils;
import net.minecraft.world.item.Vanishable;
import net.minecraft.world.item.enchantment.EnchantmentHelper;
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.Blocks;
import net.minecraft.world.level.block.LayeredCauldronBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.HitResult;
Expand Down Expand Up @@ -71,6 +72,18 @@ protected InteractionResultHolder<ItemStack> fillCanteen(Level level, Player pla
return InteractionResultHolder.success(this.replaceCanteen(stack, player, new ItemStack(getPurifiedWaterCanteen())));
}
}
else if (state.getBlock() == Blocks.WATER_CAULDRON)
{
// Fill the canteen from water from a cauldron
int waterLevel = state.getValue(LayeredCauldronBlock.LEVEL);

if (waterLevel > 0 && !level.isClientSide())
{
level.playSound(player, player.getX(), player.getY(), player.getZ(), SoundEvents.BOTTLE_FILL, SoundSource.NEUTRAL, 1.0F, 1.0F);
LayeredCauldronBlock.lowerFillLevel(state, level, pos);
return InteractionResultHolder.success(this.replaceCanteen(stack, player, new ItemStack(getWaterCanteen())));
}
}
else if (level.getFluidState(pos).is(FluidTags.WATER))
{
// Fill the canteen with water in the world
Expand Down

0 comments on commit 9796860

Please sign in to comment.