From 5b96a9d5a20ae55eabff20370470445b79b1e8ff Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Fri, 27 Sep 2024 16:35:12 +0200 Subject: [PATCH] allow shift clicking a ghost item to clear the entire crafting grid closes #197 --- .../containers/CraftingTerminalContainer.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/main/java/de/ellpeck/prettypipes/terminal/containers/CraftingTerminalContainer.java b/src/main/java/de/ellpeck/prettypipes/terminal/containers/CraftingTerminalContainer.java index a1b2611..cc3d815 100644 --- a/src/main/java/de/ellpeck/prettypipes/terminal/containers/CraftingTerminalContainer.java +++ b/src/main/java/de/ellpeck/prettypipes/terminal/containers/CraftingTerminalContainer.java @@ -64,10 +64,17 @@ public class CraftingTerminalContainer extends ItemTerminalContainer { @Override public void clicked(int slotId, int dragType, ClickType clickTypeIn, Player player) { - if (slotId > 0 && clickTypeIn == ClickType.PICKUP) { - var slot = this.slots.get(slotId); - if (slot.container == this.craftInventory && !slot.hasItem()) - this.getTile().ghostItems.setStackInSlot(slot.getSlotIndex(), ItemStack.EMPTY); + if (slotId > 0) { + var ghostItems = this.getTile().ghostItems; + if (clickTypeIn == ClickType.PICKUP) { + var slot = this.slots.get(slotId); + if (slot.container == this.craftInventory && !slot.hasItem()) + ghostItems.setStackInSlot(slot.getSlotIndex(), ItemStack.EMPTY); + } else if (clickTypeIn == ClickType.QUICK_MOVE) { + // clear the entire grid when holding shift + for (var i = 0; i < ghostItems.getSlots(); i++) + ghostItems.setStackInSlot(i, ItemStack.EMPTY); + } } super.clicked(slotId, dragType, clickTypeIn, player); }