本文整理汇总了Java中net.minecraft.client.gui.GuiUtilRenderComponents类的典型用法代码示例。如果您正苦于以下问题:Java GuiUtilRenderComponents类的具体用法?Java GuiUtilRenderComponents怎么用?Java GuiUtilRenderComponents使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GuiUtilRenderComponents类属于net.minecraft.client.gui包,在下文中一共展示了GuiUtilRenderComponents类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resizeContent
import net.minecraft.client.gui.GuiUtilRenderComponents; //导入依赖的package包/类
private List<ITextComponent> resizeContent(List<String> lines)
{
List<ITextComponent> ret = new ArrayList<ITextComponent>();
for (String line : lines)
{
if (line == null)
{
ret.add(null);
continue;
}
ITextComponent chat = ForgeHooks.newChatWithLinks(line, false);
ret.addAll(GuiUtilRenderComponents.splitText(chat, this.listWidth-8, GuiModList.this.fontRendererObj, false, true));
}
return ret;
}
示例2: draw
import net.minecraft.client.gui.GuiUtilRenderComponents; //导入依赖的package包/类
@Override
public void draw(int mouseX, int mouseY, int y, int virtualWidth) {
List<ITextComponent> lines = GuiUtilRenderComponents.splitText(text, virtualWidth - 20, fontRenderer, false,
false);
int runningY = y;
for (ITextComponent line : lines) {
String strLine = line.getFormattedText();
int halfLineWidth = fontRenderer.getStringWidth(strLine) / 2;
int lineLeft = virtualWidth / 2 - halfLineWidth;
fontRenderer.drawString(strLine, lineLeft, runningY, 0xffffff);
runningY += fontRenderer.FONT_HEIGHT;
}
ITextComponent hoveredComponent = getHoveredComponent(virtualWidth, y, mouseX, mouseY);
if (hoveredComponent != null)
GeneralUtils.handleHoverEvent(hoveredComponent.getStyle().getHoverEvent(), mouseX, mouseY);
}
示例3: getHoveredComponent
import net.minecraft.client.gui.GuiUtilRenderComponents; //导入依赖的package包/类
private ITextComponent getHoveredComponent(int virtualWidth, int y, int mouseX, int mouseY) {
List<ITextComponent> lines = GuiUtilRenderComponents.splitText(text, virtualWidth - 20, fontRenderer, false,
false);
for (ITextComponent line : lines) {
String strLine = line.getFormattedText();
int halfLineWidth = fontRenderer.getStringWidth(strLine) / 2;
int lineLeft = virtualWidth / 2 - halfLineWidth;
int lineRight = virtualWidth / 2 + halfLineWidth;
if (mouseY >= y && mouseY < y + fontRenderer.FONT_HEIGHT && mouseX >= lineLeft && mouseX < lineRight) {
ITextComponent hoveredComponent = null;
for (ITextComponent sibling : line) {
hoveredComponent = sibling;
lineLeft += fontRenderer.getStringWidth(GuiUtilRenderComponents
.removeTextColorsIfConfigured(sibling.getUnformattedComponentText(), false));
if (mouseX < lineLeft)
break;
}
return hoveredComponent;
}
y += fontRenderer.FONT_HEIGHT;
}
return null;
}
示例4: resizeContent
import net.minecraft.client.gui.GuiUtilRenderComponents; //导入依赖的package包/类
private List<ITextComponent> resizeContent(List<String> lines)
{
List<ITextComponent> ret = new ArrayList<ITextComponent>();
for (String line : lines)
{
if (line == null)
{
ret.add(null);
continue;
}
ITextComponent chat = ForgeHooks.newChatWithLinks(line, false);
ret.addAll(GuiUtilRenderComponents.splitText(chat, this.listWidth-8, GuiCustomizeWorld.this.fontRenderer, false, true));
}
return ret;
}
示例5: getHeight
import net.minecraft.client.gui.GuiUtilRenderComponents; //导入依赖的package包/类
@Override
public int getHeight(int virtualWidth) {
return GuiUtilRenderComponents.splitText(text, virtualWidth - 20, fontRenderer, false, false).size()
* fontRenderer.FONT_HEIGHT;
}
示例6: split
import net.minecraft.client.gui.GuiUtilRenderComponents; //导入依赖的package包/类
public static List<ITextComponent> split(ITextComponent chat, int width) {
FontRenderer fr = Minecraft.getMinecraft().fontRenderer;
return GuiUtilRenderComponents.splitText(chat, width, fr, false, false);
}