Search in sources :

Example 1 with Component

use of net.minecraft.network.chat.Component in project MinecraftForge by MinecraftForge.

the class ForgeHooksClient method renderMainMenu.

public static void renderMainMenu(TitleScreen gui, PoseStack mStack, Font font, int width, int height, int alpha) {
    VersionChecker.Status status = ForgeVersion.getStatus();
    if (status == BETA || status == BETA_OUTDATED) {
        // render a warning at the top of the screen,
        Component line = new TranslatableComponent("forge.update.beta.1", ChatFormatting.RED, ChatFormatting.RESET).withStyle(ChatFormatting.RED);
        GuiComponent.drawCenteredString(mStack, font, line, width / 2, 4 + (0 * (font.lineHeight + 1)), 0xFFFFFF | alpha);
        line = new TranslatableComponent("forge.update.beta.2");
        GuiComponent.drawCenteredString(mStack, font, line, width / 2, 4 + (1 * (font.lineHeight + 1)), 0xFFFFFF | alpha);
    }
    String line = null;
    switch(status) {
        // case AHEAD:         line = "Using non-recommended Forge build, issues may arise."}; break;
        case OUTDATED:
        case BETA_OUTDATED:
            line = I18n.get("forge.update.newversion", ForgeVersion.getTarget());
            break;
        default:
            break;
    }
    forgeStatusLine = line;
}
Also used : TranslatableComponent(net.minecraft.network.chat.TranslatableComponent) TooltipComponent(net.minecraft.world.inventory.tooltip.TooltipComponent) TranslatableComponent(net.minecraft.network.chat.TranslatableComponent) TextComponent(net.minecraft.network.chat.TextComponent) Component(net.minecraft.network.chat.Component) ClientTooltipComponent(net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent) GuiComponent(net.minecraft.client.gui.GuiComponent)

Example 2 with Component

use of net.minecraft.network.chat.Component in project MinecraftForge by MinecraftForge.

the class ModListScreen method render.

@Override
public void render(PoseStack mStack, int mouseX, int mouseY, float partialTicks) {
    this.modList.render(mStack, mouseX, mouseY, partialTicks);
    if (this.modInfo != null)
        this.modInfo.render(mStack, mouseX, mouseY, partialTicks);
    Component text = new TranslatableComponent("fml.menu.mods.search");
    int x = modList.getLeft() + ((modList.getRight() - modList.getLeft()) / 2) - (getFontRenderer().width(text) / 2);
    this.search.render(mStack, mouseX, mouseY, partialTicks);
    super.render(mStack, mouseX, mouseY, partialTicks);
    getFontRenderer().draw(mStack, text.getVisualOrderText(), x, search.y - getFontRenderer().lineHeight, 0xFFFFFF);
}
Also used : TranslatableComponent(net.minecraft.network.chat.TranslatableComponent) TranslatableComponent(net.minecraft.network.chat.TranslatableComponent) Component(net.minecraft.network.chat.Component)

Example 3 with Component

use of net.minecraft.network.chat.Component in project MinecraftForge by MinecraftForge.

the class ExtendedButton method renderButton.

/**
 * Draws this button to the screen.
 */
@Override
public void renderButton(PoseStack mStack, int mouseX, int mouseY, float partial) {
    Minecraft mc = Minecraft.getInstance();
    int k = this.getYImage(this.isHovered);
    GuiUtils.drawContinuousTexturedBox(mStack, WIDGETS_LOCATION, this.x, this.y, 0, 46 + k * 20, this.width, this.height, 200, 20, 2, 3, 2, 2, this.getBlitOffset());
    this.renderBg(mStack, mc, mouseX, mouseY);
    Component buttonText = this.getMessage();
    int strWidth = mc.font.width(buttonText);
    int ellipsisWidth = mc.font.width("...");
    if (strWidth > width - 6 && strWidth > ellipsisWidth)
        // TODO, srg names make it hard to figure out how to append to an ITextProperties from this trim operation, wraping this in StringTextComponent is kinda dirty.
        buttonText = new TextComponent(mc.font.substrByWidth(buttonText, width - 6 - ellipsisWidth).getString() + "...");
    drawCenteredString(mStack, mc.font, buttonText, this.x + this.width / 2, this.y + (this.height - 8) / 2, getFGColor());
}
Also used : TextComponent(net.minecraft.network.chat.TextComponent) TextComponent(net.minecraft.network.chat.TextComponent) Component(net.minecraft.network.chat.Component) Minecraft(net.minecraft.client.Minecraft)

