From da486ee94167862ad069d93baa93f0dc40af46d6 Mon Sep 17 00:00:00 2001 From: mezz Date: Wed, 25 May 2016 15:56:40 -0700 Subject: [PATCH] Allow pipettes to fill a machine or tank in the world --- .../core/gui/ContainerLiquidTanksHelper.java | 3 ++- .../java/forestry/core/items/ItemPipette.java | 20 ++++++++++--------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/main/java/forestry/core/gui/ContainerLiquidTanksHelper.java b/src/main/java/forestry/core/gui/ContainerLiquidTanksHelper.java index 8aafd16dd..140926d80 100644 --- a/src/main/java/forestry/core/gui/ContainerLiquidTanksHelper.java +++ b/src/main/java/forestry/core/gui/ContainerLiquidTanksHelper.java @@ -68,7 +68,8 @@ public class ContainerLiquidTanksHelper } else { FluidStack potential = pipette.drain(itemstack, pipette.getCapacity(itemstack), false); if (potential != null) { - pipette.drain(itemstack, tank.fill(potential, true), true); + int fill = tank.fill(potential, true); + pipette.drain(itemstack, fill, true); player.updateHeldItem(); } } diff --git a/src/main/java/forestry/core/items/ItemPipette.java b/src/main/java/forestry/core/items/ItemPipette.java index 3d37017dc..389dda829 100755 --- a/src/main/java/forestry/core/items/ItemPipette.java +++ b/src/main/java/forestry/core/items/ItemPipette.java @@ -21,6 +21,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.IFluidContainerItem; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -29,21 +30,13 @@ import forestry.api.core.IToolPipette; import forestry.core.config.Constants; import forestry.core.fluids.PipetteContents; -public class ItemPipette extends ItemForestry implements IToolPipette { +public class ItemPipette extends ItemForestry implements IToolPipette, IFluidContainerItem { public ItemPipette() { setMaxStackSize(1); setFull3D(); } - /** - * @return true if the item's stackTagCompound needs to be synchronized over SMP. - */ - @Override - public boolean getShareTag() { - return true; - } - @Override public boolean canPipette(ItemStack itemstack) { PipetteContents contained = PipetteContents.create(itemstack); @@ -159,6 +152,15 @@ public class ItemPipette extends ItemForestry implements IToolPipette { return new FluidStack(contained.getContents(), drained); } + @Override + public FluidStack getFluid(ItemStack container) { + PipetteContents contained = PipetteContents.create(container); + if (contained == null) { + return null; + } + return contained.getContents(); + } + @Override public int getCapacity(ItemStack pipette) { return Constants.BUCKET_VOLUME;