Search in sources :

Example 76 with LiteralText

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

the class FakeClientPlayer method getPlayerListEntry.

public static PlayerListEntry getPlayerListEntry() {
    if (playerListEntry == null || needsNewEntry) {
        playerListEntry = new PlayerListEntry(PlayerListEntryFactory.create(mc.getSession().getProfile(), 0, GameMode.SURVIVAL, new LiteralText(mc.getSession().getProfile().getName())));
        needsNewEntry = false;
    }
    return playerListEntry;
}
Also used : PlayerListEntry(net.minecraft.client.network.PlayerListEntry) LiteralText(net.minecraft.text.LiteralText)

Example 77 with LiteralText

use of net.minecraft.text.LiteralText in project FZMM-Mod by Zailer43.

the class FzmmItemGroup method addItemFrames.

private static void addItemFrames(List<ItemStack> stacks) {
    ItemStack itemFrame = new ItemStack(Items.ITEM_FRAME);
    ItemStack glowItemFrame = new ItemStack(Items.GLOW_ITEM_FRAME);
    NbtCompound entityTag = new NbtCompound();
    entityTag.putBoolean("Invisible", true);
    itemFrame.setSubNbt(EntityType.ENTITY_TAG_KEY, entityTag);
    glowItemFrame.setSubNbt(EntityType.ENTITY_TAG_KEY, entityTag);
    itemFrame.setCustomName(new LiteralText("Invisible item frame").setStyle(Style.EMPTY.withItalic(false)));
    glowItemFrame.setCustomName(new LiteralText("Invisible glow item frame").setStyle(Style.EMPTY.withItalic(false)));
    stacks.add(itemFrame);
    stacks.add(glowItemFrame);
}
Also used : NbtCompound(net.minecraft.nbt.NbtCompound) ItemStack(net.minecraft.item.ItemStack) LiteralText(net.minecraft.text.LiteralText)

Example 78 with LiteralText

use of net.minecraft.text.LiteralText in project FZMM-Mod by Zailer43.

the class GradientLogic method getGradient.

public static MutableText getGradient(String message, byte red, byte green, byte blue, byte red2, byte green2, byte blue2, Style style) {
    List<String> messageList = splitString(message);
    int gradientLength = messageList.size();
    byte[] gradientRed = getByteGradient(red, red2, gradientLength);
    byte[] gradientGreen = getByteGradient(green, green2, gradientLength);
    byte[] gradientBlue = getByteGradient(blue, blue2, gradientLength);
    MutableText gradientText = LiteralText.EMPTY.copy();
    for (int i = 0; i != gradientLength; i++) {
        int rgb = rgbToInt(gradientRed[i], gradientGreen[i], gradientBlue[i]);
        gradientText.append(new LiteralText(String.valueOf(messageList.get(i))).setStyle(style.withColor(TextColor.fromRgb(rgb))));
    }
    return gradientText;
}
Also used : MutableText(net.minecraft.text.MutableText) LiteralText(net.minecraft.text.LiteralText)

Example 79 with LiteralText

use of net.minecraft.text.LiteralText in project FZMM-Mod by Zailer43.

the class ImagetextLine method getLine.

public ArrayList<String> getLine() {
    ArrayList<String> lineString = new ArrayList<>();
    short lineIndex = 0;
    for (int i = 0; i != this.line.size(); i++) {
        int color = this.line.get(i).getLeft();
        byte amount = this.line.get(i).getRight();
        String message;
        if (this.isDefaultText && color == -16777216) {
            // -16777216 = 255 0 0 0 (ARGB)
            String emptyString = " ".repeat(amount);
            message = '"' + emptyString + Formatting.BOLD + emptyString + Formatting.RESET + '"';
            lineIndex += amount;
        } else {
            StringBuilder text = new StringBuilder();
            Color pixel = new Color(color);
            color = (pixel.getRed() << 16) + (pixel.getGreen() << 8) + pixel.getBlue();
            for (int x = 0; x != amount; x++) {
                text.append(this.getCharacter(lineIndex++));
            }
            message = Text.Serializer.toJson(new LiteralText(text.toString()).setStyle(this.style.withColor(color)));
        }
        lineString.add(message);
    }
    return lineString;
}
Also used : ArrayList(java.util.ArrayList) LiteralText(net.minecraft.text.LiteralText)

Example 80 with LiteralText

use of net.minecraft.text.LiteralText in project tweakermore by Fallen-Breath.

the class ShulkerToolTipEnhancer method appendEnchantmentHints.

public static void appendEnchantmentHints(ItemStack itemStack, Text text) {
    if (TweakerMoreConfigs.SHULKER_TOOLTIP_ENCHANTMENT_HINT.getBooleanValue()) {
        List<Text> enchantmentTexts = Lists.newArrayList();
        ListTag enchantmentTag = itemStack.getItem() instanceof EnchantedBookItem ? EnchantedBookItem.getEnchantmentTag(itemStack) : itemStack.getEnchantments();
        ItemStack.appendEnchantments(enchantmentTexts, enchantmentTag);
        int amount = enchantmentTexts.size();
        if (amount > 0) {
            TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer;
            Text extraText = new LiteralText(" | ").formatted(Formatting.DARK_GRAY);
            int idx;
            for (idx = 0; idx < amount; idx++) {
                if (idx > 0 && textRenderer.getStringWidth(extraText.getString() + enchantmentTexts.get(idx).getString()) > MAX_TEXT_LENGTH) {
                    break;
                }
                extraText.append(enchantmentTexts.get(idx));
                if (idx < amount - 1) {
                    extraText.append(new LiteralText(", ").formatted(Formatting.GRAY));
                }
            }
            if (idx < amount) {
                extraText.append(new TranslatableText("tweakermore.config.shulkerTooltipEnchantmentHint.more", amount - idx).formatted(Formatting.GRAY));
            }
            text.append(extraText);
        }
    }
}
Also used : TranslatableText(net.minecraft.text.TranslatableText) EnchantedBookItem(net.minecraft.item.EnchantedBookItem) LiteralText(net.minecraft.text.LiteralText) TranslatableText(net.minecraft.text.TranslatableText) Text(net.minecraft.text.Text) ListTag(net.minecraft.nbt.ListTag) TextRenderer(net.minecraft.client.font.TextRenderer) LiteralText(net.minecraft.text.LiteralText)

Aggregations

LiteralText (net.minecraft.text.LiteralText)321 Text (net.minecraft.text.Text)75 ServerPlayerEntity (net.minecraft.server.network.ServerPlayerEntity)67 ServerCommandSource (net.minecraft.server.command.ServerCommandSource)43 ButtonWidget (net.minecraft.client.gui.widget.ButtonWidget)39 ItemStack (net.minecraft.item.ItemStack)39 TranslatableText (net.minecraft.text.TranslatableText)39 Screen (net.minecraft.client.gui.screen.Screen)36 MutableText (net.minecraft.text.MutableText)36 MatrixStack (net.minecraft.client.util.math.MatrixStack)33 HoverEvent (net.minecraft.text.HoverEvent)29 BaseText (net.minecraft.text.BaseText)26 Formatting (net.minecraft.util.Formatting)25 NbtCompound (net.minecraft.nbt.NbtCompound)24 ClickEvent (net.minecraft.text.ClickEvent)24 Inject (org.spongepowered.asm.mixin.injection.Inject)23 TextFieldWidget (net.minecraft.client.gui.widget.TextFieldWidget)19 Items (net.minecraft.item.Items)19 ArrayList (java.util.ArrayList)18 MinecraftClient (net.minecraft.client.MinecraftClient)18