diff options
Diffstat (limited to 'src/main/java/org/chrisoft/trashyaddon/commands')
-rw-r--r-- | src/main/java/org/chrisoft/trashyaddon/commands/MapLocateCommand.java | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/main/java/org/chrisoft/trashyaddon/commands/MapLocateCommand.java b/src/main/java/org/chrisoft/trashyaddon/commands/MapLocateCommand.java new file mode 100644 index 0000000..c965b1a --- /dev/null +++ b/src/main/java/org/chrisoft/trashyaddon/commands/MapLocateCommand.java @@ -0,0 +1,43 @@ +package org.chrisoft.trashyaddon.commands; + +import com.mojang.brigadier.arguments.IntegerArgumentType; +import com.mojang.brigadier.builder.LiteralArgumentBuilder; +import meteordevelopment.meteorclient.commands.Command; +import net.minecraft.command.CommandSource; +import net.minecraft.entity.EntityType; +import net.minecraft.entity.decoration.ItemFrameEntity; +import net.minecraft.client.MinecraftClient; +import net.minecraft.entity.Entity; + +import java.text.Format; +import java.util.Formatter; +import java.util.OptionalInt; + +import static com.mojang.brigadier.Command.SINGLE_SUCCESS; + +public class MapLocateCommand extends Command { + private final MinecraftClient mc = MinecraftClient.getInstance(); + public MapLocateCommand() { + super("ml", "Find item frames with a certain map in them. Will eventually be replaced with an enhanced ESP module."); + } + + @Override + public void build(LiteralArgumentBuilder<CommandSource> builder) { + builder.then(argument("id", IntegerArgumentType.integer()).executes(context -> { + int targetID = IntegerArgumentType.getInteger(context, "id"); + for (Entity e : mc.world.getEntities()) { + if (e.getType() != EntityType.ITEM_FRAME && e.getType() != EntityType.GLOW_ITEM_FRAME) + continue; + ItemFrameEntity ife = (ItemFrameEntity) e; + OptionalInt oid = ife.getMapId(); + if (oid.isEmpty()) + continue; + int id = oid.getAsInt(); + Formatter fmt = new Formatter(); + if (id == targetID) + info(fmt.format("Map frame found at %.2f %.2f %.2f", ife.getPos().x, ife.getPos().y, ife.getPos().z).toString()); + } + return SINGLE_SUCCESS; + })); + } +} |