Skip to content

Commit

Permalink
AutoSteal/Dump support more screens
Browse files Browse the repository at this point in the history
  • Loading branch information
hexadecimal233 authored and arlomcwalter committed Jan 28, 2023
1 parent 7379d6f commit a5cf719
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down

0 comments on commit a5cf719

Please sign in to comment.