package org.chrisoft.trashyaddon.commands; import meteordevelopment.meteorclient.commands.Command; import meteordevelopment.meteorclient.utils.render.color.Color; import net.minecraft.command.CommandSource; import com.mojang.brigadier.builder.LiteralArgumentBuilder; import net.minecraft.entity.Entity; import org.chrisoft.trashyaddon.commands.argument.CEntityArgumentType; import org.chrisoft.trashyaddon.commands.argument.ColorCodeArgumentType; import java.util.HashMap; import java.util.List; import java.util.UUID; import static com.mojang.brigadier.Command.SINGLE_SUCCESS; import static meteordevelopment.meteorclient.MeteorClient.mc; /* Usage: eh set : Highlight targeted entities with specified color eh remove : Remove highlight from targeted entities eh clear : Remove highlight from all entities Note: This command pulls settings from your ESP module. */ public class EntityHighlightCommand extends Command { private final static HashMap entityColors = new HashMap<>(); public static void clearColors() { entityColors.clear(); } public static void setEntityColor(Entity e, Color c) { entityColors.put(e.getUuid(), c); } public static void setEntityColors(List entities, Color c) { for (Entity e : entities) setEntityColor(e, c); } public static void removeEntityColor(Entity e) { entityColors.remove(e.getUuid()); } public static void removeEntityColors(List entities) { for (Entity e : entities) removeEntityColor(e); } public static Color getEntityColor(Entity e) { return entityColors.get(e.getUuid()); } public EntityHighlightCommand() { super("eh", "Highlight selected entities."); } @Override public void build(LiteralArgumentBuilder builder) { builder.then( argument("match", CEntityArgumentType.entities()).then( literal("set").then( argument("color", ColorCodeArgumentType.colorCode()).executes(ctx -> { CEntitySelector es = ctx.getArgument("match", CEntitySelector.class); List entities = es.getClientSideEntityMatches(mc.world, mc.player.getPos()); setEntityColors(entities, ctx.getArgument("color", Color.class)); info("Successfully set highlight for " + entities.size() + " entity(ies)."); return SINGLE_SUCCESS; } ))).then( literal("remove").executes(ctx -> { CEntitySelector es = ctx.getArgument("match", CEntitySelector.class); List entities = es.getClientSideEntityMatches(mc.world, mc.player.getPos()); removeEntityColors(entities); info("Successfully removed highlight for " + entities.size() + " entity(ies)."); return SINGLE_SUCCESS; }) ) ).then( literal("clear").executes(ctx -> { clearColors(); info("Successfully removed highlight for all entities."); return SINGLE_SUCCESS; }) ); } }