Search in sources :

Example 1 with SINGLE_SUCCESS

use of com.mojang.brigadier.Command.SINGLE_SUCCESS in project meteor-rejects by AntiCope.

the class KickCommand method build.

@Override
public void build(LiteralArgumentBuilder<CommandSource> builder) {
    builder.then(literal("disconnect").executes(ctx -> {
        mc.player.networkHandler.onDisconnect(new DisconnectS2CPacket(new LiteralText("Disconnected via .kick command")));
        return SINGLE_SUCCESS;
    }));
    builder.then(literal("pos").executes(ctx -> {
        mc.player.networkHandler.sendPacket(new PlayerMoveC2SPacket.PositionAndOnGround(Double.NaN, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, !mc.player.isOnGround()));
        return SINGLE_SUCCESS;
    }));
    builder.then(literal("hurt").executes(ctx -> {
        mc.player.networkHandler.sendPacket(PlayerInteractEntityC2SPacket.attack(mc.player, mc.player.isSneaking()));
        return SINGLE_SUCCESS;
    }));
    builder.then(literal("chat").executes(ctx -> {
        mc.player.sendChatMessage("§0§1§");
        return SINGLE_SUCCESS;
    }));
    builder.then(literal("shutdown").executes(ctx -> {
        try {
            shutdown();
        } catch (Exception exception) {
            error("Couldn't disconnect. IOException");
        }
        return SINGLE_SUCCESS;
    }));
    builder.then(literal("crash").executes(ctx -> {
        GlfwUtil.makeJvmCrash();
        return SINGLE_SUCCESS;
    }));
}
Also used : CommandSource(net.minecraft.command.CommandSource) SINGLE_SUCCESS(com.mojang.brigadier.Command.SINGLE_SUCCESS) LiteralText(net.minecraft.text.LiteralText) Command(meteordevelopment.meteorclient.systems.commands.Command) SystemUtils(org.apache.commons.lang3.SystemUtils) PlayerInteractEntityC2SPacket(net.minecraft.network.packet.c2s.play.PlayerInteractEntityC2SPacket) GlfwUtil(net.minecraft.client.util.GlfwUtil) PlayerMoveC2SPacket(net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket) DisconnectS2CPacket(net.minecraft.network.packet.s2c.play.DisconnectS2CPacket) LiteralArgumentBuilder(com.mojang.brigadier.builder.LiteralArgumentBuilder) DisconnectS2CPacket(net.minecraft.network.packet.s2c.play.DisconnectS2CPacket) LiteralText(net.minecraft.text.LiteralText)

Example 2 with SINGLE_SUCCESS

use of com.mojang.brigadier.Command.SINGLE_SUCCESS in project meteor-rejects by AntiCope.

the class LocateCommand method build.

