the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 84 lines 3.2 kB view raw
1#pragma once 2 3// 4J The body of this class was commented out in Java. Copying here for completeness 4 5class MouseInventoryClickHandler 6{ 7/* public static void handle(int buttonNum, boolean clickedOutside, int slotId, Player player) { 8 Inventory inventory = player.inventory; 9 Slot slot = player.getInventorySlot(slotId); 10 if (slot != null) { 11 ItemInstance clicked = slot.getItem(); 12 if (clicked == null && inventory.carried == null) { 13 } else if (clicked != null && inventory.carried == null) { 14 int c = buttonNum == 0 ? clicked.count : (clicked.count + 1) / 2; 15 inventory.carried = slot.container.removeItem(slot.slot, c); 16 if (clicked.count == 0) slot.set(null); 17 slot.onTake(); 18 } else if (clicked == null && inventory.carried != null && slot.mayPlace(inventory.carried)) { 19 int c = buttonNum == 0 ? inventory.carried.count : 1; 20 if (c > slot.getMaxStackSize()) c = slot.getMaxStackSize(); 21 slot.set(inventory.carried.remove(c)); 22 if (inventory.carried.count == 0) inventory.carried = null; 23 } else if (clicked != null && inventory.carried != null) { 24 25 if (slot.mayPlace(inventory.carried)) { 26 if (clicked.id != inventory.carried.id) { 27 if (inventory.carried.count <= slot.getMaxStackSize()) { 28 ItemInstance tmp = clicked; 29 slot.set(inventory.carried); 30 inventory.carried = tmp; 31 } 32 } else if (clicked.id == inventory.carried.id) { 33 if (buttonNum == 0) { 34 int c = inventory.carried.count; 35 if (c > slot.getMaxStackSize() - clicked.count) c = slot.getMaxStackSize() - clicked.count; 36 if (c > inventory.carried.getMaxStackSize() - clicked.count) c = inventory.carried.getMaxStackSize() - clicked.count; 37 inventory.carried.remove(c); 38 if (inventory.carried.count == 0) inventory.carried = null; 39 clicked.count += c; 40 } else if (buttonNum == 1) { 41 int c = 1; 42 if (c > slot.getMaxStackSize() - clicked.count) c = slot.getMaxStackSize() - clicked.count; 43 if (c > inventory.carried.getMaxStackSize() - clicked.count) c = inventory.carried.getMaxStackSize() - clicked.count; 44 inventory.carried.remove(c); 45 if (inventory.carried.count == 0) inventory.carried = null; 46 clicked.count += c; 47 } 48 } 49 } else { 50 if (clicked.id == inventory.carried.id && inventory.carried.getMaxStackSize() > 1) { 51 int c = clicked.count; 52 if (c > 0 && c + inventory.carried.count <= inventory.carried.getMaxStackSize()) { 53 inventory.carried.count += c; 54 clicked.remove(c); 55 if (clicked.count == 0) slot.set(null); 56 slot.onTake(); 57 } 58 } 59 } 60 } 61 slot.setChanged(); 62 } else if (inventory.carried != null) { 63 if (clickedOutside) { 64 if (buttonNum == 0) { 65 player.drop(inventory.carried); 66 inventory.carried = null; 67 } 68 if (buttonNum == 1) { 69 player.drop(inventory.carried.remove(1)); 70 if (inventory.carried.count == 0) inventory.carried = null; 71 } 72 } 73 } 74 } 75 76 public static void handleClose(Player player) { 77 Inventory inventory = player.inventory; 78 if (inventory.carried != null) { 79 player.drop(inventory.carried); 80 inventory.carried = null; 81 } 82 }*/ 83 84};