Search in sources :

Example 6 with BaseText

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

the class ModulesCommand method build.

@Override
public void build(LiteralArgumentBuilder<CommandSource> builder) {
    builder.executes(context -> {
        ChatUtils.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.name, categoryMessage);
        });
        return SINGLE_SUCCESS;
    });
}
Also used : BaseText(net.minecraft.text.BaseText) LiteralText(net.minecraft.text.LiteralText)

Example 7 with BaseText

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

the class ModulesCommand method getModuleText.

private BaseText getModuleText(Module module) {
    // Hover tooltip
    BaseText tooltip = new LiteralText("");
    tooltip.append(new LiteralText(module.title).formatted(Formatting.BLUE, Formatting.BOLD)).append("\n");
    tooltip.append(new LiteralText(module.name).formatted(Formatting.GRAY)).append("\n\n");
    tooltip.append(new LiteralText(module.description).formatted(Formatting.WHITE));
    BaseText finalModule = new LiteralText(module.title);
    if (!module.equals(Modules.get().getGroup(module.category).get(Modules.get().getGroup(module.category).size() - 1)))
        finalModule.append(new LiteralText(", ").formatted(Formatting.GRAY));
    finalModule.setStyle(finalModule.getStyle().withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, tooltip)));
    return finalModule;
}
Also used : BaseText(net.minecraft.text.BaseText) HoverEvent(net.minecraft.text.HoverEvent) LiteralText(net.minecraft.text.LiteralText)

Example 8 with BaseText

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

the class CommandsCommand method build.

@Override
public void build(LiteralArgumentBuilder<CommandSource> builder) {
    builder.executes(context -> {
        ChatUtils.info("--- Commands ((highlight)%d(default)) ---", Commands.get().getCount());
        BaseText commands = new LiteralText("");
        Commands.get().getAll().forEach(command -> commands.append(getCommandText(command)));
        ChatUtils.sendMsg(commands);
        return SINGLE_SUCCESS;
    });
}
Also used : BaseText(net.minecraft.text.BaseText) LiteralText(net.minecraft.text.LiteralText)

Example 9 with BaseText

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

the class ChatEncryption method onMessageReceive.

@EventHandler
private void onMessageReceive(ReceiveMessageEvent event) {
    ((ChatHudAccessor) mc.inGameHud.getChatHud()).getVisibleMessages().removeIf((message) -> message.getId() == event.id && event.id != 0);
    ((ChatHudAccessor) mc.inGameHud.getChatHud()).getMessages().removeIf((message) -> message.getId() == event.id && event.id != 0);
    Text message = event.getMessage();
    if (message.getString().endsWith(suffix.get()) && !suffix.get().isEmpty()) {
        String[] msg = message.getString().split(encryptedPrefix);
        try {
            String chat = decrypt(msg[1], customKey.get() ? groupKey.get() : password);
            BaseText prefixOpenBorder = new LiteralText("[");
            prefixOpenBorder.setStyle(prefixOpenBorder.getStyle().withFormatting(Formatting.GRAY));
            BaseText prefix = new LiteralText("Encrypted Chat");
            prefix.setStyle(prefix.getStyle().withColor(MatHax.INSTANCE.MATHAX_COLOR.getPacked()));
            BaseText prefixCloseBorder = new LiteralText("] ");
            prefixCloseBorder.setStyle(prefixCloseBorder.getStyle().withFormatting(Formatting.GRAY));
            BaseText chatText = new LiteralText(msg[0] + chat);
            chatText.setStyle(chatText.getStyle().withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new LiteralText(msg[1]))));
            BaseText chatMessage = new LiteralText("");
            if (Modules.get().get(BetterChat.class).displayPlayerHeads())
                chatMessage.append("  ");
            chatMessage.append(prefixOpenBorder);
            chatMessage.append(prefix);
            chatMessage.append(prefixCloseBorder);
            chatMessage.append(chatText);
            message = chatMessage;
        } catch (Exception exception) {
            message = event.getMessage();
        }
    }
    event.setMessage(message);
}
Also used : BaseText(net.minecraft.text.BaseText) HoverEvent(net.minecraft.text.HoverEvent) LiteralText(net.minecraft.text.LiteralText) BaseText(net.minecraft.text.BaseText) Text(net.minecraft.text.Text) LiteralText(net.minecraft.text.LiteralText) EventHandler(mathax.client.eventbus.EventHandler)

Example 10 with BaseText

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

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 + command.getName());
    if (command.getAliases().size() > 0) {
        aliases.append(", ");
        for (String alias : command.getAliases()) {
            if (alias.isEmpty())
                continue;
            aliases.append(Config.get().prefix + 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 + 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)

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