diff --git a/src/main/java/codechicken/nei/NEIController.java b/src/main/java/codechicken/nei/NEIController.java index b555d851..82c2d583 100644 --- a/src/main/java/codechicken/nei/NEIController.java +++ b/src/main/java/codechicken/nei/NEIController.java @@ -14,6 +14,7 @@ import net.minecraft.item.ItemStack; import net.minecraftforge.client.ClientCommandHandler; import codechicken.core.CommonUtils; +import codechicken.lib.gui.GuiDraw; import codechicken.nei.api.API; import codechicken.nei.api.GuiInfo; import codechicken.nei.api.IInfiniteItemHandler; @@ -156,20 +157,32 @@ public class NEIController implements IContainerSlotClickHandler, IContainerInpu if (GuiInfo.hasCustomSlots(gui)) return false; - if (slotIndex >= 0 && NEIClientUtils.shiftKey() - && NEIClientUtils.getHeldItem() != null - && !slot.getHasStack()) { - ItemStack held = NEIClientUtils.getHeldItem(); - manager.handleSlotClick(slot.slotNumber, button, 0); - if (slot.isItemValid(held) && !ItemInfo.fastTransferExemptions.contains(slot.getClass())) - fastTransferManager.performMassTransfer(gui, pickedUpFromSlot, slotIndex, held); + if (NEIClientUtils.shiftKey()) { + // fix small mouse movement while clicking causing slotIndex to be -999 + if (slotIndex == -999) { + final Point mouse = GuiDraw.getMousePosition(); + slot = gui.getSlotAtPosition(mouse.x, mouse.y); - return true; - } + if (slot != null) { + slotIndex = slot.slotNumber; + } + } - if (slotIndex == -999 && NEIClientUtils.shiftKey() && button == 0) { - fastTransferManager.throwAll(gui, pickedUpFromSlot); - return true; + if (slotIndex >= 0 && NEIClientUtils.getHeldItem() != null && !slot.getHasStack()) { + final ItemStack held = NEIClientUtils.getHeldItem(); + manager.handleSlotClick(slot.slotNumber, button, 0); + + if (slot.isItemValid(held) && !ItemInfo.fastTransferExemptions.contains(slot.getClass())) { + fastTransferManager.performMassTransfer(gui, pickedUpFromSlot, slotIndex, held); + } + + return true; + } + + if (slotIndex == -999 && button == 0) { + fastTransferManager.throwAll(gui, pickedUpFromSlot); + return true; + } } return false;