|
| 1 | +package com.nekiplay.hypixelcry.utils; |
| 2 | + |
| 3 | +import net.minecraft.screen.slot.SlotActionType; |
| 4 | + |
| 5 | +import static com.nekiplay.hypixelcry.HypixelCry.mc; |
| 6 | + |
| 7 | +public class InventoryUtils { |
| 8 | + public static void clickSlotWithId(int slotId, int button, SlotActionType actionType, int syncId) { |
| 9 | + if (mc.interactionManager != null && mc.player != null) { |
| 10 | + mc.interactionManager.clickSlot(syncId, slotId, button, actionType, mc.player); |
| 11 | + } |
| 12 | + } |
| 13 | + |
| 14 | + public static void clickContainerSlot(int slot, int button, SlotActionType actionType) { |
| 15 | + if (mc.player != null && mc.player.currentScreenHandler != null) { |
| 16 | + clickSlotWithId(slot, button, actionType, mc.player.currentScreenHandler.syncId); |
| 17 | + } |
| 18 | + } |
| 19 | + |
| 20 | + public static void clickSlot(int slot, int button, SlotActionType actionType) { |
| 21 | + if (mc.player != null && mc.player.playerScreenHandler != null) { |
| 22 | + clickSlotWithId(slot, button, actionType, mc.player.playerScreenHandler.syncId); |
| 23 | + } |
| 24 | + } |
| 25 | + |
| 26 | + public static void swapSlots(int slot, int hotbarSlot) { |
| 27 | + if (mc.player != null && mc.player.playerScreenHandler != null) { |
| 28 | + clickSlotWithId(slot, hotbarSlot, SlotActionType.SWAP, mc.player.playerScreenHandler.syncId); |
| 29 | + } |
| 30 | + } |
| 31 | + |
| 32 | + // Дополнительные полезные методы |
| 33 | + public static void leftClickSlot(int slot) { |
| 34 | + clickSlot(slot, 0, SlotActionType.PICKUP); |
| 35 | + } |
| 36 | + |
| 37 | + public static void rightClickSlot(int slot) { |
| 38 | + clickSlot(slot, 1, SlotActionType.PICKUP); |
| 39 | + } |
| 40 | + |
| 41 | + public static void dropSlot(int slot) { |
| 42 | + clickSlot(slot, 0, SlotActionType.THROW); |
| 43 | + } |
| 44 | + |
| 45 | + public static void dropAllFromSlot(int slot) { |
| 46 | + clickSlot(slot, 1, SlotActionType.THROW); |
| 47 | + } |
| 48 | +} |
0 commit comments