@SubscribeEvent public void drawDislocationFocusHUD(RenderGameOverlayEvent.Post event) { if (event.type == ElementType.HOTBAR && ClientHelper.minecraft().currentScreen == null) { boolean up = !Config.dialBottom; int xpos = 4; int ypos = up ? 50 : event.resolution.getScaledHeight() - 70; ItemStack item = ClientHelper.clientPlayer().getCurrentEquippedItem(); if (item != null && item.getItem() instanceof ItemWandCasting) { ItemWandCasting wand = (ItemWandCasting) item.getItem(); wand.getFocusItem(item); ItemFocusBasic focus = wand.getFocus(item); if (focus != null && focus instanceof ItemFocusDislocation) { ItemStack pickedBlock = ((ItemFocusDislocation) focus).getPickedBlock(item); if (pickedBlock != null) { Gui.drawRect(xpos - 1, ypos - 1, xpos + 18, ypos + 18, 0x66000000); FontRenderer font = ClientHelper.fontRenderer(); boolean unicode = font.getUnicodeFlag(); font.setUnicodeFlag(true); String name = StatCollector.translateToLocal("ttmisc.focusDislocation.tooltip"); int strLength = font.getStringWidth(name); Gui.drawRect(xpos + 18, ypos, xpos + 18 + strLength + 4, ypos + 9, 0x66000000); font.drawStringWithShadow(name, xpos + 20, ypos, 0xFFAA00); NBTTagCompound cmp = ((ItemFocusDislocation) focus).getStackTileEntity(item); if (cmp != null && !cmp.hasNoTags()) { String content = StatCollector.translateToLocal("ttmisc.focusDislocation.tooltipExtra"); font.getStringWidth(content); Gui.drawRect(xpos + 18, ypos + 9, xpos + 18 + strLength + 4, ypos + 18, 0x66000000); font.drawStringWithShadow(content, xpos + 20, ypos + 9, 0xFFAA00); } if (new ItemStack(((ItemBlock) pickedBlock.getItem()).field_150939_a).getItem() != null) renderItem.renderItemIntoGUI( font, ClientHelper.minecraft().renderEngine, new ItemStack(((ItemBlock) pickedBlock.getItem()).field_150939_a), xpos, ypos); else { if (((ItemBlock) pickedBlock.getItem()).field_150939_a == Blocks.reeds) renderItem.renderItemIntoGUI( font, ClientHelper.minecraft().renderEngine, new ItemStack(Items.reeds), xpos, ypos); } font.setUnicodeFlag(unicode); } } } } }
@SideOnly(Side.CLIENT) public static void renderText(int x, int y, int width, int height, String unlocalizedText) { FontRenderer renderer = Minecraft.getMinecraft().fontRenderer; boolean unicode = renderer.getUnicodeFlag(); renderer.setUnicodeFlag(true); String text = StatCollector.translateToLocal(unlocalizedText).replaceAll("&", "\u00a7"); String[] textEntries = text.split("<br>"); String lastFormat = ""; String pendingFormat = ""; for (String s : textEntries) { List<String> wrappedLines = new ArrayList(); String workingOn = ""; int i = 0; String[] tokens = s.split(" "); for (String s1 : tokens) { boolean skipPending = false; String format = FontHelper.getFormatFromString(s1); if (!format.isEmpty() && s1.length() > 0 && s1.charAt(0) != '\u00a7') { skipPending = true; pendingFormat = format; format = ""; } if (!pendingFormat.isEmpty() && !skipPending) { format = pendingFormat; pendingFormat = ""; } if (MathHelper.stringNullOrLengthZero(format)) format = lastFormat; if (renderer.getStringWidth(workingOn + " " + s1) >= width) { wrappedLines.add(workingOn); workingOn = ""; } workingOn = workingOn + format + " " + s1; if (i == tokens.length - 1) wrappedLines.add(workingOn); ++i; lastFormat = format; } for (String s1 : wrappedLines) { y += 10; renderer.drawString(s1, x, y, 0); } y += 10; } renderer.setUnicodeFlag(unicode); }
@SideOnly(Side.CLIENT) private KnowledgeObject<?> getHoveredObject( FontRenderer fontRenderer, int mouseX, int mouseY, int x, int y) { if (!(mouseX >= x && mouseX <= x + CompendiumPageHandler.innerWidth && mouseY >= y && parsed.contains(linkColor))) return null; boolean origFont = fontRenderer.getUnicodeFlag(); fontRenderer.setUnicodeFlag(true); List<String> list = fontRenderer.listFormattedStringToWidth(parsed, CompendiumPageHandler.innerWidth); if (mouseY <= y + list.size() * fontRenderer.FONT_HEIGHT) { boolean multiLine = false; int count = -1, index, prevIndex; String lineStr; for (int line = 0; line < list.size(); line++) { lineStr = list.get(line); prevIndex = -1; while ((index = lineStr.indexOf(linkColor, ++prevIndex)) != -1) { prevIndex = index; if (multiLine) multiLine = false; else ++count; int startX = x + fontRenderer.getStringWidth(lineStr.substring(0, prevIndex = index)); if ((index = lineStr.indexOf(EnumChatFormatting.BLACK.toString(), index)) == -1) { index = lineStr.length(); multiLine = true; } if (mouseY >= y + line * fontRenderer.FONT_HEIGHT && mouseY <= y + (line + 1) * fontRenderer.FONT_HEIGHT && mouseX >= startX && mouseX <= startX + fontRenderer.getStringWidth(lineStr.substring(prevIndex, index))) { fontRenderer.setUnicodeFlag(origFont); return count < parsedObjects.size() ? parsedObjects.get(count) : null; } } } } fontRenderer.setUnicodeFlag(origFont); return null; }
@SideOnly(Side.CLIENT) public void renderManaBar(IGuiLexiconEntry gui, T recipe, int mx, int my) { FontRenderer font = Minecraft.getMinecraft().fontRenderer; GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); int x = gui.getLeft() + gui.getWidth() / 2 - 50; int y = gui.getTop() + 120; boolean unicode = font.getUnicodeFlag(); font.setUnicodeFlag(true); String stopStr = StatCollector.translateToLocal("botaniamisc.shiftToStopSpin"); font.drawString(stopStr, x + 50 - font.getStringWidth(stopStr) / 2, y + 15, 0x99000000); font.setUnicodeFlag(unicode); GL11.glDisable(GL11.GL_BLEND); }