@Override
public void build(LiteralArgumentBuilder<CommandSource> builder) {
    builder.then(literal("lodestone").executes(ctx -> {
        ItemStack stack = mc.player.getInventory().getMainHandStack();
        if (stack.getItem() != Items.COMPASS) {
            error("You need to hold a lodestone compass");
            return SINGLE_SUCCESS;
        }
        NbtCompound tag = stack.getNbt();
        if (tag == null) {
            error("Couldn't get the NBT data. Are you holding a (highlight)lodestone(default) compass?");
            return SINGLE_SUCCESS;
        }
        NbtCompound nbt1 = tag.getCompound("LodestonePos");
        if (nbt1 == null) {
            error("Couldn't get the NBT data. Are you holding a (highlight)lodestone(default) compass?");
            return SINGLE_SUCCESS;
        }
        Vec3d coords = new Vec3d(nbt1.getDouble("X"), nbt1.getDouble("Y"), nbt1.getDouble("Z"));
        BaseText text = new LiteralText("Lodestone located at ");
        text.append(ChatUtils.formatCoords(coords));
        text.append(".");
        info(text);
        return SINGLE_SUCCESS;
    }));
    builder.then(argument("feature", EnumArgumentType.enumArgument(WorldGenUtils.Feature.stronghold)).executes(ctx -> {
        WorldGenUtils.Feature feature = EnumArgumentType.getEnum(ctx, "feature", WorldGenUtils.Feature.stronghold);
        BlockPos pos = WorldGenUtils.locateFeature(feature, mc.player.getBlockPos());
        if (pos != null) {
            BaseText text = new LiteralText(String.format("%s located at ", Utils.nameToTitle(feature.toString().replaceAll("_", "-"))));
            Vec3d coords = new Vec3d(pos.getX(), pos.getY(), pos.getZ());
            text.append(ChatUtils.formatCoords(coords));
            text.append(".");
            info(text);
            return SINGLE_SUCCESS;
        }
        if (feature == WorldGenUtils.Feature.stronghold) {
            FindItemResult eye = InvUtils.findInHotbar(Items.ENDER_EYE);
            if (eye.found()) {
                BaritoneAPI.getProvider().getPrimaryBaritone().getCommandManager().execute("follow entity minecraft:eye_of_ender");
                firstStart = null;
                firstEnd = null;
                secondStart = null;
                secondEnd = null;
                MeteorClient.EVENT_BUS.subscribe(this);
                info("Please throw the first Eye of Ender");
            }
        }
        throw NOT_FOUND.create(feature);
    }));
    builder.then(literal("cancel").executes(s -> {
        cancel();
        return SINGLE_SUCCESS;
    }));
}
Also used : EntityType(net.minecraft.entity.EntityType) LiteralText(net.minecraft.text.LiteralText) SINGLE_SUCCESS(com.mojang.brigadier.Command.SINGLE_SUCCESS) ItemStack(net.minecraft.item.ItemStack) PlaySoundS2CPacket(net.minecraft.network.packet.s2c.play.PlaySoundS2CPacket) BaseText(net.minecraft.text.BaseText) Command(meteordevelopment.meteorclient.systems.commands.Command) SoundEvents(net.minecraft.sound.SoundEvents) Vec3d(net.minecraft.util.math.Vec3d) EnumArgumentType(anticope.rejects.arguments.EnumArgumentType) FindItemResult(meteordevelopment.meteorclient.utils.player.FindItemResult) InvUtils(meteordevelopment.meteorclient.utils.player.InvUtils) ChatUtils(meteordevelopment.meteorclient.utils.player.ChatUtils) Utils(meteordevelopment.meteorclient.utils.Utils) EntitySpawnS2CPacket(net.minecraft.network.packet.s2c.play.EntitySpawnS2CPacket) BaritoneAPI(baritone.api.BaritoneAPI) BlockPos(net.minecraft.util.math.BlockPos) Items(net.minecraft.item.Items) PacketEvent(meteordevelopment.meteorclient.events.packets.PacketEvent) LiteralArgumentBuilder(com.mojang.brigadier.builder.LiteralArgumentBuilder) CommandSource(net.minecraft.command.CommandSource) NbtCompound(net.minecraft.nbt.NbtCompound) DynamicCommandExceptionType(com.mojang.brigadier.exceptions.DynamicCommandExceptionType) MeteorClient(meteordevelopment.meteorclient.MeteorClient) WorldGenUtils(anticope.rejects.utils.WorldGenUtils) EventHandler(meteordevelopment.orbit.EventHandler) BaseText(net.minecraft.text.BaseText) NbtCompound(net.minecraft.nbt.NbtCompound) FindItemResult(meteordevelopment.meteorclient.utils.player.FindItemResult) BlockPos(net.minecraft.util.math.BlockPos) ItemStack(net.minecraft.item.ItemStack) Vec3d(net.minecraft.util.math.Vec3d) LiteralText(net.minecraft.text.LiteralText)

Example 3 with SINGLE_SUCCESS

use of com.mojang.brigadier.Command.SINGLE_SUCCESS in project meteor-rejects by AntiCope.

the class SeedCommand method build.

@Override
public void build(LiteralArgumentBuilder<CommandSource> builder) {
    builder.executes(ctx -> {
        Seed seed = Seeds.get().getSeed();
        if (seed == null)
            throw NO_SEED.create();
        info(seed.toText());
        return SINGLE_SUCCESS;
    });
    builder.then(literal("list").executes(ctx -> {
        Seeds.get().seeds.forEach((name, seed) -> {
            BaseText text = new LiteralText(name + " ");
            text.append(seed.toText());
            info(text);
        });
        return SINGLE_SUCCESS;
    }));
    builder.then(literal("delete").executes(ctx -> {
        Seed seed = Seeds.get().getSeed();
        if (seed != null) {
            BaseText text = new LiteralText("Deleted ");
            text.append(seed.toText());
            info(text);
        }
        Seeds.get().seeds.remove(Utils.getWorldName());
        return SINGLE_SUCCESS;
    }));
    builder.then(argument("seed", StringArgumentType.string()).executes(ctx -> {
        Seeds.get().setSeed(StringArgumentType.getString(ctx, "seed"));
        return SINGLE_SUCCESS;
    }));
    builder.then(argument("seed", StringArgumentType.string()).then(argument("version", EnumArgumentType.enumArgument(MCVersion.latest())).executes(ctx -> {
        Seeds.get().setSeed(StringArgumentType.getString(ctx, "seed"), EnumArgumentType.getEnum(ctx, "version", MCVersion.latest()));
        return SINGLE_SUCCESS;
    })));
}
Also used : LiteralText(net.minecraft.text.LiteralText) MCVersion(com.seedfinding.mccore.version.MCVersion) LiteralArgumentBuilder(com.mojang.brigadier.builder.LiteralArgumentBuilder) SimpleCommandExceptionType(com.mojang.brigadier.exceptions.SimpleCommandExceptionType) CommandSource(net.minecraft.command.CommandSource) Seed(anticope.rejects.utils.seeds.Seed) SINGLE_SUCCESS(com.mojang.brigadier.Command.SINGLE_SUCCESS) StringArgumentType(com.mojang.brigadier.arguments.StringArgumentType) BaseText(net.minecraft.text.BaseText) Command(meteordevelopment.meteorclient.systems.commands.Command) EnumArgumentType(anticope.rejects.arguments.EnumArgumentType) Seeds(anticope.rejects.utils.seeds.Seeds) Utils(meteordevelopment.meteorclient.utils.Utils) BaseText(net.minecraft.text.BaseText) Seed(anticope.rejects.utils.seeds.Seed) LiteralText(net.minecraft.text.LiteralText)

