allow shift clicking a ghost item to clear the entire crafting grid

closes #197
This commit is contained in:
Ell 2024-09-27 16:35:12 +02:00
parent c7f43c3500
commit 5b96a9d5a2

View file

@ -64,10 +64,17 @@ public class CraftingTerminalContainer extends ItemTerminalContainer {
@Override @Override
public void clicked(int slotId, int dragType, ClickType clickTypeIn, Player player) { public void clicked(int slotId, int dragType, ClickType clickTypeIn, Player player) {
if (slotId > 0 && clickTypeIn == ClickType.PICKUP) { if (slotId > 0) {
var slot = this.slots.get(slotId); var ghostItems = this.getTile().ghostItems;
if (slot.container == this.craftInventory && !slot.hasItem()) if (clickTypeIn == ClickType.PICKUP) {
this.getTile().ghostItems.setStackInSlot(slot.getSlotIndex(), ItemStack.EMPTY); 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); super.clicked(slotId, dragType, clickTypeIn, player);
} }