Search in sources :

Example 71 with LiteralText

use of net.minecraft.text.LiteralText 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 72 with LiteralText

use of net.minecraft.text.LiteralText 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 73 with LiteralText

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

the class AutoLog method onTick.

@EventHandler
private void onTick(TickEvent.Post event) {
    if (mc.player.getHealth() <= 0) {
        this.toggle();
        return;
    }
    if (mc.player.getHealth() <= health.get()) {
        mc.player.networkHandler.onDisconnect(new DisconnectS2CPacket(new LiteralText("[AutoLog] Health was lower than " + health.get() + ".")));
        if (smartToggle.get()) {
            this.toggle();
            enableHealthListener();
        }
    }
    if (smart.get() && mc.player.getHealth() + mc.player.getAbsorptionAmount() - PlayerUtils.possibleHealthReductions() < health.get()) {
        mc.player.networkHandler.onDisconnect(new DisconnectS2CPacket(new LiteralText("[AutoLog] Health was going to be lower than " + health.get() + ".")));
        if (toggleOff.get())
            this.toggle();
    }
    for (Entity entity : mc.world.getEntities()) {
        if (entity instanceof PlayerEntity && entity.getUuid() != mc.player.getUuid()) {
            if (onlyTrusted.get() && entity != mc.player && !Friends.get().isFriend((PlayerEntity) entity)) {
                mc.player.networkHandler.onDisconnect(new DisconnectS2CPacket(new LiteralText("[AutoLog] A non-trusted player appeared in your render distance.")));
                if (toggleOff.get())
                    this.toggle();
                break;
            }
            if (mc.player.distanceTo(entity) < 8 && instantDeath.get() && DamageUtils.getSwordDamage((PlayerEntity) entity, true) > mc.player.getHealth() + mc.player.getAbsorptionAmount()) {
                mc.player.networkHandler.onDisconnect(new DisconnectS2CPacket(new LiteralText("[AutoLog] Anti-32k measures.")));
                if (toggleOff.get())
                    this.toggle();
                break;
            }
        }
        if (entity instanceof EndCrystalEntity && mc.player.distanceTo(entity) < range.get() && crystalLog.get()) {
            mc.player.networkHandler.onDisconnect(new DisconnectS2CPacket(new LiteralText("[AutoLog] End Crystal appeared within specified range.")));
            if (toggleOff.get())
                this.toggle();
        }
    }
}
Also used : Entity(net.minecraft.entity.Entity) EndCrystalEntity(net.minecraft.entity.decoration.EndCrystalEntity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) EndCrystalEntity(net.minecraft.entity.decoration.EndCrystalEntity) DisconnectS2CPacket(net.minecraft.network.packet.s2c.play.DisconnectS2CPacket) LiteralText(net.minecraft.text.LiteralText) PlayerEntity(net.minecraft.entity.player.PlayerEntity) EventHandler(meteordevelopment.orbit.EventHandler)

Example 74 with LiteralText

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

the class BetterTab method getPlayerName.

public Text getPlayerName(PlayerListEntry playerListEntry) {
    Text name;
    Color color = null;
    name = playerListEntry.getDisplayName();
    if (name == null)
        name = new LiteralText(playerListEntry.getProfile().getName());
    if (playerListEntry.getProfile().getId().toString().equals(mc.player.getGameProfile().getId().toString()) && self.get()) {
        color = selfColor.get();
    } else if (friends.get() && Friends.get().get(playerListEntry.getProfile().getName()) != null) {
        Friend friend = Friends.get().get(playerListEntry.getProfile().getName());
        if (friend != null)
            color = Friends.get().color;
    }
    if (color != null) {
        String nameString = name.getString();
        for (Formatting format : Formatting.values()) {
            if (format.isColor())
                nameString = nameString.replace(format.toString(), "");
        }
        name = new LiteralText(nameString).setStyle(name.getStyle().withColor(new TextColor(color.getPacked())));
    }
    return name;
}
Also used : Friend(meteordevelopment.meteorclient.systems.friends.Friend) Color(meteordevelopment.meteorclient.utils.render.color.Color) SettingColor(meteordevelopment.meteorclient.utils.render.color.SettingColor) TextColor(net.minecraft.text.TextColor) Formatting(net.minecraft.util.Formatting) LiteralText(net.minecraft.text.LiteralText) Text(net.minecraft.text.Text) TextColor(net.minecraft.text.TextColor) LiteralText(net.minecraft.text.LiteralText)

