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
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);
}