From a5cf719060551ec82ae4656469d5886943166598 Mon Sep 17 00:00:00 2001 From: ThebestkillerTBK <2593828650@qq.com> Date: Sun, 22 Jan 2023 14:26:02 +0800 Subject: [PATCH] AutoSteal/Dump support more screens --- .../meteorclient/systems/modules/misc/InventoryTweaks.java | 6 ++---- .../meteorclient/utils/player/SlotUtils.java | 4 +++- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/InventoryTweaks.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/InventoryTweaks.java index bc799b1453..15a67974a3 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/InventoryTweaks.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/InventoryTweaks.java @@ -34,9 +34,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.item.Wearable; import net.minecraft.network.packet.c2s.play.CloseHandledScreenC2SPacket; -import net.minecraft.screen.GenericContainerScreenHandler; import net.minecraft.screen.ScreenHandler; -import net.minecraft.screen.ShulkerBoxScreenHandler; import net.minecraft.screen.slot.Slot; import net.minecraft.screen.slot.SlotActionType; import org.lwjgl.glfw.GLFW; @@ -431,11 +429,11 @@ private void moveSlots(ScreenHandler handler, int start, int end, boolean steal) } public void steal(ScreenHandler handler) { - MeteorExecutor.execute(() -> moveSlots(handler, 0, SlotUtils.indexToId(handler.slots.size()), true)); + MeteorExecutor.execute(() -> moveSlots(handler, 0, SlotUtils.indexToId(SlotUtils.MAIN_START, handler), true)); } public void dump(ScreenHandler handler) { - int playerInvOffset = SlotUtils.indexToId(SlotUtils.HOTBAR_START); + int playerInvOffset = SlotUtils.indexToId(SlotUtils.MAIN_START, handler); MeteorExecutor.execute(() -> moveSlots(handler, playerInvOffset, playerInvOffset + 4 * 9, false)); } diff --git a/src/main/java/meteordevelopment/meteorclient/utils/player/SlotUtils.java b/src/main/java/meteordevelopment/meteorclient/utils/player/SlotUtils.java index 82b6c56fcd..d2bf7abe95 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/player/SlotUtils.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/player/SlotUtils.java @@ -33,8 +33,10 @@ public class SlotUtils { public static int indexToId(int i) { if (mc.player == null) return -1; - ScreenHandler handler = mc.player.currentScreenHandler; + return indexToId(i, mc.player.currentScreenHandler); + } + public static int indexToId(int i, ScreenHandler handler) { if (handler instanceof PlayerScreenHandler) return survivalInventory(i); else if (handler instanceof CreativeInventoryScreen.CreativeScreenHandler) return creativeInventory(i); else if (handler instanceof GenericContainerScreenHandler) return genericContainer(i, ((GenericContainerScreenHandler) handler).getRows());