From 8522412f4e415028c37d945365f4edf913299639 Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Sun, 31 Jan 2021 18:52:08 +0800 Subject: BasicMachine fluid tank manipulations in GUI Signed-off-by: Glease <4586901+Glease@users.noreply.github.com> --- .../api/gui/GT_Container_BasicMachine.java | 98 +++++++++++++++++++++- 1 file changed, 94 insertions(+), 4 deletions(-) (limited to 'src/main/java/gregtech/api/gui/GT_Container_BasicMachine.java') diff --git a/src/main/java/gregtech/api/gui/GT_Container_BasicMachine.java b/src/main/java/gregtech/api/gui/GT_Container_BasicMachine.java index 7e14061d2f..6cd7f9e8e3 100644 --- a/src/main/java/gregtech/api/gui/GT_Container_BasicMachine.java +++ b/src/main/java/gregtech/api/gui/GT_Container_BasicMachine.java @@ -4,11 +4,18 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachine; +import gregtech.api.util.GT_Utility; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.ICrafting; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.IFluidContainerItem; +import net.minecraftforge.fluids.IFluidTank; + +import static gregtech.api.enums.GT_Values.NI; +import static gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachine.OTHER_SLOT_COUNT; /** * NEVER INCLUDE THIS FILE IN YOUR MOD!!! @@ -179,18 +186,101 @@ public class GT_Container_BasicMachine extends GT_Container_BasicTank { @Override public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer) { + if (mTileEntity.getMetaTileEntity() == null) return null; + GT_MetaTileEntity_BasicMachine machine = (GT_MetaTileEntity_BasicMachine) mTileEntity.getMetaTileEntity(); switch (aSlotIndex) { case 0: - if (mTileEntity.getMetaTileEntity() == null) return null; - ((GT_MetaTileEntity_BasicMachine) mTileEntity.getMetaTileEntity()).mFluidTransfer = !((GT_MetaTileEntity_BasicMachine) mTileEntity.getMetaTileEntity()).mFluidTransfer; + machine.mFluidTransfer = !machine.mFluidTransfer; return null; case 1: if (mTileEntity.getMetaTileEntity() == null) return null; - ((GT_MetaTileEntity_BasicMachine) mTileEntity.getMetaTileEntity()).mItemTransfer = !((GT_MetaTileEntity_BasicMachine) mTileEntity.getMetaTileEntity()).mItemTransfer; + machine.mItemTransfer = !machine.mItemTransfer; return null; + case 2: + return pickupFluid(machine.getDrainableStack(), aPlayer); default: - return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); + if (aSlotIndex == OTHER_SLOT_COUNT + 1 + machine.mInputSlotCount + machine.mOutputItems.length) { + // input fluid slot + ItemStack tStackHeld = aPlayer.inventory.getItemStack(); + ItemStack tStackSizedOne = GT_Utility.copyAmount(1, tStackHeld); + if (tStackSizedOne == null) return null; + FluidStack tInputFluid = machine.getFillableStack(); + FluidStack tFluidHeld = GT_Utility.getFluidForFilledItem(tStackSizedOne, true); + if (tInputFluid == null) { + if (tFluidHeld == null) + // both null -> no op + return null; + return fillFluid(machine, aPlayer, tFluidHeld); + } else { + if (tFluidHeld != null) { + // both nonnull. actually both pickup and fill is reasonable, but I'll go with fill here + return fillFluid(machine, aPlayer, tFluidHeld); + } else { + return pickupFluid(machine.getFillableStack(), aPlayer); + } + } + } else { + return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); + } + } + } + + private ItemStack pickupFluid(FluidStack aTankStack, EntityPlayer aPlayer) { + if (aTankStack == null) return null; + ItemStack tStackHeld = aPlayer.inventory.getItemStack(); + ItemStack tStackSizedOne = GT_Utility.copyAmount(1, tStackHeld); + if (tStackSizedOne == null) return null; + ItemStack tFilled = GT_Utility.fillFluidContainer(aTankStack, tStackSizedOne, true, false); + if (tFilled == null && tStackSizedOne.getItem() instanceof IFluidContainerItem) { + IFluidContainerItem tContainerItem = (IFluidContainerItem) tStackSizedOne.getItem(); + int tFilledAmount = tContainerItem.fill(tStackSizedOne, aTankStack, true); + if (tFilledAmount > 0) { + tFilled = tStackSizedOne; + aTankStack.amount -= tFilledAmount; + } + } + if (tFilled != null) { + reduceStackSizeInHandByOne(aPlayer); + GT_Utility.addItemToPlayerInventory(aPlayer, tFilled); } + return tFilled; + } + + private ItemStack fillFluid(IFluidTank aTank, EntityPlayer aPlayer, FluidStack aFluidHeld) { + ItemStack tStackHeld = aPlayer.inventory.getItemStack(); + ItemStack tStackSizedOne = GT_Utility.copyAmount(1, tStackHeld); + if (tStackSizedOne == null) + return null; + + int tFilled = aTank.fill(aFluidHeld, false); + if (tFilled == 0) // filled nothing + return null; + ItemStack tStackEmptied = null; + if (tFilled == aFluidHeld.amount) + // fully accepted - try take it from item now + // IFluidContainerItem is intentionally not checked here. it will be checked later + tStackEmptied = GT_Utility.getContainerForFilledItem(tStackSizedOne, false); + if (tStackEmptied == null && tStackHeld.getItem() instanceof IFluidContainerItem) { + IFluidContainerItem container = (IFluidContainerItem) tStackHeld.getItem(); + FluidStack tDrained = container.drain(tStackSizedOne, tFilled, true); + if (tDrained != null && tDrained.amount > 0) + // something is actually drained - change the cell and drop it to player + tStackEmptied = tStackSizedOne; + } + if (tStackEmptied == null) + // somehow the cell refuse to take that amount of fluid, no op then + return null; + aTank.fill(aFluidHeld, true); + GT_Utility.addItemToPlayerInventory(aPlayer, tStackEmptied); + reduceStackSizeInHandByOne(aPlayer); + return tStackEmptied; + } + + private void reduceStackSizeInHandByOne(EntityPlayer aPlayer) { + ItemStack tStackHeld = aPlayer.inventory.getItemStack(); + tStackHeld.stackSize -= 1; + if (tStackHeld.stackSize == 0) + aPlayer.inventory.setItemStack(NI); } @Override -- cgit From 3d4a402564b5a862866f6826d4b26179658d7221 Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Sun, 31 Jan 2021 20:00:03 +0800 Subject: Address reviews Signed-off-by: Glease <4586901+Glease@users.noreply.github.com> --- src/main/java/gregtech/api/gui/GT_Container_BasicMachine.java | 4 ++-- src/main/java/gregtech/api/gui/GT_Slot_Render.java | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) (limited to 'src/main/java/gregtech/api/gui/GT_Container_BasicMachine.java') diff --git a/src/main/java/gregtech/api/gui/GT_Container_BasicMachine.java b/src/main/java/gregtech/api/gui/GT_Container_BasicMachine.java index 6cd7f9e8e3..7e4e105353 100644 --- a/src/main/java/gregtech/api/gui/GT_Container_BasicMachine.java +++ b/src/main/java/gregtech/api/gui/GT_Container_BasicMachine.java @@ -186,8 +186,8 @@ public class GT_Container_BasicMachine extends GT_Container_BasicTank { @Override public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer) { - if (mTileEntity.getMetaTileEntity() == null) return null; GT_MetaTileEntity_BasicMachine machine = (GT_MetaTileEntity_BasicMachine) mTileEntity.getMetaTileEntity(); + if (machine == null) return null; switch (aSlotIndex) { case 0: machine.mFluidTransfer = !machine.mFluidTransfer; @@ -216,7 +216,7 @@ public class GT_Container_BasicMachine extends GT_Container_BasicTank { // both nonnull. actually both pickup and fill is reasonable, but I'll go with fill here return fillFluid(machine, aPlayer, tFluidHeld); } else { - return pickupFluid(machine.getFillableStack(), aPlayer); + return pickupFluid(tInputFluid, aPlayer); } } } else { diff --git a/src/main/java/gregtech/api/gui/GT_Slot_Render.java b/src/main/java/gregtech/api/gui/GT_Slot_Render.java index 8dd19a0e8e..92927e284e 100644 --- a/src/main/java/gregtech/api/gui/GT_Slot_Render.java +++ b/src/main/java/gregtech/api/gui/GT_Slot_Render.java @@ -1,7 +1,5 @@ package gregtech.api.gui; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Maintenance; -import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; -- cgit From eede79b1f210eec76f3b223353ab06a3398919ef Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Tue, 9 Feb 2021 02:14:26 +0800 Subject: Fix size 0 fluid stack Signed-off-by: Glease <4586901+Glease@users.noreply.github.com> --- src/main/java/gregtech/api/gui/GT_Container_BasicMachine.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/main/java/gregtech/api/gui/GT_Container_BasicMachine.java') diff --git a/src/main/java/gregtech/api/gui/GT_Container_BasicMachine.java b/src/main/java/gregtech/api/gui/GT_Container_BasicMachine.java index 7e4e105353..da528d67fc 100644 --- a/src/main/java/gregtech/api/gui/GT_Container_BasicMachine.java +++ b/src/main/java/gregtech/api/gui/GT_Container_BasicMachine.java @@ -188,6 +188,7 @@ public class GT_Container_BasicMachine extends GT_Container_BasicTank { public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer) { GT_MetaTileEntity_BasicMachine machine = (GT_MetaTileEntity_BasicMachine) mTileEntity.getMetaTileEntity(); if (machine == null) return null; + ItemStack tResultStack; switch (aSlotIndex) { case 0: machine.mFluidTransfer = !machine.mFluidTransfer; @@ -197,7 +198,10 @@ public class GT_Container_BasicMachine extends GT_Container_BasicTank { machine.mItemTransfer = !machine.mItemTransfer; return null; case 2: - return pickupFluid(machine.getDrainableStack(), aPlayer); + tResultStack = pickupFluid(machine.getDrainableStack(), aPlayer); + if (machine.getDrainableStack().amount == 0) + machine.setDrainableStack(null); + return tResultStack; default: if (aSlotIndex == OTHER_SLOT_COUNT + 1 + machine.mInputSlotCount + machine.mOutputItems.length) { // input fluid slot @@ -216,7 +220,10 @@ public class GT_Container_BasicMachine extends GT_Container_BasicTank { // both nonnull. actually both pickup and fill is reasonable, but I'll go with fill here return fillFluid(machine, aPlayer, tFluidHeld); } else { - return pickupFluid(tInputFluid, aPlayer); + tResultStack = pickupFluid(tInputFluid, aPlayer); + if (tInputFluid.amount == 0) + machine.setFillableStack(null); + return tResultStack; } } } else { -- cgit From 3dfd906868ee4a02caa7aa97438ccb25f15c0843 Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Tue, 9 Feb 2021 03:57:57 +0800 Subject: Allows manipulating multiple cell worth of fluid Left click to do as many manipulation as possible. Right click to just manipulate once. Signed-off-by: Glease <4586901+Glease@users.noreply.github.com> --- .../api/gui/GT_Container_BasicMachine.java | 98 ++++++++++++++++------ 1 file changed, 71 insertions(+), 27 deletions(-) (limited to 'src/main/java/gregtech/api/gui/GT_Container_BasicMachine.java') diff --git a/src/main/java/gregtech/api/gui/GT_Container_BasicMachine.java b/src/main/java/gregtech/api/gui/GT_Container_BasicMachine.java index da528d67fc..665be8b8ce 100644 --- a/src/main/java/gregtech/api/gui/GT_Container_BasicMachine.java +++ b/src/main/java/gregtech/api/gui/GT_Container_BasicMachine.java @@ -12,9 +12,7 @@ import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.IFluidContainerItem; -import net.minecraftforge.fluids.IFluidTank; -import static gregtech.api.enums.GT_Values.NI; import static gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachine.OTHER_SLOT_COUNT; /** @@ -198,12 +196,16 @@ public class GT_Container_BasicMachine extends GT_Container_BasicTank { machine.mItemTransfer = !machine.mItemTransfer; return null; case 2: - tResultStack = pickupFluid(machine.getDrainableStack(), aPlayer); - if (machine.getDrainableStack().amount == 0) + if (aMouseclick > 1) + return null; + tResultStack = pickupFluid(machine.getDrainableStack(), aPlayer, aMouseclick == 0); + if (machine.getDrainableStack() != null && machine.getDrainableStack().amount == 0) machine.setDrainableStack(null); return tResultStack; default: if (aSlotIndex == OTHER_SLOT_COUNT + 1 + machine.mInputSlotCount + machine.mOutputItems.length) { + if (aMouseclick > 1) + return null; // input fluid slot ItemStack tStackHeld = aPlayer.inventory.getItemStack(); ItemStack tStackSizedOne = GT_Utility.copyAmount(1, tStackHeld); @@ -214,13 +216,13 @@ public class GT_Container_BasicMachine extends GT_Container_BasicTank { if (tFluidHeld == null) // both null -> no op return null; - return fillFluid(machine, aPlayer, tFluidHeld); + return fillFluid(machine, aPlayer, tFluidHeld, aMouseclick == 0); } else { if (tFluidHeld != null) { // both nonnull. actually both pickup and fill is reasonable, but I'll go with fill here - return fillFluid(machine, aPlayer, tFluidHeld); + return fillFluid(machine, aPlayer, tFluidHeld, aMouseclick == 1); } else { - tResultStack = pickupFluid(tInputFluid, aPlayer); + tResultStack = pickupFluid(tInputFluid, aPlayer, aMouseclick == 0); if (tInputFluid.amount == 0) machine.setFillableStack(null); return tResultStack; @@ -232,11 +234,12 @@ public class GT_Container_BasicMachine extends GT_Container_BasicTank { } } - private ItemStack pickupFluid(FluidStack aTankStack, EntityPlayer aPlayer) { + private ItemStack pickupFluid(FluidStack aTankStack, EntityPlayer aPlayer, boolean aProcessFullStack) { if (aTankStack == null) return null; ItemStack tStackHeld = aPlayer.inventory.getItemStack(); ItemStack tStackSizedOne = GT_Utility.copyAmount(1, tStackHeld); if (tStackSizedOne == null) return null; + int tOriginalFluidAmount = aTankStack.amount; ItemStack tFilled = GT_Utility.fillFluidContainer(aTankStack, tStackSizedOne, true, false); if (tFilled == null && tStackSizedOne.getItem() instanceof IFluidContainerItem) { IFluidContainerItem tContainerItem = (IFluidContainerItem) tStackSizedOne.getItem(); @@ -247,47 +250,88 @@ public class GT_Container_BasicMachine extends GT_Container_BasicTank { } } if (tFilled != null) { - reduceStackSizeInHandByOne(aPlayer); - GT_Utility.addItemToPlayerInventory(aPlayer, tFilled); + if (aProcessFullStack) { + int tFilledAmount = tOriginalFluidAmount - aTankStack.amount; + /* + work out how many more items we can fill + the round down behavior will left over a fraction of a cell worth of fluid + the user then get to decide what to do with it + it will not be too fancy if it spills out partially filled cells + */ + int tAdditionalParallel = Math.min(tStackHeld.stackSize, aTankStack.amount / tFilledAmount); + aTankStack.amount -= tFilledAmount * tAdditionalParallel; + tFilled.stackSize += tAdditionalParallel; + } + replaceCursorItemStack(aPlayer, tFilled); } return tFilled; } - private ItemStack fillFluid(IFluidTank aTank, EntityPlayer aPlayer, FluidStack aFluidHeld) { + private ItemStack fillFluid(GT_MetaTileEntity_BasicMachine aMachine, EntityPlayer aPlayer, FluidStack aFluidHeld, boolean aProcessFullStack) { + // we are not using aMachine.fill() here any more, so we need to check for fluid type here ourselves + if (aMachine.getFillableStack() != null && !aMachine.getFillableStack().isFluidEqual(aFluidHeld)) + return null; ItemStack tStackHeld = aPlayer.inventory.getItemStack(); ItemStack tStackSizedOne = GT_Utility.copyAmount(1, tStackHeld); if (tStackSizedOne == null) return null; - int tFilled = aTank.fill(aFluidHeld, false); - if (tFilled == 0) // filled nothing + int tFreeSpace = aMachine.getCapacity() - (aMachine.getFillableStack() != null ? aMachine.getFillableStack().amount : 0); + if (tFreeSpace <= 0) + // no space left return null; + + // find out how much fluid can be taken + // some cells cannot be partially filled ItemStack tStackEmptied = null; - if (tFilled == aFluidHeld.amount) + int tAmountTaken = 0; + if (tFreeSpace == aFluidHeld.amount) { // fully accepted - try take it from item now // IFluidContainerItem is intentionally not checked here. it will be checked later tStackEmptied = GT_Utility.getContainerForFilledItem(tStackSizedOne, false); - if (tStackEmptied == null && tStackHeld.getItem() instanceof IFluidContainerItem) { - IFluidContainerItem container = (IFluidContainerItem) tStackHeld.getItem(); - FluidStack tDrained = container.drain(tStackSizedOne, tFilled, true); - if (tDrained != null && tDrained.amount > 0) + tAmountTaken = aFluidHeld.amount; + } + if (tStackEmptied == null && tStackSizedOne.getItem() instanceof IFluidContainerItem) { + // either partially accepted, or is IFluidContainerItem + IFluidContainerItem container = (IFluidContainerItem) tStackSizedOne.getItem(); + FluidStack tDrained = container.drain(tStackSizedOne, tFreeSpace, true); + if (tDrained != null && tDrained.amount > 0) { // something is actually drained - change the cell and drop it to player tStackEmptied = tStackSizedOne; + tAmountTaken = tDrained.amount; + } } if (tStackEmptied == null) - // somehow the cell refuse to take that amount of fluid, no op then + // somehow the cell refuse to give out that amount of fluid, no op then return null; - aTank.fill(aFluidHeld, true); - GT_Utility.addItemToPlayerInventory(aPlayer, tStackEmptied); - reduceStackSizeInHandByOne(aPlayer); + + // find out how many fill can we do + // same round down behavior as above + // however here the fluid stack is not changed at all, so the exact code will slightly differ + int tParallel = aProcessFullStack ? Math.min(tFreeSpace / tAmountTaken, tStackHeld.stackSize) : 1; + if (aMachine.getFillableStack() == null) { + FluidStack tNewFillableStack = aFluidHeld.copy(); + tNewFillableStack.amount = tAmountTaken * tParallel; + aMachine.setFillableStack(tNewFillableStack); + } else { + aMachine.getFillableStack().amount += tAmountTaken * tParallel; + } + tStackEmptied.stackSize = tParallel; + replaceCursorItemStack(aPlayer, tStackEmptied); return tStackEmptied; } - private void reduceStackSizeInHandByOne(EntityPlayer aPlayer) { - ItemStack tStackHeld = aPlayer.inventory.getItemStack(); - tStackHeld.stackSize -= 1; - if (tStackHeld.stackSize == 0) - aPlayer.inventory.setItemStack(NI); + private void replaceCursorItemStack(EntityPlayer aPlayer, ItemStack tStackResult) { + if (aPlayer.inventory.getItemStack().stackSize == tStackResult.stackSize) { + // every cell is mutated. it could just stay on the cursor. + aPlayer.inventory.setItemStack(tStackResult); + } else { + // some cells not mutated. The mutated cells must go into the inventory + // or drop into the world if there isn't enough space. + ItemStack tStackHeld = aPlayer.inventory.getItemStack(); + tStackHeld.stackSize -= tStackResult.stackSize; + GT_Utility.addItemToPlayerInventory(aPlayer, tStackResult); + } } @Override -- cgit From 533f8d6f2cea05ba94d1b829e1f90769cd7ce2ab Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Wed, 10 Feb 2021 14:34:42 +0800 Subject: Fix bucket gui fluid manipulation Signed-off-by: Glease <4586901+Glease@users.noreply.github.com> --- .../java/gregtech/api/gui/GT_Container_BasicMachine.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src/main/java/gregtech/api/gui/GT_Container_BasicMachine.java') diff --git a/src/main/java/gregtech/api/gui/GT_Container_BasicMachine.java b/src/main/java/gregtech/api/gui/GT_Container_BasicMachine.java index 665be8b8ce..38f8bd3b35 100644 --- a/src/main/java/gregtech/api/gui/GT_Container_BasicMachine.java +++ b/src/main/java/gregtech/api/gui/GT_Container_BasicMachine.java @@ -209,7 +209,7 @@ public class GT_Container_BasicMachine extends GT_Container_BasicTank { // input fluid slot ItemStack tStackHeld = aPlayer.inventory.getItemStack(); ItemStack tStackSizedOne = GT_Utility.copyAmount(1, tStackHeld); - if (tStackSizedOne == null) return null; + if (tStackSizedOne == null || tStackHeld.stackSize == 0) return null; FluidStack tInputFluid = machine.getFillableStack(); FluidStack tFluidHeld = GT_Utility.getFluidForFilledItem(tStackSizedOne, true); if (tInputFluid == null) { @@ -220,7 +220,7 @@ public class GT_Container_BasicMachine extends GT_Container_BasicTank { } else { if (tFluidHeld != null) { // both nonnull. actually both pickup and fill is reasonable, but I'll go with fill here - return fillFluid(machine, aPlayer, tFluidHeld, aMouseclick == 1); + return fillFluid(machine, aPlayer, tFluidHeld, aMouseclick == 0); } else { tResultStack = pickupFluid(tInputFluid, aPlayer, aMouseclick == 0); if (tInputFluid.amount == 0) @@ -238,7 +238,7 @@ public class GT_Container_BasicMachine extends GT_Container_BasicTank { if (aTankStack == null) return null; ItemStack tStackHeld = aPlayer.inventory.getItemStack(); ItemStack tStackSizedOne = GT_Utility.copyAmount(1, tStackHeld); - if (tStackSizedOne == null) return null; + if (tStackSizedOne == null || tStackHeld.stackSize == 0) return null; int tOriginalFluidAmount = aTankStack.amount; ItemStack tFilled = GT_Utility.fillFluidContainer(aTankStack, tStackSizedOne, true, false); if (tFilled == null && tStackSizedOne.getItem() instanceof IFluidContainerItem) { @@ -254,11 +254,12 @@ public class GT_Container_BasicMachine extends GT_Container_BasicTank { int tFilledAmount = tOriginalFluidAmount - aTankStack.amount; /* work out how many more items we can fill + one cell is already used, so account for that the round down behavior will left over a fraction of a cell worth of fluid the user then get to decide what to do with it it will not be too fancy if it spills out partially filled cells */ - int tAdditionalParallel = Math.min(tStackHeld.stackSize, aTankStack.amount / tFilledAmount); + int tAdditionalParallel = Math.min(tStackHeld.stackSize - 1, aTankStack.amount / tFilledAmount); aTankStack.amount -= tFilledAmount * tAdditionalParallel; tFilled.stackSize += tAdditionalParallel; } @@ -285,7 +286,7 @@ public class GT_Container_BasicMachine extends GT_Container_BasicTank { // some cells cannot be partially filled ItemStack tStackEmptied = null; int tAmountTaken = 0; - if (tFreeSpace == aFluidHeld.amount) { + if (tFreeSpace >= aFluidHeld.amount) { // fully accepted - try take it from item now // IFluidContainerItem is intentionally not checked here. it will be checked later tStackEmptied = GT_Utility.getContainerForFilledItem(tStackSizedOne, false); @@ -322,6 +323,11 @@ public class GT_Container_BasicMachine extends GT_Container_BasicTank { } private void replaceCursorItemStack(EntityPlayer aPlayer, ItemStack tStackResult) { + int tStackResultMaxStackSize = tStackResult.getMaxStackSize(); + while (tStackResult.stackSize > tStackResultMaxStackSize) { + aPlayer.inventory.getItemStack().stackSize -= tStackResultMaxStackSize; + GT_Utility.addItemToPlayerInventory(aPlayer, tStackResult.splitStack(tStackResultMaxStackSize)); + } if (aPlayer.inventory.getItemStack().stackSize == tStackResult.stackSize) { // every cell is mutated. it could just stay on the cursor. aPlayer.inventory.setItemStack(tStackResult); -- cgit