本文整理汇总了Java中net.minecraft.client.gui.FontRenderer.drawString方法的典型用法代码示例。如果您正苦于以下问题:Java FontRenderer.drawString方法的具体用法?Java FontRenderer.drawString怎么用?Java FontRenderer.drawString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.client.gui.FontRenderer
的用法示例。
在下文中一共展示了FontRenderer.drawString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: drawForegroundLayer
import net.minecraft.client.gui.FontRenderer; //导入方法依赖的package包/类
@Override
public void drawForegroundLayer(BasicTeslaGuiContainer container, int guiX, int guiY, int mouseX, int mouseY) {
super.drawForegroundLayer(container, guiX, guiY, mouseX, mouseY);
if (this.tile != null) {
FontRenderer renderer = Minecraft.getMinecraft().fontRenderer;
GlStateManager.pushMatrix();
GlStateManager.translate(this.getLeft() + 2, this.getTop() + 8, 0);
GlStateManager.scale(1, 1, 1);
if (!tile.getItemStack().isEmpty()) {
ItemStackUtils.renderItemIntoGUI(tile.getItemStack(), 1, 0, 7);
String display = new TextComponentTranslation(tile.getDisplayNameUnlocalized()).getUnformattedText();
renderer.drawString(TextFormatting.DARK_GRAY + display.substring(0, Math.min(display.length(), 21)) + (display.length() > 21 ? "." : ""), 20, 4, 0xFFFFFF);
renderer.drawString(TextFormatting.DARK_GRAY + new TextComponentTranslation("text.industrialforegoing.display.amount").getUnformattedText() + " " + new DecimalFormat().format(tile.getAmount()), 4, (renderer.FONT_HEIGHT) * 3, 0xFFFFFF);
} else {
renderer.drawString(TextFormatting.DARK_GRAY + new TextComponentTranslation("text.industrialforegoing.display.empty").getFormattedText(), 4, 4, 0xFFFFFF);
}
GlStateManager.popMatrix();
}
}
示例2: drawButton
import net.minecraft.client.gui.FontRenderer; //导入方法依赖的package包/类
@Override
public void drawButton(Minecraft mc, int mouseX, int mouseY, float partialTicks) {
if (this.visible) {
FontRenderer fontrenderer = mc.fontRenderer;
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
this.hovered = mouseX >= this.x && mouseY >= this.y
&& mouseX < this.x + this.width && mouseY < this.y + this.height;
int i = this.getHoverState(this.hovered);
this.mouseDragged(mc, mouseX, mouseY);
int j = 0;
String p = "";
if (!this.enabled) {
j = 10526880;
} else if (this.hovered) {
j = 1450415;
p += TextFormatting.UNDERLINE;
}
fontrenderer.drawString(p + I18n.format(this.displayString), this.x, this.y, j);
}
}
示例3: drawSlot
import net.minecraft.client.gui.FontRenderer; //导入方法依赖的package包/类
@Override
protected void drawSlot(int idx, int right, int top, int height, Tessellator tess)
{
if(idx >= 0 && idx < channels.size())
{
FontRenderer font = this.parent.getFontRenderer();
String channel = channels.get(idx);
GlStateManager.pushMatrix();
GlStateManager.scale(0.5F, 0.5F, 1F);
String name = font.trimStringToWidth(channel.substring(channel.indexOf(":") + 1), (listWidth - 10) * 2);
if(channel.startsWith("public:"))
{
name = I18n.translateToLocal("glass.gui.public") + " " + name;
}
font.drawString(name, (this.left + 2) * 2, top * 2, idx % 2 == 0 ? 0xFFFFFF : 0xAAAAAA);
GlStateManager.popMatrix();
}
}
示例4: drawScreen
import net.minecraft.client.gui.FontRenderer; //导入方法依赖的package包/类
@Override
public void drawScreen(int x, int y, float partialTicks) {
textField.drawTextBox();
FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer;
fontRenderer.drawString(I18n.format("gui.entityFilter"), 35, 50, 0xFFFFFFFF);
if (Keyboard.isKeyDown(Keyboard.KEY_F1)) {
GuiUtils.showPopupHelpScreen(Minecraft.getMinecraft().currentScreen, fontRenderer,
PneumaticCraftUtils.convertStringIntoList(I18n.format("gui.entityFilter.helpText"), 60));
}
}
示例5: render
import net.minecraft.client.gui.FontRenderer; //导入方法依赖的package包/类
@Override
public void render(int mouseX, int mouseY, float partialTick) {
fluid = tank.getFluid() != null ? tank.getFluid().getFluid() : null;
super.render(mouseX, mouseY, partialTick);
if (fluid != null) {
int fluidAmount = tank.getFluidAmount() / 1000;
String s = fluidAmount + "B";
if (fluidAmount > 1) {
FontRenderer fr = Minecraft.getMinecraft().fontRenderer;
GlStateManager.translate(0, 0, 400); // ensure amount is drawn in front of the fluid texture
fr.drawString(s, x - fr.getStringWidth(s) + 17, y + 9, 0xFFFFFFFF, true);
GlStateManager.translate(0, 0, -400);
}
}
}
示例6: drawExtras
import net.minecraft.client.gui.FontRenderer; //导入方法依赖的package包/类
@Override
public void drawExtras(Minecraft minecraft) {
drawProgressBar(68, 75, 173, 0, 24, 17, StartDirection.LEFT);
FontRenderer fontRenderer = FMLClientHandler.instance().getClient().fontRenderer;
fontRenderer.drawString("Required Machines", 5, 15, 4210752);
fontRenderer.drawString("Prog.", 129, 9, 4210752);
}
示例7: drawCenteredSplitString
import net.minecraft.client.gui.FontRenderer; //导入方法依赖的package包/类
public static void drawCenteredSplitString(FontRenderer fontRenderer, String text, float x, float y, int wrap,
int color)
{
List<String> strings = fontRenderer.listFormattedStringToWidth(text, wrap);
for (String s : strings)
{
fontRenderer.drawString(s, (float) (x - fontRenderer.getStringWidth(s) / 2), y, color, false);
y += fontRenderer.FONT_HEIGHT;
}
}
示例8: renderZoomedStack
import net.minecraft.client.gui.FontRenderer; //导入方法依赖的package包/类
private static void renderZoomedStack(ItemStack itemStack, GuiContainer guiContainer, Minecraft minecraft) {
ScaledResolution scaledResolution = new ScaledResolution(minecraft);
final float scale = Config.getZoomAmount() / 100f * guiContainer.getGuiLeft() / 17f; // item is 16 wide, give it some extra space on each side
final float xPosition = (guiContainer.getGuiLeft() / scale - 16f) / 2f;
final float yPosition = (scaledResolution.getScaledHeight() / scale - 16f) / 2f;
FontRenderer font = getFontRenderer(minecraft, itemStack);
GlStateManager.pushMatrix();
GlStateManager.scale(scale, scale, 1);
GlStateManager.translate(xPosition, yPosition, 0);
ZoomRenderHelper.enableGUIStandardItemLighting(scale);
minecraft.getRenderItem().zLevel += 100;
minecraft.getRenderItem().renderItemAndEffectIntoGUI(minecraft.player, itemStack, 0, 0);
renderItemOverlayIntoGUI(font, itemStack);
minecraft.getRenderItem().zLevel -= 100;
GlStateManager.disableBlend();
RenderHelper.disableStandardItemLighting();
GlStateManager.popMatrix();
if (Config.showHelpText()) {
String modName = ItemZoom.MOD_NAME;
int stringWidth = font.getStringWidth(modName);
int x = (guiContainer.getGuiLeft() - stringWidth) / 2;
int y = (scaledResolution.getScaledHeight() + Math.round(17 * scale)) / 2;
font.drawString(modName, x, y, 4210752);
if (Config.isToggledEnabled()) {
String toggleText = KeyBindings.TOGGLE.getDisplayName();
stringWidth = font.getStringWidth(toggleText);
x = (guiContainer.getGuiLeft() - stringWidth) / 2;
y += font.FONT_HEIGHT;
font.drawString(toggleText, x, y, 4210752);
}
}
}
示例9: render
import net.minecraft.client.gui.FontRenderer; //导入方法依赖的package包/类
@Override
public void render(GuiScreenEvent.DrawScreenEvent.Post event)
{
FontRenderer font = Minecraft.getMinecraft().fontRenderer;
int left = getLeft(event.getGui(), font.getStringWidth(text));
int top = getTop(event.getGui(), font.FONT_HEIGHT);
font.drawString(text, left, top, color.getRGB(), dropShadow);
}
示例10: drawBackgroundLayer
import net.minecraft.client.gui.FontRenderer; //导入方法依赖的package包/类
@SideOnly(Side.CLIENT)
@Override
public void drawBackgroundLayer(BasicTeslaGuiContainer<?> container, int guiX, int guiY, float partialTicks, int mouseX, int mouseY) {
super.drawBackgroundLayer(container, guiX, guiY, partialTicks, mouseX, mouseY);
FontRenderer renderer = Minecraft.getMinecraft().fontRenderer;
GlStateManager.pushMatrix();
GlStateManager.scale(1, 1, 1);
renderer.drawString(string.getString(id), this.getLeft() + guiX, this.getTop() + guiY, 0xFFFFFF);
GlStateManager.popMatrix();
}
示例11: drawNameplate
import net.minecraft.client.gui.FontRenderer; //导入方法依赖的package包/类
public static void drawNameplate(FontRenderer fontRendererIn, String str, float x, float y, float z, int verticalShift, float viewerYaw, float viewerPitch, boolean isThirdPersonFrontal)
{
GlStateManager.pushMatrix();
GlStateManager.translate(x, y, z);
GlStateManager.glNormal3f(0.0F, 1.0F, 0.0F);
GlStateManager.rotate(-viewerYaw, 0.0F, 1.0F, 0.0F);
GlStateManager.rotate((float)(isThirdPersonFrontal ? -1 : 1) * viewerPitch, 1.0F, 0.0F, 0.0F);
GlStateManager.scale(-0.025F, -0.025F, 0.025F);
GlStateManager.disableLighting();
GlStateManager.depthMask(false);
GlStateManager.enableBlend();
GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
int i = fontRendererIn.getStringWidth(str) / 2;
GlStateManager.disableTexture2D();
Tessellator tessellator = Tessellator.getInstance();
VertexBuffer vertexbuffer = tessellator.getBuffer();
vertexbuffer.begin(7, DefaultVertexFormats.POSITION_COLOR);
vertexbuffer.pos((double)(-i - 1), (double)(-1 + verticalShift), 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
vertexbuffer.pos((double)(-i - 1), (double)(8 + verticalShift), 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
vertexbuffer.pos((double)(i + 1), (double)(8 + verticalShift), 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
vertexbuffer.pos((double)(i + 1), (double)(-1 + verticalShift), 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
tessellator.draw();
GlStateManager.enableTexture2D();
GlStateManager.depthMask(true);
fontRendererIn.drawString(str, -fontRendererIn.getStringWidth(str) / 2, verticalShift, -1);
GlStateManager.enableLighting();
GlStateManager.disableBlend();
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
GlStateManager.popMatrix();
}
示例12: drawSlot
import net.minecraft.client.gui.FontRenderer; //导入方法依赖的package包/类
@Override
protected void drawSlot(int idx, int right, int top, int height, Tessellator tess)
{
if(idx >= 0 && idx < tracks.size())
{
FontRenderer font = this.parent.getFontRenderer();
TrackFile track = tracks.get(idx);
GlStateManager.pushMatrix();
GlStateManager.scale(0.5F, 0.5F, 1F);
String trim = font.trimStringToWidth(track.track.getTitle(), (listWidth - 10) * 2);
if(isSelected(idx) && !track.track.getTitle().endsWith(trim))
{
int lengthDiff = (int)Math.ceil((track.track.getTitle().length() - trim.length()) * 1.4D);
String newString = track.track.getTitle().substring(lengthDiff);
int val = ((parent.scrollTicker % (lengthDiff * 2 + 40)) / 2) - 10;
if(val < 0)
{
val = 0;
}
String newTrim = font.trimStringToWidth(track.track.getTitle().substring(val), (listWidth - 10) * 2);
if(newString.length() > newTrim.length())
{
trim = newString;
}
else
{
trim = newTrim;
}
}
font.drawString(trim, (this.left + 2) * 2, top * 2, idx % 2 == 0 ? 0xFFFFFF : 0xAAAAAA);
GlStateManager.popMatrix();
}
}
示例13: renderName
import net.minecraft.client.gui.FontRenderer; //导入方法依赖的package包/类
public void renderName(T entity, double x, double y, double z)
{
if (this.canRenderName(entity))
{
double d0 = entity.getDistanceSqToEntity(this.renderManager.livingPlayer);
float f = entity.isSneaking() ? 32.0F : 64.0F;
if (d0 < (double)(f * f))
{
String s = entity.getDisplayName().getFormattedText();
float f1 = 0.02666667F;
GlStateManager.alphaFunc(516, 0.1F);
if (entity.isSneaking())
{
FontRenderer fontrenderer = this.getFontRendererFromRenderManager();
GlStateManager.pushMatrix();
GlStateManager.translate((float)x, (float)y + entity.height + 0.5F - (entity.isChild() ? entity.height / 2.0F : 0.0F), (float)z);
GL11.glNormal3f(0.0F, 1.0F, 0.0F);
GlStateManager.rotate(-this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
GlStateManager.rotate(this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F);
GlStateManager.scale(-0.02666667F, -0.02666667F, 0.02666667F);
GlStateManager.translate(0.0F, 9.374999F, 0.0F);
GlStateManager.disableLighting();
GlStateManager.depthMask(false);
GlStateManager.enableBlend();
GlStateManager.disableTexture2D();
GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
int i = fontrenderer.getStringWidth(s) / 2;
Tessellator tessellator = Tessellator.getInstance();
WorldRenderer worldrenderer = tessellator.getWorldRenderer();
worldrenderer.begin(7, DefaultVertexFormats.POSITION_COLOR);
worldrenderer.pos((double)(-i - 1), -1.0D, 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
worldrenderer.pos((double)(-i - 1), 8.0D, 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
worldrenderer.pos((double)(i + 1), 8.0D, 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
worldrenderer.pos((double)(i + 1), -1.0D, 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
tessellator.draw();
GlStateManager.enableTexture2D();
GlStateManager.depthMask(true);
fontrenderer.drawString(s, -fontrenderer.getStringWidth(s) / 2, 0, 553648127);
GlStateManager.enableLighting();
GlStateManager.disableBlend();
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
GlStateManager.popMatrix();
}
else
{
this.renderOffsetLivingLabel(entity, x, y - (entity.isChild() ? (double)(entity.height / 2.0F) : 0.0D), z, s, 0.02666667F, d0);
}
}
}
}
示例14: renderTooltip
import net.minecraft.client.gui.FontRenderer; //导入方法依赖的package包/类
public static void renderTooltip(int x, int y, List<String> tooltipData, Color color, Color colorFade, Color strColor, FontRenderer fontRenderer) {
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
boolean lighting = GL11.glGetBoolean(GL11.GL_LIGHTING);
if (lighting)
RenderHelper.disableStandardItemLighting();
if (!tooltipData.isEmpty()) {
int esWidth = 0;
for (String toolTip : tooltipData) {
int width = fontRenderer.getStringWidth(toolTip);
if (width > esWidth)
esWidth = width;
}
ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft());
if(x + 15 + esWidth > sr.getScaledWidth()) {
x -= esWidth + 24;
}
int sumLineHeight = 8;
if (tooltipData.size() > 1)
sumLineHeight += 2 + (tooltipData.size() - 1) * 10;
if(y + sumLineHeight > sr.getScaledHeight()) {
y = (sr.getScaledHeight() - sumLineHeight);
y = Math.max(25, y);
}
int pX = x + 12;
int pY = y - 12;
float z = 300F;
drawGradientRect(pX - 3, pY - 4, z, pX + esWidth + 3, pY - 3, color, colorFade);
drawGradientRect(pX - 3, pY + sumLineHeight + 3, z, pX + esWidth + 3, pY + sumLineHeight + 4, color, colorFade);
drawGradientRect(pX - 3, pY - 3, z, pX + esWidth + 3, pY + sumLineHeight + 3, color, colorFade);
drawGradientRect(pX - 4, pY - 3, z, pX - 3, pY + sumLineHeight + 3, color, colorFade);
drawGradientRect(pX + esWidth + 3, pY - 3, z, pX + esWidth + 4, pY + sumLineHeight + 3, color, colorFade);
int rgb = color.getRGB();
int col = (rgb & 0x00FFFFFF) | rgb & 0xFF000000;
Color colOp = new Color(col);
drawGradientRect(pX - 3, pY - 3 + 1, z, pX - 3 + 1, pY + sumLineHeight + 3 - 1, color, colOp);
drawGradientRect(pX + esWidth + 2, pY - 3 + 1, z, pX + esWidth + 3, pY + sumLineHeight + 3 - 1, color, colOp);
drawGradientRect(pX - 3, pY - 3, z, pX + esWidth + 3, pY - 3 + 1, colOp, colOp);
drawGradientRect(pX - 3, pY + sumLineHeight + 2, z, pX + esWidth + 3, pY + sumLineHeight + 3, color, color);
GlStateManager.disableDepth();
for (int i = 0; i < tooltipData.size(); ++i) {
String str = tooltipData.get(i);
fontRenderer.drawString(str, pX, pY, strColor.getRGB());
if (i == 0)
pY += 2;
pY += 10;
}
GlStateManager.color(1F, 1F, 1F, 1F);
GlStateManager.enableDepth();
}
if (lighting)
RenderHelper.enableStandardItemLighting();
GlStateManager.color(1F, 1F, 1F, 1F);
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
}
示例15: drawCenteredStringWithoutShadow
import net.minecraft.client.gui.FontRenderer; //导入方法依赖的package包/类
public void drawCenteredStringWithoutShadow(FontRenderer fontRendererIn, String text, int x, int y, int color)
{
fontRendererIn.drawString(text, x - fontRendererIn.getStringWidth(text) / 2, y, color);
}