Search in sources :

Example 11 with SINGLE_SUCCESS

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

the class NbtCommand method build.

@Override
public void build(LiteralArgumentBuilder<CommandSource> builder) {
    builder.then(literal("add").then(argument("nbt_data", CompoundNbtTagArgumentType.nbtTag()).executes(s -> {
        ItemStack stack = mc.player.getInventory().getMainHandStack();
        if (validBasic(stack)) {
            NbtCompound tag = CompoundNbtTagArgumentType.getTag(s, "nbt_data");
            NbtCompound source = stack.getOrCreateNbt();
            if (tag != null) {
                source.copyFrom(tag);
                setStack(stack);
            } else {
                error("Some of the NBT data could not be found, try using: " + Config.get().prefix.get() + "nbt set {nbt}");
            }
        }
        return SINGLE_SUCCESS;
    })));
    builder.then(literal("set").then(argument("nbt_data", CompoundNbtTagArgumentType.nbtTag()).executes(s -> {
        ItemStack stack = mc.player.getInventory().getMainHandStack();
        if (validBasic(stack)) {
            NbtCompound tag = s.getArgument("nbt_data", NbtCompound.class);
            stack.setNbt(tag);
            setStack(stack);
        }
        return SINGLE_SUCCESS;
    })));
    builder.then(literal("remove").then(argument("nbt_path", NbtPathArgumentType.nbtPath()).executes(s -> {
        ItemStack stack = mc.player.getInventory().getMainHandStack();
        if (validBasic(stack)) {
            NbtPathArgumentType.NbtPath path = s.getArgument("nbt_path", NbtPathArgumentType.NbtPath.class);
            path.remove(stack.getNbt());
        }
        return SINGLE_SUCCESS;
    })));
    builder.then(literal("get").executes(s -> {
        ItemStack stack = mc.player.getInventory().getMainHandStack();
        if (stack == null) {
            error("You must hold an item in your main hand.");
        } else {
            NbtCompound tag = stack.getNbt();
            String nbt = tag == null ? "{}" : tag.asString();
            BaseText copyButton = new LiteralText("NBT");
            copyButton.setStyle(copyButton.getStyle().withFormatting(Formatting.UNDERLINE).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, this.toString("copy"))).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new LiteralText("Copy the NBT data to your clipboard."))));
            BaseText text = new LiteralText("");
            text.append(copyButton);
            text.append(new LiteralText(": " + nbt));
            info(text);
        }
        return SINGLE_SUCCESS;
    }));
    builder.then(literal("copy").executes(s -> {
        ItemStack stack = mc.player.getInventory().getMainHandStack();
        if (stack == null) {
            error("You must hold an item in your main hand.");
        } else {
            NbtCompound tag = stack.getOrCreateNbt();
            mc.keyboard.setClipboard(tag.toString());
            BaseText nbt = new LiteralText("NBT");
            nbt.setStyle(nbt.getStyle().withFormatting(Formatting.UNDERLINE).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new LiteralText(tag.toString()))));
            BaseText text = new LiteralText("");
            text.append(nbt);
            text.append(new LiteralText(" data copied!"));
            info(text);
        }
        return SINGLE_SUCCESS;
    }));
    builder.then(literal("count").then(argument("count", IntegerArgumentType.integer(-127, 127)).executes(context -> {
        ItemStack stack = mc.player.getInventory().getMainHandStack();
        if (validBasic(stack)) {
            int count = IntegerArgumentType.getInteger(context, "count");
            stack.setCount(count);
            setStack(stack);
            info("Set mainhand stack count to %s.", count);
        }
        return SINGLE_SUCCESS;
    })));
}
Also used : LiteralText(net.minecraft.text.LiteralText) CompoundNbtTagArgumentType(meteordevelopment.meteorclient.systems.commands.arguments.CompoundNbtTagArgumentType) CreativeInventoryActionC2SPacket(net.minecraft.network.packet.c2s.play.CreativeInventoryActionC2SPacket) Config(meteordevelopment.meteorclient.systems.config.Config) HoverEvent(net.minecraft.text.HoverEvent) LiteralArgumentBuilder(com.mojang.brigadier.builder.LiteralArgumentBuilder) CommandSource(net.minecraft.command.CommandSource) SINGLE_SUCCESS(com.mojang.brigadier.Command.SINGLE_SUCCESS) ItemStack(net.minecraft.item.ItemStack) NbtCompound(net.minecraft.nbt.NbtCompound) BaseText(net.minecraft.text.BaseText) Formatting(net.minecraft.util.Formatting) NbtPathArgumentType(net.minecraft.command.argument.NbtPathArgumentType) Command(meteordevelopment.meteorclient.systems.commands.Command) ClickEvent(net.minecraft.text.ClickEvent) IntegerArgumentType(com.mojang.brigadier.arguments.IntegerArgumentType) BaseText(net.minecraft.text.BaseText) HoverEvent(net.minecraft.text.HoverEvent) NbtCompound(net.minecraft.nbt.NbtCompound) NbtPathArgumentType(net.minecraft.command.argument.NbtPathArgumentType) ClickEvent(net.minecraft.text.ClickEvent) ItemStack(net.minecraft.item.ItemStack) LiteralText(net.minecraft.text.LiteralText)

