Skip to content

Commit

Permalink
Make .peek work for containers in item frames
Browse files Browse the repository at this point in the history
  • Loading branch information
IExploitableMan authored Jul 3, 2024
1 parent f33e87b commit 7e65731
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@
import meteordevelopment.meteorclient.commands.Command;
import meteordevelopment.meteorclient.utils.Utils;
import net.minecraft.command.CommandSource;
import net.minecraft.entity.decoration.ItemFrameEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.text.Text;

public class PeekCommand extends Command {
private static final ItemStack[] ITEMS = new ItemStack[27];
private static final SimpleCommandExceptionType NOT_HOLDING_SHULKER_BOX = new SimpleCommandExceptionType(Text.literal("You must be holding a storage block with items in it."));
private static final SimpleCommandExceptionType CANT_PEEK = new SimpleCommandExceptionType(Text.literal("You must be holding a storage block or looking at an item frame."));

public PeekCommand() {
super("peek", "Lets you see what's inside storage block items.");
Expand All @@ -26,7 +27,10 @@ public void build(LiteralArgumentBuilder<CommandSource> builder) {
builder.executes(context -> {
if (Utils.openContainer(mc.player.getMainHandStack(), ITEMS, true)) return SINGLE_SUCCESS;
else if (Utils.openContainer(mc.player.getOffHandStack(), ITEMS, true)) return SINGLE_SUCCESS;
else throw NOT_HOLDING_SHULKER_BOX.create();
else if (mc.targetedEntity instanceof ItemFrameEntity &&
Utils.openContainer(((ItemFrameEntity) mc.targetedEntity).getHeldItemStack(), ITEMS, true)
) return SINGLE_SUCCESS;
else throw CANT_PEEK.create();
});
}
}

0 comments on commit 7e65731

Please sign in to comment.