aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/chrisoft/trashyaddon/commands/EntityHighlightCommand.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/chrisoft/trashyaddon/commands/EntityHighlightCommand.java')
-rw-r--r--src/main/java/org/chrisoft/trashyaddon/commands/EntityHighlightCommand.java81
1 files changed, 81 insertions, 0 deletions
diff --git a/src/main/java/org/chrisoft/trashyaddon/commands/EntityHighlightCommand.java b/src/main/java/org/chrisoft/trashyaddon/commands/EntityHighlightCommand.java
new file mode 100644
index 0000000..c29dfa4
--- /dev/null
+++ b/src/main/java/org/chrisoft/trashyaddon/commands/EntityHighlightCommand.java
@@ -0,0 +1,81 @@
+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 <target selector> set <color> : Highlight targeted entities with specified color
+eh <target selector> 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<UUID, Color> 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<? extends Entity> 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<? extends Entity> 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<CommandSource> 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<? extends Entity> 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<? extends Entity> 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;
+ })
+ );
+ }
+}