Example 12 with SINGLE_SUCCESS

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

the class ResetCommand method build.

@Override
public void build(LiteralArgumentBuilder<CommandSource> builder) {
    builder.then(literal("settings").then(argument("module", ModuleArgumentType.module()).executes(context -> {
        Module module = context.getArgument("module", Module.class);
        module.settings.forEach(group -> group.forEach(Setting::reset));
        module.info("Reset all settings.");
        return SINGLE_SUCCESS;
    })).then(literal("all").executes(context -> {
        Modules.get().getAll().forEach(module -> module.settings.forEach(group -> group.forEach(Setting::reset)));
        ChatUtils.info("Modules", "Reset all module settings");
        return SINGLE_SUCCESS;
    }))).then(literal("gui").executes(context -> {
        GuiThemes.get().clearWindowConfigs();
        ChatUtils.info("Reset GUI positioning.");
        return SINGLE_SUCCESS;
    })).then(literal("bind").then(argument("module", ModuleArgumentType.module()).executes(context -> {
        Module module = context.getArgument("module", Module.class);
        module.keybind.set(true, -1);
        module.info("Reset bind.");
        return SINGLE_SUCCESS;
    })).then(literal("all").executes(context -> {
        Modules.get().getAll().forEach(module -> module.keybind.set(true, -1));
        ChatUtils.info("Modules", "Reset all binds.");
        return SINGLE_SUCCESS;
    }))).then(literal("hud").executes(context -> {
        Systems.get(HUD.class).reset.run();
        ChatUtils.info("HUD", "Reset all elements.");
        return SINGLE_SUCCESS;
    }));
}
Also used : Systems(meteordevelopment.meteorclient.systems.Systems) HUD(meteordevelopment.meteorclient.systems.hud.HUD) CommandSource(net.minecraft.command.CommandSource) SINGLE_SUCCESS(com.mojang.brigadier.Command.SINGLE_SUCCESS) Setting(meteordevelopment.meteorclient.settings.Setting) Command(meteordevelopment.meteorclient.systems.commands.Command) Module(meteordevelopment.meteorclient.systems.modules.Module) Modules(meteordevelopment.meteorclient.systems.modules.Modules) ChatUtils(meteordevelopment.meteorclient.utils.player.ChatUtils) GuiThemes(meteordevelopment.meteorclient.gui.GuiThemes) LiteralArgumentBuilder(com.mojang.brigadier.builder.LiteralArgumentBuilder) ModuleArgumentType(meteordevelopment.meteorclient.systems.commands.arguments.ModuleArgumentType) HUD(meteordevelopment.meteorclient.systems.hud.HUD) Module(meteordevelopment.meteorclient.systems.modules.Module)

Example 13 with SINGLE_SUCCESS

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

the class LocateCommand method build.

