aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/MouseInventoryClickHandler.h
diff options
context:
space:
mode:
authordaoge_cmd <3523206925@qq.com>2026-03-01 12:16:08 +0800
committerdaoge_cmd <3523206925@qq.com>2026-03-01 12:16:08 +0800
commitb691c43c44ff180d10e7d4a9afc83b98551ff586 (patch)
tree3e9849222cbc6ba49f2f1fc6e5fe7179632c7390 /Minecraft.World/MouseInventoryClickHandler.h
parentdef8cb415354ac390b7e89052a50605285f1aca9 (diff)
Initial commit
Diffstat (limited to 'Minecraft.World/MouseInventoryClickHandler.h')
-rw-r--r--Minecraft.World/MouseInventoryClickHandler.h84
1 files changed, 84 insertions, 0 deletions
diff --git a/Minecraft.World/MouseInventoryClickHandler.h b/Minecraft.World/MouseInventoryClickHandler.h
new file mode 100644
index 00000000..ab451687
--- /dev/null
+++ b/Minecraft.World/MouseInventoryClickHandler.h
@@ -0,0 +1,84 @@
+#pragma once
+
+// 4J The body of this class was commented out in Java. Copying here for completeness
+
+class MouseInventoryClickHandler
+{
+/* public static void handle(int buttonNum, boolean clickedOutside, int slotId, Player player) {
+ Inventory inventory = player.inventory;
+ Slot slot = player.getInventorySlot(slotId);
+ if (slot != null) {
+ ItemInstance clicked = slot.getItem();
+ if (clicked == null && inventory.carried == null) {
+ } else if (clicked != null && inventory.carried == null) {
+ int c = buttonNum == 0 ? clicked.count : (clicked.count + 1) / 2;
+ inventory.carried = slot.container.removeItem(slot.slot, c);
+ if (clicked.count == 0) slot.set(null);
+ slot.onTake();
+ } else if (clicked == null && inventory.carried != null && slot.mayPlace(inventory.carried)) {
+ int c = buttonNum == 0 ? inventory.carried.count : 1;
+ if (c > slot.getMaxStackSize()) c = slot.getMaxStackSize();
+ slot.set(inventory.carried.remove(c));
+ if (inventory.carried.count == 0) inventory.carried = null;
+ } else if (clicked != null && inventory.carried != null) {
+
+ if (slot.mayPlace(inventory.carried)) {
+ if (clicked.id != inventory.carried.id) {
+ if (inventory.carried.count <= slot.getMaxStackSize()) {
+ ItemInstance tmp = clicked;
+ slot.set(inventory.carried);
+ inventory.carried = tmp;
+ }
+ } else if (clicked.id == inventory.carried.id) {
+ if (buttonNum == 0) {
+ int c = inventory.carried.count;
+ if (c > slot.getMaxStackSize() - clicked.count) c = slot.getMaxStackSize() - clicked.count;
+ if (c > inventory.carried.getMaxStackSize() - clicked.count) c = inventory.carried.getMaxStackSize() - clicked.count;
+ inventory.carried.remove(c);
+ if (inventory.carried.count == 0) inventory.carried = null;
+ clicked.count += c;
+ } else if (buttonNum == 1) {
+ int c = 1;
+ if (c > slot.getMaxStackSize() - clicked.count) c = slot.getMaxStackSize() - clicked.count;
+ if (c > inventory.carried.getMaxStackSize() - clicked.count) c = inventory.carried.getMaxStackSize() - clicked.count;
+ inventory.carried.remove(c);
+ if (inventory.carried.count == 0) inventory.carried = null;
+ clicked.count += c;
+ }
+ }
+ } else {
+ if (clicked.id == inventory.carried.id && inventory.carried.getMaxStackSize() > 1) {
+ int c = clicked.count;
+ if (c > 0 && c + inventory.carried.count <= inventory.carried.getMaxStackSize()) {
+ inventory.carried.count += c;
+ clicked.remove(c);
+ if (clicked.count == 0) slot.set(null);
+ slot.onTake();
+ }
+ }
+ }
+ }
+ slot.setChanged();
+ } else if (inventory.carried != null) {
+ if (clickedOutside) {
+ if (buttonNum == 0) {
+ player.drop(inventory.carried);
+ inventory.carried = null;
+ }
+ if (buttonNum == 1) {
+ player.drop(inventory.carried.remove(1));
+ if (inventory.carried.count == 0) inventory.carried = null;
+ }
+ }
+ }
+ }
+
+ public static void handleClose(Player player) {
+ Inventory inventory = player.inventory;
+ if (inventory.carried != null) {
+ player.drop(inventory.carried);
+ inventory.carried = null;
+ }
+ }*/
+
+}; \ No newline at end of file