Example 4 with SINGLE_SUCCESS

use of com.mojang.brigadier.Command.SINGLE_SUCCESS in project meteor-client by MeteorDevelopment.

the class SwarmCommand method build.

@Override
public void build(LiteralArgumentBuilder<CommandSource> builder) {
    builder.then(literal("disconnect").executes(context -> {
        Swarm swarm = Modules.get().get(Swarm.class);
        if (swarm.isActive()) {
            swarm.close();
        } else {
            throw SWARM_NOT_ACTIVE.create();
        }
        return SINGLE_SUCCESS;
    }));
    builder.then(literal("join").then(argument("ip", StringArgumentType.string()).then(argument("port", IntegerArgumentType.integer(0, 65535)).executes(context -> {
        Swarm swarm = Modules.get().get(Swarm.class);
        if (!swarm.isActive())
            swarm.toggle();
        swarm.close();
        swarm.mode.set(Swarm.Mode.Worker);
        swarm.worker = new SwarmWorker(StringArgumentType.getString(context, "ip"), IntegerArgumentType.getInteger(context, "port"));
        return SINGLE_SUCCESS;
    }))));
    builder.then(literal("connections").executes(context -> {
        Swarm swarm = Modules.get().get(Swarm.class);
        if (swarm.isActive()) {
            if (swarm.isHost()) {
                if (swarm.host.getConnectionCount() > 0) {
                    ChatUtils.info("--- Swarm Connections (highlight)(%s/%s)(default) ---", swarm.host.getConnectionCount(), swarm.host.getConnections().length);
                    for (int i = 0; i < swarm.host.getConnections().length; i++) {
                        SwarmConnection connection = swarm.host.getConnections()[i];
                        if (connection != null)
                            ChatUtils.info("(highlight)Worker %s(default): %s.", i, connection.getConnection());
                    }
                } else {
                    warning("No active connections");
                }
            } else if (swarm.isWorker()) {
                info("Connected to (highlight)%s", swarm.worker.getConnection());
            }
        } else {
            throw SWARM_NOT_ACTIVE.create();
        }
        return SINGLE_SUCCESS;
    }));
    builder.then(literal("follow").executes(context -> {
        Swarm swarm = Modules.get().get(Swarm.class);
        if (swarm.isActive()) {
            if (swarm.isHost()) {
                swarm.host.sendMessage(context.getInput() + " " + mc.player.getEntityName());
            } else if (swarm.isWorker()) {
                error("The follow host command must be used by the host.");
            }
        } else {
            throw SWARM_NOT_ACTIVE.create();
        }
        return SINGLE_SUCCESS;
    }).then(argument("player", PlayerArgumentType.player()).executes(context -> {
        PlayerEntity playerEntity = PlayerArgumentType.getPlayer(context);
        Swarm swarm = Modules.get().get(Swarm.class);
        if (swarm.isActive()) {
            if (swarm.isHost()) {
                swarm.host.sendMessage(context.getInput());
            } else if (swarm.isWorker() && playerEntity != null) {
                BaritoneAPI.getProvider().getPrimaryBaritone().getFollowProcess().follow(entity -> entity.getEntityName().equalsIgnoreCase(playerEntity.getEntityName()));
            }
        } else {
            throw SWARM_NOT_ACTIVE.create();
        }
        return SINGLE_SUCCESS;
    })));
    builder.then(literal("goto").then(argument("x", IntegerArgumentType.integer()).then(argument("z", IntegerArgumentType.integer()).executes(context -> {
        Swarm swarm = Modules.get().get(Swarm.class);
        if (swarm.isActive()) {
            if (swarm.isHost()) {
                swarm.host.sendMessage(context.getInput());
            } else if (swarm.isWorker()) {
                int x = IntegerArgumentType.getInteger(context, "x");
                int z = IntegerArgumentType.getInteger(context, "z");
                BaritoneAPI.getProvider().getPrimaryBaritone().getCustomGoalProcess().setGoalAndPath(new GoalXZ(x, z));
            }
        } else {
            throw SWARM_NOT_ACTIVE.create();
        }
        return SINGLE_SUCCESS;
    }))));
    builder.then(literal("infinity-miner").executes(context -> {
        Swarm swarm = Modules.get().get(Swarm.class);
        if (swarm.isActive()) {
            if (swarm.isHost()) {
                swarm.host.sendMessage(context.getInput());
            } else if (swarm.isWorker()) {
                runInfinityMiner();
            }
        } else {
            throw SWARM_NOT_ACTIVE.create();
        }
        return SINGLE_SUCCESS;
    }).then(argument("target", BlockStateArgumentType.blockState()).executes(context -> {
        Swarm swarm = Modules.get().get(Swarm.class);
        if (swarm.isActive()) {
            if (swarm.isHost()) {
                swarm.host.sendMessage(context.getInput());
            } else if (swarm.isWorker()) {
                Modules.get().get(InfinityMiner.class).targetBlocks.set(List.of(context.getArgument("target", BlockStateArgument.class).getBlockState().getBlock()));
                runInfinityMiner();
            }
        } else {
            throw SWARM_NOT_ACTIVE.create();
        }
        return SINGLE_SUCCESS;
    }).then(argument("repair", BlockStateArgumentType.blockState()).executes(context -> {
        Swarm swarm = Modules.get().get(Swarm.class);
        if (swarm.isActive()) {
            if (swarm.isHost()) {
                swarm.host.sendMessage(context.getInput());
            } else if (swarm.isWorker()) {
                Modules.get().get(InfinityMiner.class).targetBlocks.set(List.of(context.getArgument("target", BlockStateArgument.class).getBlockState().getBlock()));
                Modules.get().get(InfinityMiner.class).repairBlocks.set(List.of(context.getArgument("repair", BlockStateArgument.class).getBlockState().getBlock()));
                runInfinityMiner();
            }
        } else {
            throw SWARM_NOT_ACTIVE.create();
        }
        return SINGLE_SUCCESS;
    }))).then(literal("logout").then(argument("logout", BoolArgumentType.bool()).executes(context -> {
        Swarm swarm = Modules.get().get(Swarm.class);
        if (swarm.isActive()) {
            if (swarm.isHost()) {
                swarm.host.sendMessage(context.getInput());
            } else if (swarm.isWorker()) {
                Modules.get().get(InfinityMiner.class).logOut.set(BoolArgumentType.getBool(context, "logout"));
            }
        } else {
            throw SWARM_NOT_ACTIVE.create();
        }
        return SINGLE_SUCCESS;
    }))).then(literal("walkhome").then(argument("walkhome", BoolArgumentType.bool()).executes(context -> {
        Swarm swarm = Modules.get().get(Swarm.class);
        if (swarm.isActive()) {
            if (swarm.isHost()) {
                swarm.host.sendMessage(context.getInput());
            } else if (swarm.isWorker()) {
                Modules.get().get(InfinityMiner.class).walkHome.set(BoolArgumentType.getBool(context, "walkhome"));
            }
        } else {
            throw SWARM_NOT_ACTIVE.create();
        }
        return SINGLE_SUCCESS;
    }))));
    builder.then(literal("mine").then(argument("block", BlockStateArgumentType.blockState()).executes(context -> {
        Swarm swarm = Modules.get().get(Swarm.class);
        if (swarm.isActive()) {
            if (swarm.isHost()) {
                swarm.host.sendMessage(context.getInput());
            } else if (swarm.isWorker()) {
                swarm.worker.target = context.getArgument("block", BlockStateArgument.class).getBlockState().getBlock();
            }
        } else {
            throw SWARM_NOT_ACTIVE.create();
        }
        return SINGLE_SUCCESS;
    })));
    builder.then(literal("toggle").then(argument("module", ModuleArgumentType.module()).executes(context -> {
        Swarm swarm = Modules.get().get(Swarm.class);
        if (swarm.isActive()) {
            if (swarm.isHost()) {
                swarm.host.sendMessage(context.getInput());
            } else if (swarm.isWorker()) {
                Module module = ModuleArgumentType.getModule(context, "module");
                module.toggle();
            }
        } else {
            throw SWARM_NOT_ACTIVE.create();
        }
        return SINGLE_SUCCESS;
    }).then(literal("on").executes(context -> {
        Swarm swarm = Modules.get().get(Swarm.class);
        if (swarm.isActive()) {
            if (swarm.isHost()) {
                swarm.host.sendMessage(context.getInput());
            } else if (swarm.isWorker()) {
                Module m = ModuleArgumentType.getModule(context, "module");
                if (!m.isActive())
                    m.toggle();
            }
        } else {
            throw SWARM_NOT_ACTIVE.create();
        }
        return SINGLE_SUCCESS;
    })).then(literal("off").executes(context -> {
        Swarm swarm = Modules.get().get(Swarm.class);
        if (swarm.isActive()) {
            if (swarm.isHost()) {
                swarm.host.sendMessage(context.getInput());
            } else if (swarm.isWorker()) {
                Module m = ModuleArgumentType.getModule(context, "module");
                if (m.isActive())
                    m.toggle();
            }
        } else {
            throw SWARM_NOT_ACTIVE.create();
        }
        return SINGLE_SUCCESS;
    }))));
    builder.then(literal("scatter").executes(context -> {
        Swarm swarm = Modules.get().get(Swarm.class);
        if (swarm.isActive()) {
            if (swarm.isHost()) {
                swarm.host.sendMessage(context.getInput());
            } else if (swarm.isWorker()) {
                scatter(100);
            }
        } else {
            throw SWARM_NOT_ACTIVE.create();
        }
        return SINGLE_SUCCESS;
    }).then(argument("radius", IntegerArgumentType.integer()).executes(context -> {
        Swarm swarm = Modules.get().get(Swarm.class);
        if (swarm.isActive()) {
            if (swarm.isHost()) {
                swarm.host.sendMessage(context.getInput());
            } else if (swarm.isWorker()) {
                scatter(IntegerArgumentType.getInteger(context, "radius"));
            }
        } else {
            throw SWARM_NOT_ACTIVE.create();
        }
        return SINGLE_SUCCESS;
    })));
    builder.then(literal("stop").executes(context -> {
        Swarm swarm = Modules.get().get(Swarm.class);
        if (swarm.isActive()) {
            if (swarm.isHost()) {
                swarm.host.sendMessage(context.getInput());
            } else if (swarm.isWorker()) {
                BaritoneAPI.getProvider().getPrimaryBaritone().getPathingBehavior().cancelEverything();
            }
        } else {
            throw SWARM_NOT_ACTIVE.create();
        }
        return SINGLE_SUCCESS;
    }));
    builder.then(literal("exec").then(argument("command", StringArgumentType.greedyString()).executes(context -> {
        Swarm swarm = Modules.get().get(Swarm.class);
        if (swarm.isActive()) {
            if (swarm.isHost()) {
                swarm.host.sendMessage(context.getInput());
            } else if (swarm.isWorker()) {
                mc.player.sendChatMessage(StringArgumentType.getString(context, "command"));
            }
        } else {
            throw SWARM_NOT_ACTIVE.create();
        }
        return SINGLE_SUCCESS;
    })));
}
Also used : LiteralText(net.minecraft.text.LiteralText) PlayerArgumentType(meteordevelopment.meteorclient.systems.commands.arguments.PlayerArgumentType) Random(java.util.Random) SimpleCommandExceptionType(com.mojang.brigadier.exceptions.SimpleCommandExceptionType) ModuleArgumentType(meteordevelopment.meteorclient.systems.commands.arguments.ModuleArgumentType) SINGLE_SUCCESS(com.mojang.brigadier.Command.SINGLE_SUCCESS) BoolArgumentType(com.mojang.brigadier.arguments.BoolArgumentType) StringArgumentType(com.mojang.brigadier.arguments.StringArgumentType) GoalXZ(baritone.api.pathing.goals.GoalXZ) Command(meteordevelopment.meteorclient.systems.commands.Command) Module(meteordevelopment.meteorclient.systems.modules.Module) Modules(meteordevelopment.meteorclient.systems.modules.Modules) ChatUtils(meteordevelopment.meteorclient.utils.player.ChatUtils) BlockStateArgument(net.minecraft.command.argument.BlockStateArgument) BaritoneAPI(baritone.api.BaritoneAPI) PlayerEntity(net.minecraft.entity.player.PlayerEntity) LiteralArgumentBuilder(com.mojang.brigadier.builder.LiteralArgumentBuilder) CommandSource(net.minecraft.command.CommandSource) BlockStateArgumentType(net.minecraft.command.argument.BlockStateArgumentType) Swarm(meteordevelopment.meteorclient.systems.modules.misc.swarm.Swarm) List(java.util.List) InfinityMiner(meteordevelopment.meteorclient.systems.modules.world.InfinityMiner) IntegerArgumentType(com.mojang.brigadier.arguments.IntegerArgumentType) SwarmConnection(meteordevelopment.meteorclient.systems.modules.misc.swarm.SwarmConnection) SwarmWorker(meteordevelopment.meteorclient.systems.modules.misc.swarm.SwarmWorker) Swarm(meteordevelopment.meteorclient.systems.modules.misc.swarm.Swarm) GoalXZ(baritone.api.pathing.goals.GoalXZ) SwarmConnection(meteordevelopment.meteorclient.systems.modules.misc.swarm.SwarmConnection) InfinityMiner(meteordevelopment.meteorclient.systems.modules.world.InfinityMiner) SwarmWorker(meteordevelopment.meteorclient.systems.modules.misc.swarm.SwarmWorker) Module(meteordevelopment.meteorclient.systems.modules.Module) PlayerEntity(net.minecraft.entity.player.PlayerEntity)