@Override
public void build(LiteralArgumentBuilder<CommandSource> builder) {
    builder.then(literal("buried_treasure").executes(s -> {
        ItemStack stack = mc.player.getInventory().getMainHandStack();
        if (stack.getItem() != Items.FILLED_MAP) {
            error("You need to hold a treasure map first");
            return SINGLE_SUCCESS;
        }
        NbtCompound tag = stack.getNbt();
        NbtList nbt1 = (NbtList) tag.get("Decorations");
        if (nbt1 == null) {
            error("Couldn't locate the cross. Are you holding a (highlight)treasure map(default)?");
            return SINGLE_SUCCESS;
        }
        NbtCompound iconNBT = nbt1.getCompound(0);
        if (iconNBT == null) {
            error("Couldn't locate the cross. Are you holding a (highlight)treasure map(default)?");
            return SINGLE_SUCCESS;
        }
        Vec3d coords = new Vec3d(iconNBT.getDouble("x"), iconNBT.getDouble("y"), iconNBT.getDouble("z"));
        BaseText text = new LiteralText("Buried Treasure located at ");
        text.append(ChatUtils.formatCoords(coords));
        text.append(".");
        info(text);
        return SINGLE_SUCCESS;
    }));
    builder.then(literal("lodestone").executes(s -> {
        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(literal("mansion").executes(s -> {
        ItemStack stack = mc.player.getInventory().getMainHandStack();
        if (stack.getItem() != Items.FILLED_MAP) {
            error("You need to hold a woodland explorer map first");
            return SINGLE_SUCCESS;
        }
        NbtCompound tag = stack.getNbt();
        NbtList nbt1 = (NbtList) tag.get("Decorations");
        if (nbt1 == null) {
            error("Couldn't locate the mansion. Are you holding a (highlight)woodland explorer map(default)?");
            return SINGLE_SUCCESS;
        }
        NbtCompound iconNBT = nbt1.getCompound(0);
        if (iconNBT == null) {
            error("Couldn't locate the mansion. Are you holding a (highlight)woodland explorer map(default)?");
            return SINGLE_SUCCESS;
        }
        Vec3d coords = new Vec3d(iconNBT.getDouble("x"), iconNBT.getDouble("y"), iconNBT.getDouble("z"));
        BaseText text = new LiteralText("Mansion located at ");
        text.append(ChatUtils.formatCoords(coords));
        text.append(".");
        info(text);
        return SINGLE_SUCCESS;
    }));
    builder.then(literal("stronghold").executes(s -> {
        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");
        } else {
            Vec3d coords = findByBlockList(strongholdBlocks);
            if (coords == null) {
                error("No stronghold found nearby. You can use (highlight)Ender Eyes(default) for more success.");
                return SINGLE_SUCCESS;
            }
            BaseText text = new LiteralText("Stronghold located at ");
            text.append(ChatUtils.formatCoords(coords));
            text.append(".");
            info(text);
        }
        return SINGLE_SUCCESS;
    }));
    builder.then(literal("nether_fortress").executes(s -> {
        Vec3d coords = findByBlockList(netherFortressBlocks);
        if (coords == null) {
            error("No nether fortress found.");
            return SINGLE_SUCCESS;
        }
        BaseText text = new LiteralText("Fortress located at ");
        text.append(ChatUtils.formatCoords(coords));
        text.append(".");
        info(text);
        return SINGLE_SUCCESS;
    }));
    builder.then(literal("monument").executes(s -> {
        ItemStack stack = mc.player.getInventory().getMainHandStack();
        if (stack.getItem() == Items.FILLED_MAP) {
            NbtCompound tag = stack.getNbt();
            if (tag != null) {
                NbtList nbt1 = (NbtList) tag.get("Decorations");
                if (nbt1 != null) {
                    NbtCompound iconNBT = nbt1.getCompound(0);
                    if (iconNBT != null) {
                        Vec3d coords = new Vec3d(iconNBT.getDouble("x"), iconNBT.getDouble("y"), iconNBT.getDouble("z"));
                        BaseText text = new LiteralText("Monument located at ");
                        text.append(ChatUtils.formatCoords(coords));
                        text.append(".");
                        info(text);
                        return SINGLE_SUCCESS;
                    }
                }
            }
        }
        Vec3d coords = findByBlockList(monumentBlocks);
        if (coords == null) {
            error("No monument found. You can try using a (highlight)Ocean explorer map(default) for more success.");
            return SINGLE_SUCCESS;
        }
        BaseText text = new LiteralText("Monument located at ");
        text.append(ChatUtils.formatCoords(coords));
        text.append(".");
        info(text);
        return SINGLE_SUCCESS;
    }));
    builder.then(literal("cancel").executes(s -> {
        cancel();
        return SINGLE_SUCCESS;
    }));
}
Also used : EntityType(net.minecraft.entity.EntityType) LiteralText(net.minecraft.text.LiteralText) Arrays(java.util.Arrays) NbtList(net.minecraft.nbt.NbtList) 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) Block(net.minecraft.block.Block) SoundEvents(net.minecraft.sound.SoundEvents) Vec3d(net.minecraft.util.math.Vec3d) FindItemResult(meteordevelopment.meteorclient.utils.player.FindItemResult) InvUtils(meteordevelopment.meteorclient.utils.player.InvUtils) ChatUtils(meteordevelopment.meteorclient.utils.player.ChatUtils) 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) Blocks(net.minecraft.block.Blocks) CommandSource(net.minecraft.command.CommandSource) NbtCompound(net.minecraft.nbt.NbtCompound) List(java.util.List) MeteorClient(meteordevelopment.meteorclient.MeteorClient) EventHandler(meteordevelopment.orbit.EventHandler) BaseText(net.minecraft.text.BaseText) NbtCompound(net.minecraft.nbt.NbtCompound) FindItemResult(meteordevelopment.meteorclient.utils.player.FindItemResult) NbtList(net.minecraft.nbt.NbtList) ItemStack(net.minecraft.item.ItemStack) Vec3d(net.minecraft.util.math.Vec3d) LiteralText(net.minecraft.text.LiteralText)

