net.minecraft.client.gui.FontRenderer Java Examples
The following examples show how to use
net.minecraft.client.gui.FontRenderer.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GTRenderDisplayScreen.java From GT-Classic with GNU Lesser General Public License v3.0 | 9 votes |
@Override public void render(GTTileDisplayScreen screen, double x, double y, double z, float partialTicks, int destroyStage, float alpha) { if (screen != null && screen.shouldDraw) { FontRenderer renderer = Minecraft.getMinecraft().fontRenderer; GlStateManager.pushMatrix(); screen.applyRotation((float) x, (float) y, (float) z); screen.applySize(2.5F, 4D, 4D, -0.001D); int bright = 0xF0; int brightX = bright % 65536; int brightY = bright / 65536; OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, brightX, brightY); int i = 0; for (String text : screen.information.getWrapperList()) { i++; if (i > 8) { break; } renderer.drawString(text, (int) x + 10, (int) (y - 2) + (10 * i), Color.CYAN.getRGB()); } GlStateManager.popMatrix(); } }
Example #2
Source File: GuiHelper.java From AgriCraft with MIT License | 6 votes |
/** * Utility method: splits the string in different lines so it will fit on the page. * * @param fontRendererObj the font renderer to check against. * @param input the line to split up. * @param maxWidth the maximum allowable width of the line before being wrapped. * @param scale the scale of the text to the width. * @return the string split up into lines by the '\n' character. */ public static String splitInLines(FontRenderer fontRendererObj, String input, double maxWidth, double scale) { maxWidth = maxWidth / scale; String notProcessed = input; String output = ""; while (fontRendererObj.getStringWidth(notProcessed) > maxWidth) { int index = 0; if (notProcessed != null && !notProcessed.equals("")) { //find the first index at which the string exceeds the size limit while (notProcessed.length() - 1 > index && fontRendererObj.getStringWidth(notProcessed.substring(0, index)) < maxWidth) { index = (index + 1) < notProcessed.length() ? index + 1 : index; } //go back to the first space to cut the string in two lines while (index > 0 && notProcessed.charAt(index) != ' ') { index--; } //update the data for the next iteration output = output.equals("") ? output : output + '\n'; output = output + notProcessed.substring(0, index); notProcessed = notProcessed.length() > index + 1 ? notProcessed.substring(index + 1) : notProcessed; } } return output + '\n' + notProcessed; }
Example #3
Source File: CustomButton.java From MediaMod with GNU General Public License v3.0 | 6 votes |
@Override public void drawButton(Minecraft mc, int mouseX, int mouseY) { if (this.visible) { FontRenderer fontrenderer = mc.fontRendererObj; GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); this.hovered = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height; Gui.drawRect(this.xPosition, this.yPosition, this.xPosition + this.width, this.yPosition + this.height, new Color(0, 0, 0, 175).getRGB()); this.mouseDragged(mc, mouseX, mouseY); int j = 14737632; if (!this.enabled) { j = 10526880; } else if (this.hovered) { j = new Color(180, 180, 180).getRGB(); } drawCenteredString(fontrenderer, this.displayString, this.xPosition + this.width / 2, this.yPosition + (this.height - 8) / 2, j); } }
Example #4
Source File: SliderWidget.java From GregTech with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void drawInBackground(int mouseX, int mouseY, IRenderContext context) { Position pos = getPosition(); Size size = getSize(); if (backgroundArea != null) { backgroundArea.draw(pos.x, pos.y, size.width, size.height); } if(displayString == null) { this.displayString = getDisplayString(); } sliderIcon.draw(pos.x + (int) (this.sliderPosition * (float) (size.width - 8)), pos.y, sliderWidth, size.height); FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer; fontRenderer.drawString(displayString, pos.x + size.width / 2 - fontRenderer.getStringWidth(displayString) / 2, pos.y + size.height / 2 - fontRenderer.FONT_HEIGHT / 2, textColor); GlStateManager.color(1.0f, 1.0f, 1.0f); }
Example #5
Source File: DisplayTable.java From Hyperium with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void draw(int x, int y) { boolean first = true; GlStateManager.pushMatrix(); GlStateManager.translate(x, y, 0); for (String[] row : rows) { FontRenderer fontRendererObj = Minecraft.getMinecraft().fontRendererObj; GlStateManager.pushMatrix(); for (int i = 0; i < row.length; i++) { String tmp = row[i]; fontRendererObj.drawString((first ? EnumChatFormatting.BOLD : "") + tmp, 0, 0, Color.WHITE.getRGB()); GlStateManager.translate(rowSpacing[i], 0, 0); } GlStateManager.popMatrix(); GlStateManager.translate(0, 11, 0); first = false; } GlStateManager.popMatrix(); }
Example #6
Source File: Fonts.java From LiquidBounce with GNU General Public License v3.0 | 6 votes |
public static Object[] getFontDetails(final FontRenderer fontRenderer) { for(final Field field : Fonts.class.getDeclaredFields()) { try { field.setAccessible(true); final Object o = field.get(null); if(o.equals(fontRenderer)) { final FontDetails fontDetails = field.getAnnotation(FontDetails.class); return new Object[] {fontDetails.fontName(), fontDetails.fontSize()}; } }catch(final IllegalAccessException e) { e.printStackTrace(); } } if (fontRenderer instanceof GameFontRenderer) { final Font font = ((GameFontRenderer) fontRenderer).getDefaultFont().getFont(); return new Object[] {font.getName(), font.getSize()}; } return null; }
Example #7
Source File: Fonts.java From LiquidBounce with GNU General Public License v3.0 | 6 votes |
public static List<FontRenderer> getFonts() { final List<FontRenderer> fonts = new ArrayList<>(); for(final Field fontField : Fonts.class.getDeclaredFields()) { try { fontField.setAccessible(true); final Object fontObj = fontField.get(null); if(fontObj instanceof FontRenderer) fonts.add((FontRenderer) fontObj); }catch(final IllegalAccessException e) { e.printStackTrace(); } } fonts.addAll(Fonts.CUSTOM_FONT_RENDERERS); return fonts; }
Example #8
Source File: GuiButton.java From WearableBackpacks with MIT License | 6 votes |
/** Draws the content on the button, such as text. */ protected void drawButtonForeground(boolean isHighlighted, float partialTicks) { String text = getText(); if (text.isEmpty()) return; FontRenderer fontRenderer = getFontRenderer(); int textWidth = fontRenderer.getStringWidth(text); int maxTextWidth = getWidth() - MIN_TEXT_PADDING; if ((textWidth > maxTextWidth) && (textWidth > ELLIPSIS_WIDTH)) { text = fontRenderer.trimStringToWidth(text, maxTextWidth - ELLIPSIS_WIDTH).trim() + ELLIPSIS; textWidth = fontRenderer.getStringWidth(text); } fontRenderer.drawStringWithShadow(text, getWidth() / 2 - textWidth / 2, (getHeight() - 8) / 2, getTextColor(isHighlighted)); }
Example #9
Source File: XRayAddGui.java From ehacks-pro with GNU General Public License v3.0 | 6 votes |
private void drawItem(ItemStack itemstack, int x, int y, String name) { GL11.glColor3ub((byte) -1, (byte) -1, (byte) -1); GL11.glDisable(2896); this.zLevel = 200.0f; GuiScreen.itemRender.zLevel = 200.0f; FontRenderer font = null; if (itemstack != null) { font = itemstack.getItem().getFontRenderer(itemstack); } if (font == null) { font = this.fontRendererObj; } GuiScreen.itemRender.renderItemAndEffectIntoGUI(font, this.mc.getTextureManager(), itemstack, x, y); GuiScreen.itemRender.renderItemOverlayIntoGUI(font, this.mc.getTextureManager(), itemstack, x, y, name); this.zLevel = 0.0f; GuiScreen.itemRender.zLevel = 0.0f; GL11.glEnable(2896); }
Example #10
Source File: WidgetTextFieldNumber.java From Signals with GNU General Public License v3.0 | 6 votes |
public WidgetTextFieldNumber(FontRenderer fontRenderer, int x, int y, int width, int height){ super(fontRenderer, x, y, width, height); setValue(0); setValidator(input -> { if(input == null || input.isEmpty() || input.equals("-")) { return true; // treat as numeric zero } try { double d = Double.parseDouble(input); return d >= this.minValue && d <= this.maxValue; } catch(NumberFormatException e) { return false; } }); }
Example #11
Source File: ClickButtonWidget.java From GregTech with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void drawInBackground(int mouseX, int mouseY, IRenderContext context) { super.drawInBackground(mouseX, mouseY, context); Position position = getPosition(); Size size = getSize(); if (buttonTexture instanceof SizedTextureArea) { ((SizedTextureArea) buttonTexture).drawHorizontalCutSubArea(position.x, position.y, size.width, size.height, 0.0, 1.0); } else { buttonTexture.drawSubArea(position.x, position.y, size.width, size.height, 0.0, 0.0, 1.0, 1.0); } FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer; String text = I18n.format(displayText); fontRenderer.drawString(text, position.x + size.width / 2 - fontRenderer.getStringWidth(text) / 2, position.y + size.height / 2 - fontRenderer.FONT_HEIGHT / 2, textColor); GlStateManager.color(1.0f, 1.0f, 1.0f); }
Example #12
Source File: ControlEventsClient.java From Valkyrien-Skies with Apache License 2.0 | 6 votes |
@SubscribeEvent public void render(RenderGameOverlayEvent.Post event) { Minecraft minecraft = Minecraft.getMinecraft(); EntityPlayer player = Minecraft.getMinecraft().player; FontRenderer fontRenderer = minecraft.fontRenderer; if (fontRenderer != null && player != null && event.getType() == net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType.TEXT) { IShipPilot playerPilot = (IShipPilot) player; if (playerPilot.isPiloting()) { BlockPos tilePilotedPos = playerPilot.getPosBeingControlled(); TileEntity pilotedTile = player.getEntityWorld().getTileEntity(tilePilotedPos); if (pilotedTile instanceof TileEntityPilotableImpl) { TileEntityPilotableImpl pilotedControlEntity = (TileEntityPilotableImpl) pilotedTile; ScaledResolution scaledresolution = new ScaledResolution( Minecraft.getMinecraft()); pilotedControlEntity.renderPilotText(fontRenderer, scaledresolution); } } } }
Example #13
Source File: GTJeiMultiRecipeWrapper.java From GT-Classic with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void drawInfo(Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY) { int extraHeight = 0; FontRenderer font = minecraft.fontRenderer; font.drawString("Ticks: " + getEntryTicks(multiRecipe.getOutputs()), 0, 40, Color.black.getRGB()); font.drawString("Seconds: " + getEntryTicks(multiRecipe.getOutputs()) / 20.0F, 0, 50, Color.black.getRGB()); font.drawString("Tier: " + GTValues.getTierString(EnergyNet.instance.getTierFromPower(multiRecipe.getMachineEu())), 0, 60, Color.black.getRGB()); font.drawString("Usage: " + multiRecipe.getMachineEu() + " EU/t", 0, 70, Color.black.getRGB()); font.drawString("Cost: " + NumberFormat.getNumberInstance(Locale.US).format(getEntryTicks(multiRecipe.getOutputs()) * multiRecipe.getMachineEu()) + " EU", 0, 80, Color.black.getRGB()); if (multiRecipe.getMachineEu() == 8192 && getEntryTicks(multiRecipe.getOutputs()) > 3000) { extraHeight = 10; font.drawString("Output: " + NumberFormat.getNumberInstance(Locale.US).format(getEntryTicks(multiRecipe.getOutputs()) * 32000) + " EU Out", 0, 90, Color.black.getRGB()); } if (GTConfig.general.debugMode) { font.drawString("Recipe Id: " + multiRecipe.getRecipeID(), 0, 90 + extraHeight, Color.black.getRGB()); } }
Example #14
Source File: GuiCustomButton.java From Custom-Main-Menu with MIT License | 5 votes |
public void drawCenteredString(FontRenderer fontRendererIn, String text, int x, int y, int color, boolean shadow) { if (shadow) { fontRendererIn.drawStringWithShadow(text, (float) (x - fontRendererIn.getStringWidth(text) / 2), (float) y, color); } else { fontRendererIn.drawString(text, (float) (x - fontRendererIn.getStringWidth(text) / 2), (float) y, color, false); } }
Example #15
Source File: GuiNEIButton.java From NotEnoughItems with MIT License | 5 votes |
@Override public void drawButton(Minecraft minecraft, int mouseX, int mouseY, float partialTicks) { if (!visible) { return; } FontRenderer fontrenderer = minecraft.fontRenderer; TextureUtils.changeTexture(GUI_TEX); GlStateManager.color(1, 1, 1, 1); boolean flag = mouseX >= x && mouseY >= y && mouseX < x + width && mouseY < y + height; int k = getHoverState(flag); drawTexturedModalRect(x, y, 0, 46 + k * 20, width / 2, height / 2);//top left drawTexturedModalRect(x + width / 2, y, 200 - width / 2, 46 + k * 20, width / 2, height / 2);//top right drawTexturedModalRect(x, y + height / 2, 0, 46 + k * 20 + 20 - height / 2, width / 2, height / 2);//bottom left drawTexturedModalRect(x + width / 2, y + height / 2, 200 - width / 2, 46 + k * 20 + 20 - height / 2, width / 2, height / 2);//bottom right mouseDragged(minecraft, mouseX, mouseY); if (!enabled) { drawCenteredString(fontrenderer, displayString, x + width / 2, y + (height - 8) / 2, 0xffa0a0a0); } else if (flag) { drawCenteredString(fontrenderer, displayString, x + width / 2, y + (height - 8) / 2, 0xffffa0); } else { drawCenteredString(fontrenderer, displayString, x + width / 2, y + (height - 8) / 2, 0xe0e0e0); } }
Example #16
Source File: BlockListEditButton.java From ForgeWurst with GNU General Public License v3.0 | 5 votes |
@Override public int getDefaultWidth() { FontRenderer fr = WMinecraft.getFontRenderer(); String text = setting.getName() + ": " + setting.getBlockNames().size(); return fr.getStringWidth(text) + buttonWidth + 6; }
Example #17
Source File: BlockListEditButton.java From ForgeWurst with GNU General Public License v3.0 | 5 votes |
public BlockListEditButton(BlockListSetting setting) { this.setting = setting; FontRenderer fr = WMinecraft.getFontRenderer(); buttonWidth = fr.getStringWidth("Edit..."); setWidth(getDefaultWidth()); setHeight(getDefaultHeight()); }
Example #18
Source File: EditBlockListScreen.java From ForgeWurst with GNU General Public License v3.0 | 5 votes |
private String renderIconAndGetName(ItemStack stack, int y) { if(WItem.isNullOrEmpty(stack)) { GL11.glPushMatrix(); GL11.glTranslated(52, y, 0); GL11.glScaled(0.75, 0.75, 0.75); RenderHelper.enableGUIStandardItemLighting(); mc.getRenderItem().renderItemAndEffectIntoGUI( new ItemStack(Blocks.GRASS), 0, 0); RenderHelper.disableStandardItemLighting(); GL11.glPopMatrix(); GL11.glDisable(GL11.GL_DEPTH_TEST); FontRenderer fr = WMinecraft.getFontRenderer(); fr.drawString("?", 55, y + 2, 0xf0f0f0, true); GL11.glEnable(GL11.GL_DEPTH_TEST); return ChatFormatting.ITALIC + "unknown block" + ChatFormatting.RESET; }else { GL11.glPushMatrix(); GL11.glTranslated(52, y, 0); GL11.glScaled(0.75, 0.75, 0.75); RenderHelper.enableGUIStandardItemLighting(); mc.getRenderItem().renderItemAndEffectIntoGUI(stack, 0, 0); RenderHelper.disableStandardItemLighting(); GL11.glPopMatrix(); return stack.getDisplayName(); } }
Example #19
Source File: GuiLabel.java From WearableBackpacks with MIT License | 5 votes |
@Override public void draw(int mouseX, int mouseY, float partialTicks) { if (!isVisible()) return; FontRenderer fontRenderer = getFontRenderer(); List<String> lines = fontRenderer.listFormattedStringToWidth(_text, Integer.MAX_VALUE); int yPos = 1; for (String line : lines) { int lineWidth = fontRenderer.getStringWidth(line); if (!_expands && (lineWidth > getWidth())) { line = fontRenderer.trimStringToWidth(line, getWidth() - ELLIPSIS_WIDTH) + ELLIPSIS; lineWidth = fontRenderer.getStringWidth(line); } int xPos = 0; switch (_align) { case LEFT: xPos = 0; break; case RIGHT: xPos = getWidth() - lineWidth; break; case CENTER: xPos = (getWidth() - lineWidth) / 2; break; } int color = isEnabled() ? getColor() : getDisabledColor(); int shadowColor = getShadowColor(); if (shadowColor >= 0) fontRenderer.drawString(line, xPos + 1, yPos + 1, shadowColor); if (shadowColor == SHADOW_AUTOMATIC) fontRenderer.drawStringWithShadow(line, xPos, yPos, color); else fontRenderer.drawString(line, xPos, yPos, color); yPos += LINE_HEIGHT; } }
Example #20
Source File: GTJeiUUAmplifierWrapper.java From GT-Classic with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void drawInfo(Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY) { FontRenderer font = minecraft.fontRenderer; int value = getEntryTicks(multiRecipe.getOutputs()); DecimalFormat df = new DecimalFormat("###.##"); font.drawString("Progress: " + df.format(100.0 / (1000000.0 / value)) + "%", 0, 40, Color.black.getRGB()); font.drawString("Multiplier: " + value / 5000.0 + "X", 0, 50, Color.black.getRGB()); font.drawString("Cost: " + NumberFormat.getNumberInstance(Locale.US).format(value) + " EU", 0, 60, Color.black.getRGB()); if (GTConfig.general.debugMode) { font.drawString("Recipe Id: " + multiRecipe.getRecipeID(), 0, 70, Color.black.getRGB()); } }
Example #21
Source File: ModuleData.java From AdvancedRocketry with MIT License | 5 votes |
@SideOnly(Side.CLIENT) @Override public void renderForeground(int guiOffsetX, int guiOffsetY, int mouseX, int mouseY, float zLevel, GuiContainer gui, FontRenderer font) { buttonLoad.renderForeground(guiOffsetX, guiOffsetY, mouseX, mouseY, zLevel, gui, font); buttonStore.renderForeground(guiOffsetX, guiOffsetY, mouseX, mouseY, zLevel, gui, font); int relativeX = mouseX - offsetX; int relativeY = mouseY - offsetY; //Handles data tooltip if( relativeX > 0 && relativeX < barXSize && relativeY > 0 && relativeY < barYSize) { int totalData = 0, totalMaxData = 0; for(DataStorage datum : data) { totalData += datum.getData(); totalMaxData += datum.getMaxData(); } List<String> list = new LinkedList<String>(); list.add(totalData + " / " + totalMaxData + " Data"); list.add("Type: " + I18n.format(data[0].getDataType().toString(), new Object[0])); this.drawTooltip(gui, list, mouseX, mouseY, zLevel, font); } }
Example #22
Source File: Text.java From OpenPeripheral-Addons with MIT License | 5 votes |
private void updateBoundingBox() { final int height = Math.round(8 * scale); final int width; if (Strings.isNullOrEmpty(text)) { width = 0; } else { FontRenderer fontRenderer = FMLClientHandler.instance().getClient().fontRenderer; width = Math.round(fontRenderer.getStringWidth(text) * scale); } setBoundingBox(Box2d.fromOriginAndSize(x, y, width, height)); }
Example #23
Source File: AbstractRenderer.java From BoundingBoxOutlineReloaded with MIT License | 5 votes |
void renderText(OffsetPoint offsetPoint, String... texts) { FontRenderer fontRenderer = Minecraft.getInstance().fontRenderer; RenderHelper.beforeRenderFont(offsetPoint); float top = -(fontRenderer.FONT_HEIGHT * texts.length) / 2f; for (String text : texts) { float left = fontRenderer.getStringWidth(text) / 2f; fontRenderer.drawString(text, -left, top, -1); top += fontRenderer.FONT_HEIGHT; } RenderHelper.afterRenderFont(); }
Example #24
Source File: MixinGuiOverlayDebug.java From Hyperium with GNU Lesser General Public License v3.0 | 5 votes |
private void renderOldDebugInfoLeft() { FontRenderer fontRendererObj = mc.fontRendererObj; fontRendererObj.drawStringWithShadow("Minecraft 1.8.9 (" + Minecraft.getDebugFPS() + " fps, " + RenderChunk.renderChunksUpdated + " chunk updates)", 2, 2, -1); fontRendererObj.drawStringWithShadow(mc.renderGlobal.getDebugInfoRenders(), 2, 12, -1); fontRendererObj.drawStringWithShadow(mc.renderGlobal.getDebugInfoEntities(), 2, 22, -1); fontRendererObj.drawStringWithShadow("P: " + mc.effectRenderer.getStatistics() + ". T: " + mc.theWorld.getDebugLoadedEntities(), 2, 32, -1); fontRendererObj.drawStringWithShadow(mc.theWorld.getProviderName(), 2, 42, -1); int posX = MathHelper.floor_double(mc.thePlayer.posX); int posY = MathHelper.floor_double(mc.thePlayer.posY); int posZ = MathHelper.floor_double(mc.thePlayer.posZ); fontRendererObj.drawStringWithShadow(String.format("x: %.5f (%d) // c: %d (%d)", mc.thePlayer.posX, posX, posX >> 4, posX & 15), 2, 64, -1); fontRendererObj.drawStringWithShadow(String.format("y: %.3f (feet pos, %.3f eyes pos)", mc.thePlayer.getEntityBoundingBox().minY, mc.thePlayer.posY), 2, 72, -1); Entity entity = mc.getRenderViewEntity(); EnumFacing enumfacing = entity.getHorizontalFacing(); fontRendererObj.drawStringWithShadow(String.format("z: %.5f (%d) // c: %d (%d)", mc.thePlayer.posZ, posZ, posZ >> 4, posZ & 15), 2, 80, -1); int yaw = MathHelper.floor_double((double) (mc.thePlayer.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; fontRendererObj.drawStringWithShadow("f: " + yaw + " (" + enumfacing + ") / " + MathHelper.wrapAngleTo180_float(mc.thePlayer.rotationYaw), 2, 88, -1); if (mc.theWorld != null && !mc.theWorld.isAirBlock(new BlockPos(posX, posY, posZ))) { Chunk chunk = mc.theWorld.getChunkFromBlockCoords(new BlockPos(posX, posY, posZ)); fontRendererObj.drawStringWithShadow("lc: " + (chunk.getTopFilledSegment() + 15) + " b: " + chunk.getBiome(new BlockPos(posX & 15, 64, posZ & 15), mc.theWorld.getWorldChunkManager()).biomeName + " bl: " + chunk.getBlockLightOpacity(new BlockPos(posX & 15, posY, posZ & 15)) + " sl: " + chunk.getBlockLightOpacity( new BlockPos(posX & 15, posY, posZ & 15)) + " rl: " + chunk.getBlockLightOpacity(new BlockPos(posX & 15, posY, posZ & 15)), 2, 96, -1); } fontRendererObj.drawStringWithShadow(String.format("ws: %.3f, fs: %.3f, g: %b, fl: %d", mc.thePlayer.capabilities.getWalkSpeed(), mc.thePlayer.capabilities.getFlySpeed(), mc.thePlayer.onGround, mc.theWorld.getHeight()), 2, 104, -1); if (mc.entityRenderer != null && mc.entityRenderer.isShaderActive()) { fontRendererObj.drawStringWithShadow(String.format("shader: %s", mc.entityRenderer.getShaderGroup().getShaderGroupName()), 2, 112, -1); } }
Example #25
Source File: ElementRenderer.java From Hyperium with GNU Lesser General Public License v3.0 | 5 votes |
private static void drawChromaString(String text, int xIn, int y) { FontRenderer renderer = Minecraft.getMinecraft().fontRendererObj; int x = xIn; for (char c : text.toCharArray()) { long dif = (x * 10) - (y * 10); if (current.isStaticChroma()) dif = 0; long l = System.currentTimeMillis() - dif; float ff = current.isStaticChroma() ? 1000.0F : 2000.0F; int i = Color.HSBtoRGB((float) (l % (int) ff) / ff, 0.8F, 0.8F); String tmp = String.valueOf(c); renderer.drawString(tmp, (float) ((double) x / currentScale), (float) ((double) y / currentScale), i, current.isShadow()); x += (double) renderer.getCharWidth(c) * currentScale; } }
Example #26
Source File: MemoryDisplay.java From Hyperium with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void draw(int x, double y, boolean config) { int mbDiv = 1048576; long maxMemory = Runtime.getRuntime().maxMemory() / mbDiv; long totalMemory = (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / mbDiv; String displayString = totalMemory + " / " + (maxMemory == Long.MAX_VALUE ? "No limit" : maxMemory) + "MB"; ElementRenderer.draw(x, y, displayString); FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; height = fr.FONT_HEIGHT * ElementRenderer.getCurrentScale(); width = fr.getStringWidth(displayString) * ElementRenderer.getCurrentScale(); }
Example #27
Source File: AboveHeadRenderer.java From Hyperium with GNU Lesser General Public License v3.0 | 5 votes |
private void renderName(RenderPlayerEvent event, LevelheadTag tag, EntityPlayer player, double x, double y, double z) { FontRenderer fontrenderer = event.getRenderManager().getFontRenderer(); float f = (float) (1.6F * Levelhead.getInstance().getDisplayManager().getMasterConfig().getFontSize()); float f1 = 0.016666668F * f; GlStateManager.pushMatrix(); GlStateManager.translate((float) x + 0.0F, (float) y + player.height + 0.5F, (float) z); GL11.glNormal3f(0.0F, 1.0F, 0.0F); GlStateManager.rotate(-event.getRenderManager().playerViewY, 0.0F, 1.0F, 0.0F); GlStateManager.rotate(event.getRenderManager().playerViewX, 1.0F, 0.0F, 0.0F); GlStateManager.scale(-f1, -f1, f1); GlStateManager.disableLighting(); GlStateManager.depthMask(false); GlStateManager.disableDepth(); GlStateManager.enableBlend(); GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO); Tessellator tessellator = Tessellator.getInstance(); WorldRenderer worldrenderer = tessellator.getWorldRenderer(); int i = 0; int j = fontrenderer.getStringWidth(tag.getString()) / 2; GlStateManager.disableTexture2D(); worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR); worldrenderer.pos(-j - 1, -1 + i, 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex(); worldrenderer.pos(-j - 1, 8 + i, 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex(); worldrenderer.pos(j + 1, 8 + i, 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex(); worldrenderer.pos(j + 1, -1 + i, 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex(); tessellator.draw(); GlStateManager.enableTexture2D(); renderString(fontrenderer, tag); GlStateManager.enableLighting(); GlStateManager.disableBlend(); GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); GlStateManager.popMatrix(); }
Example #28
Source File: HyperiumRender.java From Hyperium with GNU Lesser General Public License v3.0 | 5 votes |
private static void drawChromaWaveString(String text, int xIn, int y) { FontRenderer renderer = Minecraft.getMinecraft().fontRendererObj; int x = xIn; for (char c : text.toCharArray()) { long dif = (x * 10) - (y * 10); long l = System.currentTimeMillis() - dif; float ff = 2000.0F; int i = Color.HSBtoRGB((float) (l % (int) ff) / ff, 0.8F, 0.8F); String tmp = String.valueOf(c); renderer.drawString(tmp, (float) ((double) x), (float) ((double) y), i, false); x += (double) renderer.getCharWidth(c); } }
Example #29
Source File: GuiCustomizeWorld.java From YUNoMakeGoodMap with Apache License 2.0 | 5 votes |
@Override protected void drawSlot(int slotIdx, int entryRight, int slotTop, int slotBuffer, Tessellator tess) { ResourceLocation item = list.get(slotIdx); StructInfo info = getInfo(item); FontRenderer font = GuiCustomizeWorld.this.fontRenderer; font.drawString(font.trimStringToWidth(info.name, listWidth - 10), this.left + 3 , slotTop + 2, 0xFF2222); }
Example #30
Source File: GuiTextField.java From NBTEdit with GNU General Public License v3.0 | 5 votes |
public GuiTextField(FontRenderer par1FontRenderer, int x, int y, int w, int h, boolean allowSection) { this.fontRenderer = par1FontRenderer; this.xPos = x; this.yPos = y; this.width = w; this.height = h; this.allowSection = allowSection; }