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;
}
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);
}
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());
}
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());
}
}
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);
}
Aggregations