Example 5 with SINGLE_SUCCESS

use of com.mojang.brigadier.Command.SINGLE_SUCCESS in project Client by MatHax.

the class SwarmCommand method build.

@Override
public void build(LiteralArgumentBuilder<CommandSource> builder) {
    builder.then(literal("disconnect").executes(context -> {
        Swarm swarm = Modules.get().get(Swarm.class);
        if (swarm.isActive())
            swarm.close();
        else
            throw SWARM_NOT_ACTIVE.create();
        return SINGLE_SUCCESS;
    }));
    builder.then(literal("join").then(argument("ip", StringArgumentType.string()).then(argument("port", IntegerArgumentType.integer(0, 65535)).executes(context -> {
        Swarm swarm = Modules.get().get(Swarm.class);
        if (!swarm.isActive())
            swarm.toggle();
        swarm.close();
        swarm.mode.set(Swarm.Mode.Worker);
        swarm.worker = new SwarmWorker(StringArgumentType.getString(context, "ip"), IntegerArgumentType.getInteger(context, "port"));
        return SINGLE_SUCCESS;
    }))));
    builder.then(literal("connections").executes(context -> {
        Swarm swarm = Modules.get().get(Swarm.class);
        if (swarm.isActive()) {
            if (swarm.isHost()) {
                if (swarm.host.getConnectionCount() > 0) {
                    ChatUtils.info("--- Swarm Connections (highlight)(%s/%s)(default) ---", swarm.host.getConnectionCount(), swarm.host.getConnections().length);
                    for (int i = 0; i < swarm.host.getConnections().length; i++) {
                        SwarmConnection connection = swarm.host.getConnections()[i];
                        if (connection != null)
                            ChatUtils.info("(highlight)Worker %s(default): %s.", i, connection.getConnection());
                    }
                } else
                    warning("No active connections");
            } else if (swarm.isWorker())
                info("Connected to (highlight)%s", swarm.worker.getConnection());
        } else
            throw SWARM_NOT_ACTIVE.create();
        return SINGLE_SUCCESS;
    }));
    builder.then(literal("follow").executes(context -> {
        Swarm swarm = Modules.get().get(Swarm.class);
        if (swarm.isActive()) {
            if (swarm.isHost())
                swarm.host.sendMessage(context.getInput() + " " + mc.player.getEntityName());
            else if (swarm.isWorker())
                error("The follow host command must be used by the host.");
        } else
            throw SWARM_NOT_ACTIVE.create();
        return SINGLE_SUCCESS;
    }).then(argument("player", PlayerArgumentType.player()).executes(context -> {
        PlayerEntity playerEntity = PlayerArgumentType.getPlayer(context);
        Swarm swarm = Modules.get().get(Swarm.class);
        if (swarm.isActive()) {
            if (swarm.isHost())
                swarm.host.sendMessage(context.getInput());
            else if (swarm.isWorker() && playerEntity != null)
                BaritoneAPI.getProvider().getPrimaryBaritone().getFollowProcess().follow(entity -> entity.getEntityName().equalsIgnoreCase(playerEntity.getEntityName()));
        } else
            throw SWARM_NOT_ACTIVE.create();
        return SINGLE_SUCCESS;
    })));
    builder.then(literal("goto").then(argument("x", IntegerArgumentType.integer()).then(argument("z", IntegerArgumentType.integer()).executes(context -> {
        Swarm swarm = Modules.get().get(Swarm.class);
        if (swarm.isActive()) {
            if (swarm.isHost())
                swarm.host.sendMessage(context.getInput());
            else if (swarm.isWorker()) {
                int x = IntegerArgumentType.getInteger(context, "x");
                int z = IntegerArgumentType.getInteger(context, "z");
                BaritoneAPI.getProvider().getPrimaryBaritone().getCustomGoalProcess().setGoalAndPath(new GoalXZ(x, z));
            }
        } else
            throw SWARM_NOT_ACTIVE.create();
        return SINGLE_SUCCESS;
    }))));
    builder.then(literal("infinity-miner").executes(context -> {
        Swarm swarm = Modules.get().get(Swarm.class);
        if (swarm.isActive()) {
            if (swarm.isHost())
                swarm.host.sendMessage(context.getInput());
            else if (swarm.isWorker())
                runInfinityMiner();
        } else
            throw SWARM_NOT_ACTIVE.create();
        return SINGLE_SUCCESS;
    }).then(argument("target", BlockStateArgumentType.blockState()).executes(context -> {
        Swarm swarm = Modules.get().get(Swarm.class);
        if (swarm.isActive()) {
            if (swarm.isHost())
                swarm.host.sendMessage(context.getInput());
            else if (swarm.isWorker()) {
                Modules.get().get(InfinityMiner.class).targetBlocks.set(List.of(context.getArgument("target", BlockStateArgument.class).getBlockState().getBlock()));
                runInfinityMiner();
            }
        } else
            throw SWARM_NOT_ACTIVE.create();
        return SINGLE_SUCCESS;
    }).then(argument("repair", BlockStateArgumentType.blockState()).executes(context -> {
        Swarm swarm = Modules.get().get(Swarm.class);
        if (swarm.isActive()) {
            if (swarm.isHost())
                swarm.host.sendMessage(context.getInput());
            else if (swarm.isWorker()) {
                Modules.get().get(InfinityMiner.class).targetBlocks.set(List.of(context.getArgument("target", BlockStateArgument.class).getBlockState().getBlock()));
                Modules.get().get(InfinityMiner.class).repairBlocks.set(List.of(context.getArgument("repair", BlockStateArgument.class).getBlockState().getBlock()));
                runInfinityMiner();
            }
        } else
            throw SWARM_NOT_ACTIVE.create();
        return SINGLE_SUCCESS;
    }))).then(literal("logout").then(argument("logout", BoolArgumentType.bool()).executes(context -> {
        Swarm swarm = Modules.get().get(Swarm.class);
        if (swarm.isActive()) {
            if (swarm.isHost())
                swarm.host.sendMessage(context.getInput());
            else if (swarm.isWorker())
                Modules.get().get(InfinityMiner.class).logOut.set(BoolArgumentType.getBool(context, "logout"));
        } else
            throw SWARM_NOT_ACTIVE.create();
        return SINGLE_SUCCESS;
    }))).then(literal("walkhome").then(argument("walkhome", BoolArgumentType.bool()).executes(context -> {
        Swarm swarm = Modules.get().get(Swarm.class);
        if (swarm.isActive()) {
            if (swarm.isHost())
                swarm.host.sendMessage(context.getInput());
            else if (swarm.isWorker())
                Modules.get().get(InfinityMiner.class).walkHome.set(BoolArgumentType.getBool(context, "walkhome"));
        } else
            throw SWARM_NOT_ACTIVE.create();
        return SINGLE_SUCCESS;
    }))));
    builder.then(literal("mine").then(argument("block", BlockStateArgumentType.blockState()).executes(context -> {
        Swarm swarm = Modules.get().get(Swarm.class);
        if (swarm.isActive()) {
            if (swarm.isHost())
                swarm.host.sendMessage(context.getInput());
            else if (swarm.isWorker())
                swarm.worker.target = context.getArgument("block", BlockStateArgument.class).getBlockState().getBlock();
        } else
            throw SWARM_NOT_ACTIVE.create();
        return SINGLE_SUCCESS;
    })));
    builder.then(literal("toggle").then(argument("module", ModuleArgumentType.module()).executes(context -> {
        Swarm swarm = Modules.get().get(Swarm.class);
        if (swarm.isActive()) {
            if (swarm.isHost())
                swarm.host.sendMessage(context.getInput());
            else if (swarm.isWorker()) {
                Module module = ModuleArgumentType.getModule(context, "module");
                module.toggle();
            }
        } else
            throw SWARM_NOT_ACTIVE.create();
        return SINGLE_SUCCESS;
    }).then(literal("on").executes(context -> {
        Swarm swarm = Modules.get().get(Swarm.class);
        if (swarm.isActive()) {
            if (swarm.isHost())
                swarm.host.sendMessage(context.getInput());
            else if (swarm.isWorker()) {
                Module m = ModuleArgumentType.getModule(context, "module");
                if (!m.isActive())
                    m.toggle();
            }
        } else
            throw SWARM_NOT_ACTIVE.create();
        return SINGLE_SUCCESS;
    })).then(literal("off").executes(context -> {
        Swarm swarm = Modules.get().get(Swarm.class);
        if (swarm.isActive()) {
            if (swarm.isHost())
                swarm.host.sendMessage(context.getInput());
            else if (swarm.isWorker()) {
                Module m = ModuleArgumentType.getModule(context, "module");
                if (m.isActive())
                    m.toggle();
            }
        } else
            throw SWARM_NOT_ACTIVE.create();
        return SINGLE_SUCCESS;
    }))));
    builder.then(literal("scatter").executes(context -> {
        Swarm swarm = Modules.get().get(Swarm.class);
        if (swarm.isActive()) {
            if (swarm.isHost())
                swarm.host.sendMessage(context.getInput());
            else if (swarm.isWorker())
                scatter(100);
        } else
            throw SWARM_NOT_ACTIVE.create();
        return SINGLE_SUCCESS;
    }).then(argument("radius", IntegerArgumentType.integer()).executes(context -> {
        Swarm swarm = Modules.get().get(Swarm.class);
        if (swarm.isActive()) {
            if (swarm.isHost())
                swarm.host.sendMessage(context.getInput());
            else if (swarm.isWorker())
                scatter(IntegerArgumentType.getInteger(context, "radius"));
        } else
            throw SWARM_NOT_ACTIVE.create();
        return SINGLE_SUCCESS;
    })));
    builder.then(literal("stop").executes(context -> {
        Swarm swarm = Modules.get().get(Swarm.class);
        if (swarm.isActive()) {
            if (swarm.isHost())
                swarm.host.sendMessage(context.getInput());
            else if (swarm.isWorker())
                BaritoneAPI.getProvider().getPrimaryBaritone().getPathingBehavior().cancelEverything();
        } else
            throw SWARM_NOT_ACTIVE.create();
        return SINGLE_SUCCESS;
    }));
    builder.then(literal("exec").then(argument("command", StringArgumentType.greedyString()).executes(context -> {
        Swarm swarm = Modules.get().get(Swarm.class);
        if (swarm.isActive()) {
            if (swarm.isHost())
                swarm.host.sendMessage(context.getInput());
            else if (swarm.isWorker())
                mc.player.sendChatMessage(StringArgumentType.getString(context, "command"));
        } else
            throw SWARM_NOT_ACTIVE.create();
        return SINGLE_SUCCESS;
    })));
}
Also used : LiteralText(net.minecraft.text.LiteralText) InfinityMiner(mathax.client.systems.modules.world.InfinityMiner) Random(java.util.Random) PlayerArgumentType(mathax.client.systems.commands.arguments.PlayerArgumentType) SimpleCommandExceptionType(com.mojang.brigadier.exceptions.SimpleCommandExceptionType) SINGLE_SUCCESS(com.mojang.brigadier.Command.SINGLE_SUCCESS) BoolArgumentType(com.mojang.brigadier.arguments.BoolArgumentType) StringArgumentType(com.mojang.brigadier.arguments.StringArgumentType) GoalXZ(baritone.api.pathing.goals.GoalXZ) Command(mathax.client.systems.commands.Command) Module(mathax.client.systems.modules.Module) BlockStateArgument(net.minecraft.command.argument.BlockStateArgument) BaritoneAPI(baritone.api.BaritoneAPI) Swarm(mathax.client.systems.modules.client.swarm.Swarm) SwarmWorker(mathax.client.systems.modules.client.swarm.SwarmWorker) PlayerEntity(net.minecraft.entity.player.PlayerEntity) ChatUtils(mathax.client.utils.misc.ChatUtils) LiteralArgumentBuilder(com.mojang.brigadier.builder.LiteralArgumentBuilder) ModuleArgumentType(mathax.client.systems.commands.arguments.ModuleArgumentType) CommandSource(net.minecraft.command.CommandSource) BlockStateArgumentType(net.minecraft.command.argument.BlockStateArgumentType) List(java.util.List) Modules(mathax.client.systems.modules.Modules) SwarmConnection(mathax.client.systems.modules.client.swarm.SwarmConnection) IntegerArgumentType(com.mojang.brigadier.arguments.IntegerArgumentType) Swarm(mathax.client.systems.modules.client.swarm.Swarm) GoalXZ(baritone.api.pathing.goals.GoalXZ) BlockStateArgument(net.minecraft.command.argument.BlockStateArgument) SwarmConnection(mathax.client.systems.modules.client.swarm.SwarmConnection) InfinityMiner(mathax.client.systems.modules.world.InfinityMiner) SwarmWorker(mathax.client.systems.modules.client.swarm.SwarmWorker) Module(mathax.client.systems.modules.Module) PlayerEntity(net.minecraft.entity.player.PlayerEntity)