Example 14 with SINGLE_SUCCESS

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

the class BindsCommand method build.

@Override
public void build(LiteralArgumentBuilder<CommandSource> builder) {
    builder.executes(context -> {
        // Modules
        List<Module> modules = Modules.get().getAll().stream().filter(module -> module.keybind.isSet()).collect(Collectors.toList());
        ChatUtils.info("--- Bound Modules ((highlight)%d(default)) ---", modules.size());
        for (Module module : modules) {
            HoverEvent hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_TEXT, getTooltip(module));
            MutableText text = new LiteralText(module.title).formatted(Formatting.WHITE);
            text.setStyle(text.getStyle().withHoverEvent(hoverEvent));
            MutableText sep = new LiteralText(" - ");
            sep.setStyle(sep.getStyle().withHoverEvent(hoverEvent));
            text.append(sep.formatted(Formatting.GRAY));
            MutableText key = new LiteralText(module.keybind.toString());
            key.setStyle(key.getStyle().withHoverEvent(hoverEvent));
            text.append(key.formatted(Formatting.GRAY));
            ChatUtils.sendMsg(text);
        }
        return SINGLE_SUCCESS;
    });
}
Also used : LiteralText(net.minecraft.text.LiteralText) HoverEvent(net.minecraft.text.HoverEvent) Collectors(java.util.stream.Collectors) LiteralArgumentBuilder(com.mojang.brigadier.builder.LiteralArgumentBuilder) CommandSource(net.minecraft.command.CommandSource) SINGLE_SUCCESS(com.mojang.brigadier.Command.SINGLE_SUCCESS) Formatting(net.minecraft.util.Formatting) List(java.util.List) Command(meteordevelopment.meteorclient.systems.commands.Command) Module(meteordevelopment.meteorclient.systems.modules.Module) Modules(meteordevelopment.meteorclient.systems.modules.Modules) MutableText(net.minecraft.text.MutableText) ChatUtils(meteordevelopment.meteorclient.utils.player.ChatUtils) Utils(meteordevelopment.meteorclient.utils.Utils) MutableText(net.minecraft.text.MutableText) HoverEvent(net.minecraft.text.HoverEvent) Module(meteordevelopment.meteorclient.systems.modules.Module) LiteralText(net.minecraft.text.LiteralText)

Example 15 with SINGLE_SUCCESS

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

the class ToggleCommand method build.

@Override
public void build(LiteralArgumentBuilder<CommandSource> builder) {
    builder.then(literal("all").then(literal("on").executes(context -> {
        new ArrayList<>(Modules.get().getAll()).forEach(module -> {
            if (!module.isActive())
                module.toggle();
        });
        HUD.get().active = true;
        return SINGLE_SUCCESS;
    })).then(literal("off").executes(context -> {
        new ArrayList<>(Modules.get().getActive()).forEach(Module::toggle);
        HUD.get().active = false;
        return SINGLE_SUCCESS;
    }))).then(argument("module", ModuleArgumentType.module()).executes(context -> {
        Module m = ModuleArgumentType.getModule(context, "module");
        m.toggle();
        return SINGLE_SUCCESS;
    }).then(literal("on").executes(context -> {
        Module m = ModuleArgumentType.getModule(context, "module");
        if (!m.isActive())
            m.toggle();
        return SINGLE_SUCCESS;
    })).then(literal("off").executes(context -> {
        Module m = ModuleArgumentType.getModule(context, "module");
        if (m.isActive())
            m.toggle();
        return SINGLE_SUCCESS;
    })));
}
Also used : HUD(meteordevelopment.meteorclient.systems.hud.HUD) CommandSource(net.minecraft.command.CommandSource) SINGLE_SUCCESS(com.mojang.brigadier.Command.SINGLE_SUCCESS) Command(meteordevelopment.meteorclient.systems.commands.Command) Module(meteordevelopment.meteorclient.systems.modules.Module) Modules(meteordevelopment.meteorclient.systems.modules.Modules) LiteralArgumentBuilder(com.mojang.brigadier.builder.LiteralArgumentBuilder) ModuleArgumentType(meteordevelopment.meteorclient.systems.commands.arguments.ModuleArgumentType) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) Module(meteordevelopment.meteorclient.systems.modules.Module)

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