From 779aa69a09a23cb96cab8679db03fc6a8fef7fdc Mon Sep 17 00:00:00 2001 From: SeanOMik Date: Wed, 24 Feb 2021 13:58:08 -0600 Subject: [PATCH] Fixes #13 and #14 --- .../energeticstorage/gui/ESTerminalGUI.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main/java/net/seanomik/energeticstorage/gui/ESTerminalGUI.java b/src/main/java/net/seanomik/energeticstorage/gui/ESTerminalGUI.java index d7dcbae..a7a2c63 100644 --- a/src/main/java/net/seanomik/energeticstorage/gui/ESTerminalGUI.java +++ b/src/main/java/net/seanomik/energeticstorage/gui/ESTerminalGUI.java @@ -413,10 +413,7 @@ public class ESTerminalGUI implements InventoryHolder, Listener { case OUT: if (Utils.isItemValid(clickedItem)) { ItemStack takingItem = clickedItem.clone(); - - /*Map items = openSystem.getAllItems(); - int amount = items.values().toArray()[Utils.indexOfSimilarItem(items.keySet(), clickedItem)]*/ - takingItem.setAmount((clickType == ClickType.OUT_HALF && clickedItem.getAmount() / 2 > 0) ? clickedItem.getAmount() / 2 : 64); + takingItem.setAmount((clickType == ClickType.OUT_HALF && clickedItem.getAmount() / 2 > 0) ? clickedItem.getAmount() / 2 : clickedItem.getMaxStackSize()); takingItem = openSystem.removeItem(takingItem); // Remove the item from the search map if its in there @@ -430,7 +427,13 @@ public class ESTerminalGUI implements InventoryHolder, Listener { } if (clickType == ClickType.SHIFT_OUT) { - player.getInventory().addItem(takingItem); + HashMap leftOverItems = player.getInventory().addItem(takingItem); + + // Add the left over items back into the system + for (Map.Entry item : leftOverItems.entrySet()) { + System.out.println(item); + openSystem.addItem(item.getValue()); + } } else { event.getView().setCursor(takingItem); }