use of forestry.api.core.IToolPipette in project ForestryMC by ForestryMC.
the class TankWidget method handleMouseClick.
@Override
public void handleMouseClick(int mouseX, int mouseY, int mouseButton) {
EntityPlayer player = manager.minecraft.player;
ItemStack itemstack = player.inventory.getItemStack();
if (itemstack.isEmpty()) {
return;
}
Item held = itemstack.getItem();
Container container = manager.gui.inventorySlots;
if (held instanceof IToolPipette && container instanceof IContainerLiquidTanks) {
((IContainerLiquidTanks) container).handlePipetteClickClient(slot, player);
}
}
use of forestry.api.core.IToolPipette in project ForestryMC by ForestryMC.
the class ContainerLiquidTanksHelper method handlePipetteClick.
@Override
public void handlePipetteClick(int slot, EntityPlayerMP player) {
ItemStack itemstack = player.inventory.getItemStack();
Item held = itemstack.getItem();
if (!(held instanceof IToolPipette)) {
return;
}
IToolPipette pipette = (IToolPipette) held;
IFluidTank tank = tile.getTankManager().getTank(slot);
int liquidAmount = tank.getFluidAmount();
IFluidHandlerItem fluidHandlerItem = FluidUtil.getFluidHandler(itemstack);
if (fluidHandlerItem != null) {
if (pipette.canPipette(itemstack) && liquidAmount > 0) {
if (liquidAmount > 0) {
if (tank instanceof FluidTank) {
FluidStack fillAmount = ((FluidTank) tank).drainInternal(Fluid.BUCKET_VOLUME, false);
int filled = fluidHandlerItem.fill(fillAmount, true);
tank.drain(filled, true);
player.inventory.setItemStack(fluidHandlerItem.getContainer());
player.updateHeldItem();
}
}
} else {
FluidStack potential = fluidHandlerItem.drain(Integer.MAX_VALUE, false);
if (potential != null) {
if (tank instanceof FluidTank) {
int fill = ((FluidTank) tank).fillInternal(potential, true);
fluidHandlerItem.drain(fill, true);
player.inventory.setItemStack(fluidHandlerItem.getContainer());
player.updateHeldItem();
}
}
}
}
}
Aggregations