Example 75 with LiteralText

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

the class BookBot method onTick.

@EventHandler
private void onTick(TickEvent.Post event) {
    FindItemResult writableBook = InvUtils.find(Items.WRITABLE_BOOK);
    // Check if there is a book to write
    if (!writableBook.found()) {
        toggle();
        return;
    }
    // Move the book into hand
    if (!writableBook.isMainHand()) {
        InvUtils.move().from(writableBook.slot()).toHotbar(mc.player.getInventory().selectedSlot);
        return;
    }
    // If somehow it failed, just dont do anything until it tries again
    FindItemResult finalBook = InvUtils.findInHotbar(Items.WRITABLE_BOOK);
    if (!finalBook.isMainHand())
        return;
    // Check delay
    if (delayTimer > 0) {
        delayTimer--;
        return;
    }
    // Reset delay
    delayTimer = delay.get();
    if (mode.get() == Mode.Random) {
        int origin = onlyAscii.get() ? 0x21 : 0x0800;
        int bound = onlyAscii.get() ? 0x7E : 0x10FFFF;
        writeBook(// Generate a random load of ints to use as random characters
        random.ints(origin, bound).filter(i -> !Character.isWhitespace(i) && i != '\r' && i != '\n').iterator());
    } else if (mode.get() == Mode.File) {
        // Ignore if somehow the file got deleted
        if ((file == null || !file.exists()) && mode.get() == Mode.File) {
            info("No file selected, please select a file in the GUI.");
            toggle();
            return;
        }
        // Handle the file being empty
        if (file.length() == 0) {
            MutableText message = new LiteralText("");
            message.append(new LiteralText("The bookbot file is empty! ").formatted(Formatting.RED));
            message.append(new LiteralText("Click here to edit it.").setStyle(Style.EMPTY.withFormatting(Formatting.UNDERLINE, Formatting.RED).withClickEvent(new ClickEvent(ClickEvent.Action.OPEN_FILE, file.getAbsolutePath()))));
            info(message);
            toggle();
            return;
        }
        // Read each line of the file and construct a string with the needed line breaks
        try (BufferedReader reader = new BufferedReader(new FileReader(file))) {
            StringBuilder file = new StringBuilder();
            String line;
            while ((line = reader.readLine()) != null) {
                file.append(line).append('\n');
            }
            reader.close();
            // Write the file string to a book
            writeBook(file.toString().chars().iterator());
        } catch (IOException ignored) {
            error("Failed to read the file.");
        }
    }
}
Also used : MutableText(net.minecraft.text.MutableText) ClickEvent(net.minecraft.text.ClickEvent) FindItemResult(meteordevelopment.meteorclient.utils.player.FindItemResult) BufferedReader(java.io.BufferedReader) FileReader(java.io.FileReader) NbtString(net.minecraft.nbt.NbtString) IOException(java.io.IOException) LiteralText(net.minecraft.text.LiteralText) EventHandler(meteordevelopment.orbit.EventHandler)

Aggregations

LiteralText (net.minecraft.text.LiteralText)353 Text (net.minecraft.text.Text)83 ServerPlayerEntity (net.minecraft.server.network.ServerPlayerEntity)75 ServerCommandSource (net.minecraft.server.command.ServerCommandSource)50 TranslatableText (net.minecraft.text.TranslatableText)46 ItemStack (net.minecraft.item.ItemStack)42 MutableText (net.minecraft.text.MutableText)42 Screen (net.minecraft.client.gui.screen.Screen)39 ButtonWidget (net.minecraft.client.gui.widget.ButtonWidget)39 MatrixStack (net.minecraft.client.util.math.MatrixStack)33 Formatting (net.minecraft.util.Formatting)32 NbtCompound (net.minecraft.nbt.NbtCompound)30 HoverEvent (net.minecraft.text.HoverEvent)29 BaseText (net.minecraft.text.BaseText)26 Inject (org.spongepowered.asm.mixin.injection.Inject)25 ClickEvent (net.minecraft.text.ClickEvent)24 ArrayList (java.util.ArrayList)22 List (java.util.List)22 Identifier (net.minecraft.util.Identifier)22 IOException (java.io.IOException)21