Example 4 with Component

use of net.minecraft.network.chat.Component in project MinecraftForge by MinecraftForge.

the class UnicodeGlyphButton method render.

@Override
public void render(PoseStack mStack, int mouseX, int mouseY, float partial) {
    if (this.visible) {
        Minecraft mc = Minecraft.getInstance();
        this.isHovered = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height;
        int k = this.getYImage(this.isHovered);
        GuiUtils.drawContinuousTexturedBox(mStack, WIDGETS_LOCATION, this.x, this.y, 0, 46 + k * 20, this.width, this.height, 200, 20, 2, 3, 2, 2, this.getBlitOffset());
        this.renderBg(mStack, mc, mouseX, mouseY);
        Component buttonText = this.createNarrationMessage();
        int glyphWidth = (int) (mc.font.width(glyph) * glyphScale);
        int strWidth = mc.font.width(buttonText);
        int ellipsisWidth = mc.font.width("...");
        int totalWidth = strWidth + glyphWidth;
        if (totalWidth > width - 6 && totalWidth > ellipsisWidth)
            buttonText = new TextComponent(mc.font.substrByWidth(buttonText, width - 6 - ellipsisWidth).getString().trim() + "...");
        strWidth = mc.font.width(buttonText);
        totalWidth = glyphWidth + strWidth;
        mStack.pushPose();
        mStack.scale(glyphScale, glyphScale, 1.0F);
        this.drawCenteredString(mStack, mc.font, new TextComponent(glyph), (int) (((this.x + (this.width / 2) - (strWidth / 2)) / glyphScale) - (glyphWidth / (2 * glyphScale)) + 2), (int) (((this.y + ((this.height - 8) / glyphScale) / 2) - 1) / glyphScale), getFGColor());
        mStack.popPose();
        this.drawCenteredString(mStack, mc.font, buttonText, (int) (this.x + (this.width / 2) + (glyphWidth / glyphScale)), this.y + (this.height - 8) / 2, getFGColor());
    }
}
Also used : TextComponent(net.minecraft.network.chat.TextComponent) TextComponent(net.minecraft.network.chat.TextComponent) Component(net.minecraft.network.chat.Component) Minecraft(net.minecraft.client.Minecraft)

Example 5 with Component

use of net.minecraft.network.chat.Component in project Denizen-For-Bukkit by DenizenScript.

the class PacketHelperImpl method showTabListHeaderFooter.

@Override
public void showTabListHeaderFooter(Player player, String header, String footer) {
    Component cHeader = Handler.componentToNMS(FormattedTextHelper.parse(header, ChatColor.WHITE));
    Component cFooter = Handler.componentToNMS(FormattedTextHelper.parse(footer, ChatColor.WHITE));
    ClientboundTabListPacket packet = new ClientboundTabListPacket(cHeader, cFooter);
    send(player, packet);
}
Also used : Component(net.minecraft.network.chat.Component)

Aggregations

Component (net.minecraft.network.chat.Component)20 TextComponent (net.minecraft.network.chat.TextComponent)11 TranslatableComponent (net.minecraft.network.chat.TranslatableComponent)7 MutableComponent (net.minecraft.network.chat.MutableComponent)4 ItemStack (net.minecraft.world.item.ItemStack)4 GameProfile (com.mojang.authlib.GameProfile)2 TagCompound (de.keyle.knbt.TagCompound)2 TagList (de.keyle.knbt.TagList)2 TagShort (de.keyle.knbt.TagShort)2 TagString (de.keyle.knbt.TagString)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 Minecraft (net.minecraft.client.Minecraft)2 ClientboundPlayerInfoPacket (net.minecraft.network.protocol.game.ClientboundPlayerInfoPacket)2 Player (net.minecraft.world.entity.player.Player)2 Level (net.minecraft.world.level.Level)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 NativeImage (com.mojang.blaze3d.platform.NativeImage)1 Window (com.mojang.blaze3d.platform.Window)1 RenderSystem (com.mojang.blaze3d.systems.RenderSystem)1 com.mojang.blaze3d.vertex (com.mojang.blaze3d.vertex)1