Skip to content

Commit

Permalink
Fix null stacks when shift-clicking in conveyor-related inventories
Browse files Browse the repository at this point in the history
  • Loading branch information
founderio committed Dec 15, 2018
1 parent 9760781 commit d7a677e
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions common/net/teamio/taam/gui/ContainerConveyorSmallInventory.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.SlotItemHandler;
import net.teamio.taam.util.InventoryUtils;

public class ContainerConveyorSmallInventory extends Container {
protected final IItemHandler tileEntity;
Expand Down Expand Up @@ -47,29 +48,29 @@ protected void bindPlayerInventory(InventoryPlayer inventoryPlayer) {

@Override
public ItemStack transferStackInSlot(EntityPlayer player, int slotID) {
ItemStack stack = null;
ItemStack stack = ItemStack.EMPTY;
Slot slot = inventorySlots.get(slotID);

// null checks and checks if the item can be stacked (maxStackSize > 1)
if (slot != null && slot.getHasStack()) {
ItemStack stackInSlot = slot.getStack();
if (stackInSlot != null) {
if (!InventoryUtils.isEmpty(stackInSlot)) {
stack = stackInSlot.copy();

// merges the item into player inventory since its in the tileEntity
if (slotID < tileEntity.getSlots()) {
if (!mergeItemStack(stackInSlot, tileEntity.getSlots(), inventorySlots.size(), true)) {
return null;
return ItemStack.EMPTY;
}
}
// merge into tileEntity inventory, since it is in player's inventory
else if (!mergeItemStack(stackInSlot, 0, tileEntity.getSlots(), false)) {
return null;
return ItemStack.EMPTY;
}
}

if (stackInSlot == null || stackInSlot.getCount() == 0) {
slot.putStack(null);
if (InventoryUtils.isEmpty(stackInSlot)) {
slot.putStack(ItemStack.EMPTY);
} else {
slot.onSlotChanged();
}
Expand Down

0 comments on commit d7a677e

Please sign in to comment.