Aggregations

SINGLE_SUCCESS (com.mojang.brigadier.Command.SINGLE_SUCCESS)22 LiteralArgumentBuilder (com.mojang.brigadier.builder.LiteralArgumentBuilder)22 CommandSource (net.minecraft.command.CommandSource)22 LiteralText (net.minecraft.text.LiteralText)15 Command (meteordevelopment.meteorclient.systems.commands.Command)11 Command (mathax.client.systems.commands.Command)10 List (java.util.List)9 ItemStack (net.minecraft.item.ItemStack)8 IntegerArgumentType (com.mojang.brigadier.arguments.IntegerArgumentType)7 SimpleCommandExceptionType (com.mojang.brigadier.exceptions.SimpleCommandExceptionType)7 CommandContext (com.mojang.brigadier.context.CommandContext)6 CommandSyntaxException (com.mojang.brigadier.exceptions.CommandSyntaxException)6 ChatUtils (meteordevelopment.meteorclient.utils.player.ChatUtils)6 BaseText (net.minecraft.text.BaseText)6 BaritoneAPI (baritone.api.BaritoneAPI)5 Modules (mathax.client.systems.modules.Modules)5 Items (net.minecraft.item.Items)5 Formatting (net.minecraft.util.Formatting)5 StringArgumentType (com.mojang.brigadier.arguments.StringArgumentType)4 Collectors (java.util.stream.Collectors)4