Skip to content

Commit

Permalink
Fill bucket properly
Browse files Browse the repository at this point in the history
  • Loading branch information
democat3457 committed Jul 14, 2022
1 parent 4cfd892 commit 8cec128
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/main/java/de/ellpeck/nyx/blocks/LunarWaterCauldron.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@
import net.minecraft.item.Item;
import net.minecraft.item.ItemBucket;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.stats.StatList;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidUtil;
import net.minecraftforge.fluids.capability.IFluidHandlerItem;

public class LunarWaterCauldron extends BlockCauldron {
public LunarWaterCauldron() {
Expand All @@ -42,12 +43,15 @@ public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state,
if (!playerIn.capabilities.isCreativeMode) {
stack.shrink(1);

// taken from net.minecraftforge.fluids.FluidUtil#getFilledBucket
ItemStack bucket = new ItemStack(item);
FluidStack fluidContents = new FluidStack(Registry.lunarWaterFluid, 1000);

NBTTagCompound tag = new NBTTagCompound();
fluidContents.writeToNBT(tag);
bucket.setTagCompound(tag);
IFluidHandlerItem fluidHandler = FluidUtil.getFluidHandler(bucket);
if (fluidHandler != null) {
fluidHandler.fill(fluidContents, true);
}

if (stack.isEmpty()) {
playerIn.setHeldItem(hand, bucket);
} else if (!playerIn.inventory.addItemStackToInventory(bucket)) {
Expand Down

0 comments on commit 8cec128

Please sign in to comment.