Search in sources :

Example 16 with BaseText

use of net.minecraft.text.BaseText 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 17 with BaseText

use of net.minecraft.text.BaseText in project meteor-client by MeteorDevelopment.

the class CommandsCommand method getCommandText.

private BaseText getCommandText(Command command) {
    // Hover tooltip
    BaseText tooltip = new LiteralText("");
    tooltip.append(new LiteralText(Utils.nameToTitle(command.getName())).formatted(Formatting.BLUE, Formatting.BOLD)).append("\n");
    BaseText aliases = new LiteralText(Config.get().prefix.get() + command.getName());
    if (command.getAliases().size() > 0) {
        aliases.append(", ");
        for (String alias : command.getAliases()) {
            if (alias.isEmpty())
                continue;
            aliases.append(Config.get().prefix.get() + alias);
            if (!alias.equals(command.getAliases().get(command.getAliases().size() - 1)))
                aliases.append(", ");
        }
    }
    tooltip.append(aliases.formatted(Formatting.GRAY)).append("\n\n");
    tooltip.append(new LiteralText(command.getDescription()).formatted(Formatting.WHITE));
    // Text
    BaseText text = new LiteralText(Utils.nameToTitle(command.getName()));
    if (command != Commands.get().getAll().get(Commands.get().getAll().size() - 1))
        text.append(new LiteralText(", ").formatted(Formatting.GRAY));
    text.setStyle(text.getStyle().withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, tooltip)).withClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, Config.get().prefix.get() + command.getName())));
    return text;
}
Also used : BaseText(net.minecraft.text.BaseText) HoverEvent(net.minecraft.text.HoverEvent) ClickEvent(net.minecraft.text.ClickEvent) LiteralText(net.minecraft.text.LiteralText)

Example 18 with BaseText

use of net.minecraft.text.BaseText in project meteor-rejects by AntiCope.

the class Seeds method sendInvalidVersionWarning.

private static void sendInvalidVersionWarning(String seed, String targetVer) {
    BaseText msg = new LiteralText(String.format("Couldn't resolve minecraft version \"%s\". Using %s instead. If you wish to change the version run: ", targetVer, MCVersion.latest().name));
    String cmd = String.format("%sseed %s ", Config.get().prefix, seed);
    BaseText cmdText = new LiteralText(cmd + "<version>");
    cmdText.setStyle(cmdText.getStyle().withUnderline(true).withClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, cmd)).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new LiteralText("run command"))));
    msg.append(cmdText);
    msg.setStyle(msg.getStyle().withColor(Formatting.YELLOW));
    ChatUtils.sendMsg("Seed", msg);
}
Also used : BaseText(net.minecraft.text.BaseText) HoverEvent(net.minecraft.text.HoverEvent) ClickEvent(net.minecraft.text.ClickEvent) LiteralText(net.minecraft.text.LiteralText)

Example 19 with BaseText

use of net.minecraft.text.BaseText in project Client by MatHax.

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;
            MatHax.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) PacketEvent(mathax.client.events.packets.PacketEvent) NbtList(net.minecraft.nbt.NbtList) EventHandler(mathax.client.eventbus.EventHandler) 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) Block(net.minecraft.block.Block) SoundEvents(net.minecraft.sound.SoundEvents) Vec3d(net.minecraft.util.math.Vec3d) Command(mathax.client.systems.commands.Command) EntitySpawnS2CPacket(net.minecraft.network.packet.s2c.play.EntitySpawnS2CPacket) BaritoneAPI(baritone.api.BaritoneAPI) MatHax(mathax.client.MatHax) ChatUtils(mathax.client.utils.misc.ChatUtils) BlockPos(net.minecraft.util.math.BlockPos) Items(net.minecraft.item.Items) LiteralArgumentBuilder(com.mojang.brigadier.builder.LiteralArgumentBuilder) Blocks(net.minecraft.block.Blocks) CommandSource(net.minecraft.command.CommandSource) InvUtils(mathax.client.utils.player.InvUtils) NbtCompound(net.minecraft.nbt.NbtCompound) List(java.util.List) FindItemResult(mathax.client.utils.player.FindItemResult) BaseText(net.minecraft.text.BaseText) NbtCompound(net.minecraft.nbt.NbtCompound) FindItemResult(mathax.client.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 20 with BaseText

use of net.minecraft.text.BaseText in project Client by MatHax.

the class ModulesCommand method build.

@Override
public void build(LiteralArgumentBuilder<CommandSource> builder) {
    builder.executes(context -> {
        info("--- Modules ((highlight)%d(default)) ---", Modules.get().getCount());
        Modules.loopCategories().forEach(category -> {
            BaseText categoryMessage = new LiteralText("");
            Modules.get().getGroup(category).forEach(module -> categoryMessage.append(getModuleText(module)));
            ChatUtils.sendMsg(category.title, categoryMessage);
        });
        return SINGLE_SUCCESS;
    });
}
Also used : BaseText(net.minecraft.text.BaseText) LiteralText(net.minecraft.text.LiteralText)

Aggregations

BaseText (net.minecraft.text.BaseText)25 LiteralText (net.minecraft.text.LiteralText)24 HoverEvent (net.minecraft.text.HoverEvent)9 LiteralArgumentBuilder (com.mojang.brigadier.builder.LiteralArgumentBuilder)7 CommandSource (net.minecraft.command.CommandSource)7 SINGLE_SUCCESS (com.mojang.brigadier.Command.SINGLE_SUCCESS)6 ItemStack (net.minecraft.item.ItemStack)6 NbtCompound (net.minecraft.nbt.NbtCompound)6 ClickEvent (net.minecraft.text.ClickEvent)6 Vec3d (net.minecraft.util.math.Vec3d)6 Command (meteordevelopment.meteorclient.systems.commands.Command)4 BaritoneAPI (baritone.api.BaritoneAPI)3 IntegerArgumentType (com.mojang.brigadier.arguments.IntegerArgumentType)3 NbtPathArgumentType (net.minecraft.command.argument.NbtPathArgumentType)3 EntityType (net.minecraft.entity.EntityType)3 Items (net.minecraft.item.Items)3 CreativeInventoryActionC2SPacket (net.minecraft.network.packet.c2s.play.CreativeInventoryActionC2SPacket)3 EntitySpawnS2CPacket (net.minecraft.network.packet.s2c.play.EntitySpawnS2CPacket)3 PlaySoundS2CPacket (net.minecraft.network.packet.s2c.play.PlaySoundS2CPacket)3 SoundEvents (net.minecraft.sound.SoundEvents)3