diff options
Diffstat (limited to 'src/main/java/com/thatgravyboat/skyblockhud/overlay')
4 files changed, 1221 insertions, 452 deletions
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/overlay/DungeonOverlay.java b/src/main/java/com/thatgravyboat/skyblockhud/overlay/DungeonOverlay.java index 4a3b36f..d5602ed 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/overlay/DungeonOverlay.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/overlay/DungeonOverlay.java @@ -23,128 +23,323 @@ import net.minecraftforge.client.event.RenderGameOverlayEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; public class DungeonOverlay extends Gui { - private static final FontRenderer font = Minecraft.getMinecraft().fontRendererObj; - private static boolean bossBarVisible = false; - public void drawDungeonPlayer(String name, int health, boolean isDead, Classes dungeonClass, int x, int y) { - if (!SkyblockHud.config.dungeon.hideDeadDungeonPlayers || !isDead) { - GlStateManager.enableBlend(); - Minecraft mc = Minecraft.getMinecraft(); - mc.renderEngine.bindTexture(GuiTextures.dungeon); + private static final FontRenderer font = Minecraft.getMinecraft() + .fontRendererObj; + private static boolean bossBarVisible = false; - String healthString = isDead ? "DEAD" : Integer.toString(health); - GlStateManager.color(1.0F, 1.0F, 1.0F, (float) SkyblockHud.config.dungeon.dungeonPlayerOpacity / 100); - drawTexturedModalRect(x, y, 0, dungeonClass.getTextureY(), 120, 32); - GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); - drawString(font, name, x + 50, y + 6, 0xFFFFFF); - drawString(font, healthString, x + 50, y + font.FONT_HEIGHT + 9, 0xFF2B2B); - GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); - } + public void drawDungeonPlayer( + String name, + int health, + boolean isDead, + Classes dungeonClass, + int x, + int y + ) { + if (!SkyblockHud.config.dungeon.hideDeadDungeonPlayers || !isDead) { + GlStateManager.enableBlend(); + Minecraft mc = Minecraft.getMinecraft(); + mc.renderEngine.bindTexture(GuiTextures.dungeon); + + String healthString = isDead ? "DEAD" : Integer.toString(health); + GlStateManager.color( + 1.0F, + 1.0F, + 1.0F, + (float) SkyblockHud.config.dungeon.dungeonPlayerOpacity / 100 + ); + drawTexturedModalRect(x, y, 0, dungeonClass.getTextureY(), 120, 32); + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + drawString(font, name, x + 50, y + 6, 0xFFFFFF); + drawString( + font, + healthString, + x + 50, + y + font.FONT_HEIGHT + 9, + 0xFF2B2B + ); + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); } + } - public void drawDungeonClock(int width, int offset, Minecraft mc){ - GlStateManager.enableBlend(); - GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); - mc.renderEngine.bindTexture(GuiTextures.overlay); - int dungeonTime = DungeonHandler.getDungeonTime(); - int dungeonTimeMin = dungeonTime /60; - int dungeonTimeSec = dungeonTime - dungeonTimeMin * 60; - drawTexturedModalRect((width/ 2) - 17, offset + (bossBarVisible ? 17 : 0), 0, 0, 34, 34); - mc.renderEngine.bindTexture(GuiTextures.dungeon); - drawTexturedModalRect((width/ 2) - 7, offset + (bossBarVisible ? 20 : 3), 16, 50, 3, 8); - drawTexturedModalRect((width/ 2) - 7, offset + (bossBarVisible ? 30 : 13), 19, 50, 3, 8); - String dungeonTimeElapsed = (dungeonTimeMin > 9 ? String.valueOf(dungeonTimeMin) : "0" + dungeonTimeMin) + ":" + (dungeonTimeSec > 9 ? String.valueOf(dungeonTimeSec) : "0" + dungeonTimeSec); - drawCenteredString(font, dungeonTimeElapsed, (width/ 2), offset + (bossBarVisible ? 40 : 23), 0xFFFF55); - //KEYS - drawString(font, (DungeonHandler.hasBloodkey() ? "\u2714" : "x"), (width/ 2), offset + (bossBarVisible ? 19 : 2), (DungeonHandler.hasBloodkey() ? 0x55FF55 : 0xAA0000)); - drawString(font, DungeonHandler.getWitherKeys()+"x", (width/ 2), offset + (bossBarVisible ? 30 : 13), 0x555555); - //CLEARED PERCENTAGE - GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); - mc.renderEngine.bindTexture(GuiTextures.overlay); - int clearPercent = DungeonHandler.getDungeonCleared(); - String clearPercentage = "Dungeon Cleared: \u00A7" + (clearPercent <= 20 ? "4" : clearPercent <= 50 ? "6" : clearPercent <= 80 ? "e" : "a") + clearPercent + "%"; - drawTexturedModalRect((width / 2) + 17, offset + (bossBarVisible ? 20 : 3), 2, 34, font.getStringWidth(clearPercentage) + 3, 14); - drawTexturedModalRect(((width / 2) + 17) + font.getStringWidth(clearPercentage) + 3, offset + (bossBarVisible ? 20 : 3), 252, 34, 4, 14); - drawString(font, clearPercentage, (width / 2) + 18, offset + (bossBarVisible ? 23 : 6), 0xAAAAAA); + public void drawDungeonClock(int width, int offset, Minecraft mc) { + GlStateManager.enableBlend(); + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + mc.renderEngine.bindTexture(GuiTextures.overlay); + int dungeonTime = DungeonHandler.getDungeonTime(); + int dungeonTimeMin = dungeonTime / 60; + int dungeonTimeSec = dungeonTime - dungeonTimeMin * 60; + drawTexturedModalRect( + (width / 2) - 17, + offset + (bossBarVisible ? 17 : 0), + 0, + 0, + 34, + 34 + ); + mc.renderEngine.bindTexture(GuiTextures.dungeon); + drawTexturedModalRect( + (width / 2) - 7, + offset + (bossBarVisible ? 20 : 3), + 16, + 50, + 3, + 8 + ); + drawTexturedModalRect( + (width / 2) - 7, + offset + (bossBarVisible ? 30 : 13), + 19, + 50, + 3, + 8 + ); + String dungeonTimeElapsed = + ( + dungeonTimeMin > 9 + ? String.valueOf(dungeonTimeMin) + : "0" + dungeonTimeMin + ) + + ":" + + ( + dungeonTimeSec > 9 + ? String.valueOf(dungeonTimeSec) + : "0" + dungeonTimeSec + ); + drawCenteredString( + font, + dungeonTimeElapsed, + (width / 2), + offset + (bossBarVisible ? 40 : 23), + 0xFFFF55 + ); + //KEYS + drawString( + font, + (DungeonHandler.hasBloodkey() ? "\u2714" : "x"), + (width / 2), + offset + (bossBarVisible ? 19 : 2), + (DungeonHandler.hasBloodkey() ? 0x55FF55 : 0xAA0000) + ); + drawString( + font, + DungeonHandler.getWitherKeys() + "x", + (width / 2), + offset + (bossBarVisible ? 30 : 13), + 0x555555 + ); + //CLEARED PERCENTAGE + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + mc.renderEngine.bindTexture(GuiTextures.overlay); + int clearPercent = DungeonHandler.getDungeonCleared(); + String clearPercentage = + "Dungeon Cleared: \u00A7" + + ( + clearPercent <= 20 + ? "4" + : clearPercent <= 50 ? "6" : clearPercent <= 80 ? "e" : "a" + ) + + clearPercent + + "%"; + drawTexturedModalRect( + (width / 2) + 17, + offset + (bossBarVisible ? 20 : 3), + 2, + 34, + font.getStringWidth(clearPercentage) + 3, + 14 + ); + drawTexturedModalRect( + ((width / 2) + 17) + font.getStringWidth(clearPercentage) + 3, + offset + (bossBarVisible ? 20 : 3), + 252, + 34, + 4, + 14 + ); + drawString( + font, + clearPercentage, + (width / 2) + 18, + offset + (bossBarVisible ? 23 : 6), + 0xAAAAAA + ); - //DEATHS - GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); - mc.renderEngine.bindTexture(GuiTextures.overlay); - int deaths = DungeonHandler.getDeaths(); - String deathText = "Deaths: " + deaths; - drawTexturedModalRect((width / 2) + 17, offset + (bossBarVisible ? 35 : 18), 2, 34, font.getStringWidth(deathText) + 3, 14); - drawTexturedModalRect(((width / 2) + 17) + font.getStringWidth(deathText) + 3, offset + (bossBarVisible ? 35 : 18), 252, 34, 4, 14); - drawString(font, deathText, (width / 2) + 18, offset + (bossBarVisible ? 38 : 21), 0xAAAAAA); + //DEATHS + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + mc.renderEngine.bindTexture(GuiTextures.overlay); + int deaths = DungeonHandler.getDeaths(); + String deathText = "Deaths: " + deaths; + drawTexturedModalRect( + (width / 2) + 17, + offset + (bossBarVisible ? 35 : 18), + 2, + 34, + font.getStringWidth(deathText) + 3, + 14 + ); + drawTexturedModalRect( + ((width / 2) + 17) + font.getStringWidth(deathText) + 3, + offset + (bossBarVisible ? 35 : 18), + 252, + 34, + 4, + 14 + ); + drawString( + font, + deathText, + (width / 2) + 18, + offset + (bossBarVisible ? 38 : 21), + 0xAAAAAA + ); - //SECRETS - GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); - mc.renderEngine.bindTexture(GuiTextures.overlay); - int maxSecrets = DungeonHandler.getMaxSecrets(); - int secrets = DungeonHandler.getSecrets(); - int totalSecrets = DungeonHandler.getTotalSecrets(); - String secretsText = "Secrets: " + secrets + "/" + maxSecrets + " (" + totalSecrets + ")"; - drawTexturedModalRect((width/ 2) - 17 - (font.getStringWidth(secretsText)) - 4, offset + (bossBarVisible ? 20 : 3), 0, 34, 2, 14); - drawTexturedModalRect(((width/ 2) - 17 - (font.getStringWidth(secretsText))) - 2, offset + (bossBarVisible ? 20 : 3), 2, 34, font.getStringWidth(secretsText) + 2, 14); - drawString(font, secretsText, (width/ 2) - 17 - (font.getStringWidth(secretsText)) , offset + (bossBarVisible ? 23 : 6), 0xAAAAAA); + //SECRETS + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + mc.renderEngine.bindTexture(GuiTextures.overlay); + int maxSecrets = DungeonHandler.getMaxSecrets(); + int secrets = DungeonHandler.getSecrets(); + int totalSecrets = DungeonHandler.getTotalSecrets(); + String secretsText = + "Secrets: " + secrets + "/" + maxSecrets + " (" + totalSecrets + ")"; + drawTexturedModalRect( + (width / 2) - 17 - (font.getStringWidth(secretsText)) - 4, + offset + (bossBarVisible ? 20 : 3), + 0, + 34, + 2, + 14 + ); + drawTexturedModalRect( + ((width / 2) - 17 - (font.getStringWidth(secretsText))) - 2, + offset + (bossBarVisible ? 20 : 3), + 2, + 34, + font.getStringWidth(secretsText) + 2, + 14 + ); + drawString( + font, + secretsText, + (width / 2) - 17 - (font.getStringWidth(secretsText)), + offset + (bossBarVisible ? 23 : 6), + 0xAAAAAA + ); - //CRYPTS - GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); - mc.renderEngine.bindTexture(GuiTextures.overlay); - int crypts = DungeonHandler.getCrypts(); - String cryptText = "Crypts: " + crypts; - drawTexturedModalRect((width/ 2) - 17 - (font.getStringWidth(cryptText)) - 4, offset + (bossBarVisible ? 35 : 18), 0, 34, 2, 14); - drawTexturedModalRect(((width/ 2) - 17 - (font.getStringWidth(cryptText))) - 2, offset + (bossBarVisible ? 35 : 18), 2, 34, font.getStringWidth(cryptText) + 2, 14); - drawString(font, cryptText, (width/ 2) - 17 - (font.getStringWidth(cryptText)) , offset + (bossBarVisible ? 38 : 21), 0xAAAAAA); - } + //CRYPTS + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + mc.renderEngine.bindTexture(GuiTextures.overlay); + int crypts = DungeonHandler.getCrypts(); + String cryptText = "Crypts: " + crypts; + drawTexturedModalRect( + (width / 2) - 17 - (font.getStringWidth(cryptText)) - 4, + offset + (bossBarVisible ? 35 : 18), + 0, + 34, + 2, + 14 + ); + drawTexturedModalRect( + ((width / 2) - 17 - (font.getStringWidth(cryptText))) - 2, + offset + (bossBarVisible ? 35 : 18), + 2, + 34, + font.getStringWidth(cryptText) + 2, + 14 + ); + drawString( + font, + cryptText, + (width / 2) - 17 - (font.getStringWidth(cryptText)), + offset + (bossBarVisible ? 38 : 21), + 0xAAAAAA + ); + } - public void drawUltimateBar(Minecraft mc, ScaledResolution resolution){ - if (!SkyblockHud.config.dungeon.hideUltimateBar) { - float percentage = mc.thePlayer.experience; - SBHConfig.DungeonHud dungeonHud = SkyblockHud.config.dungeon; - Position position = dungeonHud.barPosition; + public void drawUltimateBar(Minecraft mc, ScaledResolution resolution) { + if (!SkyblockHud.config.dungeon.hideUltimateBar) { + float percentage = mc.thePlayer.experience; + SBHConfig.DungeonHud dungeonHud = SkyblockHud.config.dungeon; + Position position = dungeonHud.barPosition; - int x = position.getAbsX(resolution, 182); - int y = position.getAbsY(resolution, 5); + int x = position.getAbsX(resolution, 182); + int y = position.getAbsY(resolution, 5); - GenericOverlays.drawLargeBar(mc, - x - 91, y, - percentage, 0.999f, - SpecialColour.specialToChromaRGB(dungeonHud.barLoadColor), - SpecialColour.specialToChromaRGB(dungeonHud.barFullColor), - dungeonHud.barStyle); - } + GenericOverlays.drawLargeBar( + mc, + x - 91, + y, + percentage, + 0.999f, + SpecialColour.specialToChromaRGB(dungeonHud.barLoadColor), + SpecialColour.specialToChromaRGB(dungeonHud.barFullColor), + dungeonHud.barStyle + ); } + } - @SubscribeEvent - public void renderOverlay(RenderGameOverlayEvent.Post event) { - Minecraft mc = Minecraft.getMinecraft(); - if (Utils.overlayShouldRender(event.type, SkyblockHud.hasSkyblockScoreboard(), LocationHandler.getCurrentLocation().equals(Locations.CATACOMBS))) { - bossBarVisible = BossStatus.statusBarTime > 0 && GuiIngameForge.renderBossHealth && BossbarHandler.bossBarRendered; - GlStateManager.enableBlend(); - drawUltimateBar(mc, event.resolution); + @SubscribeEvent + public void renderOverlay(RenderGameOverlayEvent.Post event) { + Minecraft mc = Minecraft.getMinecraft(); + if ( + Utils.overlayShouldRender( + event.type, + SkyblockHud.hasSkyblockScoreboard(), + LocationHandler.getCurrentLocation().equals(Locations.CATACOMBS) + ) + ) { + bossBarVisible = + BossStatus.statusBarTime > 0 && + GuiIngameForge.renderBossHealth && + BossbarHandler.bossBarRendered; + GlStateManager.enableBlend(); + drawUltimateBar(mc, event.resolution); - GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); - if (!SkyblockHud.config.dungeon.hideDungeonPlayers) { - int[] hardCodedPos = new int[]{5, 42, 79, 116}; - Position[] positions = new Position[]{SkyblockHud.config.dungeon.dungeonPlayer1, SkyblockHud.config.dungeon.dungeonPlayer2, SkyblockHud.config.dungeon.dungeonPlayer3, SkyblockHud.config.dungeon.dungeonPlayer4}; - for (int i = 0; i < Math.min(DungeonHandler.getDungeonPlayers().values().size(), 4); i++) { - DungeonPlayer player = (DungeonPlayer) DungeonHandler.getDungeonPlayers().values().toArray()[i]; - int posX; - int posY; - try { - posX = positions[i].getAbsX(event.resolution, 120); - } catch (ArrayIndexOutOfBoundsException ignored) { - posX = hardCodedPos[i]; - } - try { - posY = positions[i].getAbsY(event.resolution, 120); - } catch (ArrayIndexOutOfBoundsException ignored) { - posY = 0; - } - drawDungeonPlayer(player.getName(), player.getHealth(), player.isDead(), player.getDungeonClass(), posX, posY); - } - } - drawDungeonClock(event.resolution.getScaledWidth(), SkyblockHud.config.main.mainHudPos.getAbsY(event.resolution, 34), mc); + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + if (!SkyblockHud.config.dungeon.hideDungeonPlayers) { + int[] hardCodedPos = new int[] { 5, 42, 79, 116 }; + Position[] positions = new Position[] { + SkyblockHud.config.dungeon.dungeonPlayer1, + SkyblockHud.config.dungeon.dungeonPlayer2, + SkyblockHud.config.dungeon.dungeonPlayer3, + SkyblockHud.config.dungeon.dungeonPlayer4 + }; + for ( + int i = 0; + i < Math.min(DungeonHandler.getDungeonPlayers().values().size(), 4); + i++ + ) { + DungeonPlayer player = (DungeonPlayer) DungeonHandler + .getDungeonPlayers() + .values() + .toArray()[i]; + int posX; + int posY; + try { + posX = positions[i].getAbsX(event.resolution, 120); + } catch (ArrayIndexOutOfBoundsException ignored) { + posX = hardCodedPos[i]; + } + try { + posY = positions[i].getAbsY(event.resolution, 120); + } catch (ArrayIndexOutOfBoundsException ignored) { + posY = 0; + } + drawDungeonPlayer( + player.getName(), + player.getHealth(), + player.isDead(), + player.getDungeonClass(), + posX, + posY + ); } + } + drawDungeonClock( + event.resolution.getScaledWidth(), + SkyblockHud.config.main.mainHudPos.getAbsY(event.resolution, 34), + mc + ); } + } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/overlay/GenericOverlays.java b/src/main/java/com/thatgravyboat/skyblockhud/overlay/GenericOverlays.java index d987c86..8cff166 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/overlay/GenericOverlays.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/overlay/GenericOverlays.java @@ -3,42 +3,82 @@ package com.thatgravyboat.skyblockhud.overlay; import com.thatgravyboat.skyblockhud.GuiTextures; import com.thatgravyboat.skyblockhud.SkyblockHud; import com.thatgravyboat.skyblockhud.core.util.render.RenderUtils; +import java.awt.Color; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Gui; import net.minecraft.client.renderer.GlStateManager; -import java.awt.Color; - - public class GenericOverlays extends Gui { - public static void drawLargeBar(Minecraft mc, int x, int y, float percentage, float max, int fullColor, int loadingColor, int barStyle){ - if (SkyblockHud.hasSkyblockScoreboard()) { - mc.renderEngine.bindTexture(GuiTextures.bars); - Color color = new Color(percentage == max ? fullColor : loadingColor); + public static void drawLargeBar( + Minecraft mc, + int x, + int y, + float percentage, + float max, + int fullColor, + int loadingColor, + int barStyle + ) { + if (SkyblockHud.hasSkyblockScoreboard()) { + mc.renderEngine.bindTexture(GuiTextures.bars); + Color color = new Color(percentage == max ? fullColor : loadingColor); - RenderUtils.drawTexturedModalRect(x, y, 0, 0, 182, 5); - GlStateManager.color(color.getRed() / 255f, color.getGreen() / 255f, color.getBlue() / 255f, color.getAlpha() / 255f); - RenderUtils.drawTexturedModalRect(x, y, 0, 30, 182, 5); - RenderUtils.drawTexturedModalRect(x, y, 0, 5, (int) (182 * percentage), 5); - if (barStyle != 0) { - RenderUtils.drawTexturedModalRect(x, y, 0, 5 + (barStyle * 5), 182, 5); - } - } + RenderUtils.drawTexturedModalRect(x, y, 0, 0, 182, 5); + GlStateManager.color( + color.getRed() / 255f, + color.getGreen() / 255f, + color.getBlue() / 255f, + color.getAlpha() / 255f + ); + RenderUtils.drawTexturedModalRect(x, y, 0, 30, 182, 5); + RenderUtils.drawTexturedModalRect( + x, + y, + 0, + 5, + (int) (182 * percentage), + 5 + ); + if (barStyle != 0) { + RenderUtils.drawTexturedModalRect(x, y, 0, 5 + (barStyle * 5), 182, 5); + } } + } - public static void drawSmallBar(Minecraft mc, int x, int y, double percentage, double max, int fullColor, int loadingColor, int barStyle){ - if (SkyblockHud.hasSkyblockScoreboard()) { - mc.renderEngine.bindTexture(GuiTextures.bars); - Color color = new Color(percentage == max ? fullColor : loadingColor); - GlStateManager.enableBlend(); - RenderUtils.drawTexturedModalRect(x, y, 0, 35, 62, 5); - GlStateManager.color(color.getRed() / 255f, color.getGreen() / 255f, color.getBlue() / 255f, color.getAlpha() / 255f); - RenderUtils.drawTexturedModalRect(x, y, 0, 65, 62, 5); - RenderUtils.drawTexturedModalRect(x, y, 0, 40, (int) (62 * percentage), 5); - if (barStyle != 0) { - RenderUtils.drawTexturedModalRect(x, y, 0, 45 + (barStyle * 5), 62, 5); - } - } + public static void drawSmallBar( + Minecraft mc, + int x, + int y, + double percentage, + double max, + int fullColor, + int loadingColor, + int barStyle + ) { + if (SkyblockHud.hasSkyblockScoreboard()) { + mc.renderEngine.bindTexture(GuiTextures.bars); + Color color = new Color(percentage == max ? fullColor : loadingColor); + GlStateManager.enableBlend(); + RenderUtils.drawTexturedModalRect(x, y, 0, 35, 62, 5); + GlStateManager.color( + color.getRed() / 255f, + color.getGreen() / 255f, + color.getBlue() / 255f, + color.getAlpha() / 255f + ); + RenderUtils.drawTexturedModalRect(x, y, 0, 65, 62, 5); + RenderUtils.drawTexturedModalRect( + x, + y, + 0, + 40, + (int) (62 * percentage), + 5 + ); + if (barStyle != 0) { + RenderUtils.drawTexturedModalRect(x, y, 0, 45 + (barStyle * 5), 62, 5); + } } + } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/overlay/OverlayHud.java b/src/main/java/com/thatgravyboat/skyblockhud/overlay/OverlayHud.java index 8cdd44c..1b0614d 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/overlay/OverlayHud.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/overlay/OverlayHud.java @@ -8,8 +8,11 @@ import com.thatgravyboat.skyblockhud.handlers.CurrencyHandler; import com.thatgravyboat.skyblockhud.handlers.SlayerHandler; import com.thatgravyboat.skyblockhud.handlers.TimeHandler; import com.thatgravyboat.skyblockhud.location.*; -import com.thatgravyboat.skyblockhud.seasons.SeasonDateHandler; import com.thatgravyboat.skyblockhud.seasons.Season; +import com.thatgravyboat.skyblockhud.seasons.SeasonDateHandler; +import java.text.DecimalFormat; +import java.text.DecimalFormatSymbols; +import java.util.Locale; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.Gui; @@ -20,267 +23,711 @@ import net.minecraftforge.client.GuiIngameForge; import net.minecraftforge.client.event.RenderGameOverlayEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import java.text.DecimalFormat; -import java.text.DecimalFormatSymbols; -import java.util.Locale; - public class OverlayHud extends Gui { - private static final FontRenderer font = Minecraft.getMinecraft().fontRendererObj; - - //STATS - private static boolean eventToggle; - public static boolean bossBarVisible = false; + private static final FontRenderer font = Minecraft.getMinecraft() + .fontRendererObj; - public void drawClock(int width, int offset, Minecraft mc){ - GlStateManager.enableBlend(); - GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); - mc.renderEngine.bindTexture(GuiTextures.overlay); - //CLOCK - int timeMin = (int) (TimeHandler.time / 60); - int timeHour = timeMin / 60; - timeMin = timeMin - (timeHour * 60); - String militaryTime = timeHour + ":" + (timeMin == 0 ? timeMin + "0" : timeMin); - int time12Hour = timeHour >= 12 ? timeHour - 12 : timeHour; - String normalTime = (time12Hour == 0 ? "00" : String.valueOf(time12Hour)) + ":" + (timeMin == 0 ? "00" : timeMin) + (timeHour >= 12 ? "pm" : "am"); + //STATS + private static boolean eventToggle; - drawTexturedModalRect((width/ 2) - 17, offset + (bossBarVisible ? 17 : 0), 0, 0, 34, 34); - drawTexturedModalRect((width/ 2) - 4, offset + (bossBarVisible ? 24 : 7), (timeHour > 19 || timeHour < 4) ? 43 : 43 + 8, 0, 8, 8); - if (SkyblockHud.config.main.twelveHourClock) drawScaledString(0.8f, width/ 2, offset + (bossBarVisible ? 38 : 21), normalTime, (timeHour > 19 || timeHour < 4) ? 0xAFB8CC : 0xFFFF55); - else drawCenteredString(font, militaryTime, (width/ 2), offset + (bossBarVisible ? 38 : 21), (timeHour > 19 || timeHour < 4) ? 0xAFB8CC : 0xFFFF55); + public static boolean bossBarVisible = false; - //PURSE - drawPurseAndBits(width, offset, mc); + public void drawClock(int width, int offset, Minecraft mc) { + GlStateManager.enableBlend(); + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + mc.renderEngine.bindTexture(GuiTextures.overlay); + //CLOCK + int timeMin = (int) (TimeHandler.time / 60); + int timeHour = timeMin / 60; + timeMin = timeMin - (timeHour * 60); + String militaryTime = + timeHour + ":" + (timeMin == 0 ? timeMin + "0" : timeMin); + int time12Hour = timeHour >= 12 ? timeHour - 12 : timeHour; + String normalTime = + (time12Hour == 0 ? "00" : String.valueOf(time12Hour)) + + ":" + + (timeMin == 0 ? "00" : timeMin) + + (timeHour >= 12 ? "pm" : "am"); - //SEASON/DATE - drawSeasonAndDate(width, offset, mc); + drawTexturedModalRect( + (width / 2) - 17, + offset + (bossBarVisible ? 17 : 0), + 0, + 0, + 34, + 34 + ); + drawTexturedModalRect( + (width / 2) - 4, + offset + (bossBarVisible ? 24 : 7), + (timeHour > 19 || timeHour < 4) ? 43 : 43 + 8, + 0, + 8, + 8 + ); + if (SkyblockHud.config.main.twelveHourClock) drawScaledString( + 0.8f, + width / 2, + offset + (bossBarVisible ? 38 : 21), + normalTime, + (timeHour > 19 || timeHour < 4) ? 0xAFB8CC : 0xFFFF55 + ); else drawCenteredString( + font, + militaryTime, + (width / 2), + offset + (bossBarVisible ? 38 : 21), + (timeHour > 19 || timeHour < 4) ? 0xAFB8CC : 0xFFFF55 + ); - //REDSTONE PERCENT - drawRedstone(width, offset, mc); + //PURSE + drawPurseAndBits(width, offset, mc); - // LOCATION - drawLocation(width, offset, mc); + //SEASON/DATE + drawSeasonAndDate(width, offset, mc); - //EXTRA SLOT - if (LocationHandler.getCurrentLocation().equals(Locations.YOURISLAND)) { - if (IslandHandler.flightTime > 0) drawFlightDuration(width, offset, mc); - } - else if (LocationHandler.getCurrentLocation().getCategory().equals(LocationCategory.MUSHROOMDESERT)){ - drawTrapperOrPelts(width, offset, mc); - } - else if (LocationHandler.getCurrentLocation().getCategory().equals(LocationCategory.DWARVENMINES)) { - if (DwarvenMineHandler.currentEvent != DwarvenMineHandler.Event.NONE){ - drawDwarvenEvent(width, offset, mc); - }else { - drawMithril(width, offset, mc); - } - } - else if (LocationHandler.getCurrentLocation().getCategory().equals(LocationCategory.PARK) && ParkIslandHandler.isRaining()){ - if (LocationHandler.getCurrentLocation().equals(Locations.HOWLINGCAVE)){ - drawSlayer(width, offset, mc); - }else drawRainDuration(width, offset, mc); - }else if (SlayerHandler.isDoingSlayer){ - drawSlayer(width, offset, mc); - } - } + //REDSTONE PERCENT + drawRedstone(width, offset, mc); - public void drawSeasonAndDate(int width, int offset, Minecraft mc){ - if (SeasonDateHandler.getCurrentSeason() != Season.ERROR) { - GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); - if (mc.thePlayer.ticksExisted % 100 == 0 && eventToggle) eventToggle = false; - if (mc.thePlayer.ticksExisted % 600 == 0) eventToggle = true; - mc.renderEngine.bindTexture(GuiTextures.overlay); - String dateText = SeasonDateHandler.getFancySeasonAndDate(); - if (eventToggle && !SeasonDateHandler.getCurrentEvent().isEmpty() && !SeasonDateHandler.getCurrentEventTime().isEmpty()) dateText = SeasonDateHandler.getCurrentEvent().trim() + " " + SeasonDateHandler.getCurrentEventTime().trim(); - drawTexturedModalRect((width / 2) + 17, offset + (bossBarVisible ? 20 : 3), 2, 34, font.getStringWidth(dateText) + 9, 14); - drawTexturedModalRect(((width / 2) + 17) + font.getStringWidth(dateText) + 9, offset + (bossBarVisible ? 20 : 3), 252, 34, 4, 14); - drawTexturedModalRect(((width / 2) + 17) + font.getStringWidth(dateText) + 2, offset + (bossBarVisible ? 23 : 6), SeasonDateHandler.getCurrentSeason().getTextureX(), 16, 8, 8); - drawString(font, dateText, (width / 2) + 18, offset + (bossBarVisible ? 23 : 6), 0xffffff); - } - } - - public void drawLocation(int width, int offset, Minecraft mc){ - GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); - mc.renderEngine.bindTexture(GuiTextures.overlay); - drawTexturedModalRect((width/ 2) - 33 - (font.getStringWidth(LocationHandler.getCurrentLocation().getDisplayName())), offset + (bossBarVisible ? 20 : 3), 0, 34, 2, 14); - drawTexturedModalRect(((width/ 2) - 33 - (font.getStringWidth(LocationHandler.getCurrentLocation().getDisplayName()))) + 2, offset + (bossBarVisible ? 20 : 3), 2, 34, font.getStringWidth(LocationHandler.getCurrentLocation().getDisplayName()) + 14, 14); - drawTexturedModalRect(((width/ 2) - 33 - (font.getStringWidth(LocationHandler.getCurrentLocation().getDisplayName()))) + 4, offset + (bossBarVisible ? 23 : 6), LocationHandler.getCurrentLocation().getCategory().getTexturePos(), 8, 8, 8); - drawString(font, - LocationHandler.getCurrentLocation().getDisplayName(), - (width/ 2) - 19 - (font.getStringWidth(LocationHandler.getCurrentLocation().getDisplayName())) , - offset + (bossBarVisible ? 23 : 6), - 0xFFFFFF - ); - } + // LOCATION + drawLocation(width, offset, mc); - public void drawRedstone(int width, int offset, Minecraft mc){ - GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); - mc.renderEngine.bindTexture(GuiTextures.overlay); - int redstoneColor = IslandHandler.redstone > 90 ? 0xFF0000 : IslandHandler.redstone > 75 ? 0xC45B00 : IslandHandler.redstone > 50 ? 0xFFFF55 : 0x55FF55; - if (IslandHandler.redstone > 0 && Utils.isPlayerHoldingRedstone(mc.thePlayer)) { - drawTexturedModalRect((width/ 2) - 15, offset + (bossBarVisible ? 51 : 34), 0, 48, 30, 18); - drawTexturedModalRect((width/ 2) - 4, offset + (bossBarVisible ? 51 : 34), 59, 0, 8, 8); - drawCenteredString(mc.fontRendererObj, IslandHandler.redstone+"%", (width/ 2), offset + (bossBarVisible ? 58 : 41), redstoneColor); - } + //EXTRA SLOT + if (LocationHandler.getCurrentLocation().equals(Locations.YOURISLAND)) { + if (IslandHandler.flightTime > 0) drawFlightDuration(width, offset, mc); + } else if ( + LocationHandler + .getCurrentLocation() + .getCategory() + .equals(LocationCategory.MUSHROOMDESERT) + ) { + drawTrapperOrPelts(width, offset, mc); + } else if ( + LocationHandler + .getCurrentLocation() + .getCategory() + .equals(LocationCategory.DWARVENMINES) + ) { + if (DwarvenMineHandler.currentEvent != DwarvenMineHandler.Event.NONE) { + drawDwarvenEvent(width, offset, mc); + } else { + drawMithril(width, offset, mc); + } + } else if ( + LocationHandler + .getCurrentLocation() + .getCategory() + .equals(LocationCategory.PARK) && + ParkIslandHandler.isRaining() + ) { + if (LocationHandler.getCurrentLocation().equals(Locations.HOWLINGCAVE)) { + drawSlayer(width, offset, mc); + } else drawRainDuration(width, offset, mc); + } else if (SlayerHandler.isDoingSlayer) { + drawSlayer(width, offset, mc); } + } - public void drawPurseAndBits(int width, int offset, Minecraft mc){ - GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); - mc.renderEngine.bindTexture(GuiTextures.overlay); - int xPos = (width/ 2) + 17; - - //COINS - drawTexturedModalRect(xPos, offset + (bossBarVisible ? 35 : 18), 2, 34, font.getStringWidth(CurrencyHandler.getCoinsFormatted()) + 11, 14); - drawTexturedModalRect(xPos + 1, offset + (bossBarVisible ? 37 : 20), 34, 0, 8, 8); - drawString(font, CurrencyHandler.getCoinsFormatted(), xPos + 10, offset + (bossBarVisible ? 38 : 21), 0xFFAA00); - GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); - mc.renderEngine.bindTexture(GuiTextures.overlay); - xPos += font.getStringWidth(CurrencyHandler.getCoinsFormatted()) + 11; + public void drawSeasonAndDate(int width, int offset, Minecraft mc) { + if (SeasonDateHandler.getCurrentSeason() != Season.ERROR) { + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + if (mc.thePlayer.ticksExisted % 100 == 0 && eventToggle) eventToggle = + false; + if (mc.thePlayer.ticksExisted % 600 == 0) eventToggle = true; + mc.renderEngine.bindTexture(GuiTextures.overlay); + String dateText = SeasonDateHandler.getFancySeasonAndDate(); + if ( + eventToggle && + !SeasonDateHandler.getCurrentEvent().isEmpty() && + !SeasonDateHandler.getCurrentEventTime().isEmpty() + ) dateText = + SeasonDateHandler.getCurrentEvent().trim() + + " " + + SeasonDateHandler.getCurrentEventTime().trim(); + drawTexturedModalRect( + (width / 2) + 17, + offset + (bossBarVisible ? 20 : 3), + 2, + 34, + font.getStringWidth(dateText) + 9, + 14 + ); + drawTexturedModalRect( + ((width / 2) + 17) + font.getStringWidth(dateText) + 9, + offset + (bossBarVisible ? 20 : 3), + 252, + 34, + 4, + 14 + ); + drawTexturedModalRect( + ((width / 2) + 17) + font.getStringWidth(dateText) + 2, + offset + (bossBarVisible ? 23 : 6), + SeasonDateHandler.getCurrentSeason().getTextureX(), + 16, + 8, + 8 + ); + drawString( + font, + dateText, + (width / 2) + 18, + offset + (bossBarVisible ? 23 : 6), + 0xffffff + ); + } + } - //BITS - if (CurrencyHandler.getBits() > 0) { - drawTexturedModalRect(xPos, offset + (bossBarVisible ? 35 : 18), 2, 34, font.getStringWidth(CurrencyHandler.getBitsFormatted()) + 11, 14); - drawTexturedModalRect(xPos + 1, offset + (bossBarVisible ? 37 : 20), 75, 0, 8, 8); - drawString(font, CurrencyHandler.getBitsFormatted(), xPos + 10, offset + (bossBarVisible ? 38 : 21), 0x55FFFF); - GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); - mc.renderEngine.bindTexture(GuiTextures.overlay); - xPos += font.getStringWidth(CurrencyHandler.getBitsFormatted()) + 11; - } + public void drawLocation(int width, int offset, Minecraft mc) { + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + mc.renderEngine.bindTexture(GuiTextures.overlay); + drawTexturedModalRect( + (width / 2) - + 33 - + ( + font.getStringWidth( + LocationHandler.getCurrentLocation().getDisplayName() + ) + ), + offset + (bossBarVisible ? 20 : 3), + 0, + 34, + 2, + 14 + ); + drawTexturedModalRect( + ( + (width / 2) - + 33 - + ( + font.getStringWidth( + LocationHandler.getCurrentLocation().getDisplayName() + ) + ) + ) + + 2, + offset + (bossBarVisible ? 20 : 3), + 2, + 34, + font.getStringWidth( + LocationHandler.getCurrentLocation().getDisplayName() + ) + + 14, + 14 + ); + drawTexturedModalRect( + ( + (width / 2) - + 33 - + ( + font.getStringWidth( + LocationHandler.getCurrentLocation().getDisplayName() + ) + ) + ) + + 4, + offset + (bossBarVisible ? 23 : 6), + LocationHandler.getCurrentLocation().getCategory().getTexturePos(), + 8, + 8, + 8 + ); + drawString( + font, + LocationHandler.getCurrentLocation().getDisplayName(), + (width / 2) - + 19 - + ( + font.getStringWidth( + LocationHandler.getCurrentLocation().getDisplayName() + ) + ), + offset + (bossBarVisible ? 23 : 6), + 0xFFFFFF + ); + } - drawTexturedModalRect(xPos, offset + (bossBarVisible ? 35 : 18), 252, 34, 4, 14); + public void drawRedstone(int width, int offset, Minecraft mc) { + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + mc.renderEngine.bindTexture(GuiTextures.overlay); + int redstoneColor = IslandHandler.redstone > 90 + ? 0xFF0000 + : IslandHandler.redstone > 75 + ? 0xC45B00 + : IslandHandler.redstone > 50 ? 0xFFFF55 : 0x55FF55; + if ( + IslandHandler.redstone > 0 && Utils.isPlayerHoldingRedstone(mc.thePlayer) + ) { + drawTexturedModalRect( + (width / 2) - 15, + offset + (bossBarVisible ? 51 : 34), + 0, + 48, + 30, + 18 + ); + drawTexturedModalRect( + (width / 2) - 4, + offset + (bossBarVisible ? 51 : 34), + 59, + 0, + 8, + 8 + ); + drawCenteredString( + mc.fontRendererObj, + IslandHandler.redstone + "%", + (width / 2), + offset + (bossBarVisible ? 58 : 41), + redstoneColor + ); } + } - public void drawFlightDuration(int width, int offset, Minecraft mc ){ - if (LocationHandler.getCurrentLocation().equals(Locations.YOURISLAND)){ - GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); - DecimalFormat flightFormat = new DecimalFormat("#.#", DecimalFormatSymbols.getInstance(Locale.CANADA)); - String duration; - if (IslandHandler.flightTime < 60) duration = IslandHandler.flightTime + "s"; - else if (IslandHandler.flightTime < 3600) duration = flightFormat.format((double)IslandHandler.flightTime / 60) + "m"; - else if (IslandHandler.flightTime < 86400) duration = flightFormat.format((double)IslandHandler.flightTime / 3600) + "hr"; - else if (IslandHandler.flightTime < 86460) duration = flightFormat.format((double)IslandHandler.flightTime / 86400) + "day"; - else duration = flightFormat.format((double)IslandHandler.flightTime / 86400) + "days"; - mc.renderEngine.bindTexture(GuiTextures.overlay); - drawTexturedModalRect((width/ 2) - 33 - (font.getStringWidth(duration)), offset + (bossBarVisible ? 35 : 18), 0, 34, 2, 14); - drawTexturedModalRect(((width/ 2) - 33 - (font.getStringWidth(duration))) + 2, offset + (bossBarVisible ? 35 : 18), 2, 34, font.getStringWidth(duration) + 14, 14); - drawTexturedModalRect(((width/ 2) - 33 - (font.getStringWidth(duration))) + 4, offset + (bossBarVisible ? 38 : 21), 67, 0, 8, 8); - drawString(font, duration, (width/ 2) - 19 - (font.getStringWidth(duration)) , offset + (bossBarVisible ? 38 : 21), 0xFFFFFF); - } - } + public void drawPurseAndBits(int width, int offset, Minecraft mc) { + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + mc.renderEngine.bindTexture(GuiTextures.overlay); + int xPos = (width / 2) + 17; - public void drawRainDuration(int width, int offset, Minecraft mc ){ - if (LocationHandler.getCurrentLocation().getCategory().equals(LocationCategory.PARK)){ - GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); - mc.renderEngine.bindTexture(GuiTextures.overlay); - String duration = "Rain: " + ParkIslandHandler.getRainTime(); - drawTexturedModalRect((width/ 2) - 33 - (font.getStringWidth(duration)), offset + (bossBarVisible ? 35 : 18), 0, 34, 2, 14); - drawTexturedModalRect(((width/ 2) - 33 - (font.getStringWidth(duration))) + 2, offset + (bossBarVisible ? 35 : 18), 2, 34, font.getStringWidth(duration) + 14, 14); - drawTexturedModalRect(((width/ 2) - 33 - (font.getStringWidth(duration))) + 4, offset + (bossBarVisible ? 38 : 21), 83, 0, 8, 8); - drawString(font, duration, (width/ 2) - 19 - (font.getStringWidth(duration)) , offset + (bossBarVisible ? 38 : 21), 0xFFFFFF); - } + //COINS + drawTexturedModalRect( + xPos, + offset + (bossBarVisible ? 35 : 18), + 2, + 34, + font.getStringWidth(CurrencyHandler.getCoinsFormatted()) + 11, + 14 + ); + drawTexturedModalRect( + xPos + 1, + offset + (bossBarVisible ? 37 : 20), + 34, + 0, + 8, + 8 + ); + drawString( + font, + CurrencyHandler.getCoinsFormatted(), + xPos + 10, + offset + (bossBarVisible ? 38 : 21), + 0xFFAA00 + ); + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + mc.renderEngine.bindTexture(GuiTextures.overlay); + xPos += font.getStringWidth(CurrencyHandler.getCoinsFormatted()) + 11; + + //BITS + if (CurrencyHandler.getBits() > 0) { + drawTexturedModalRect( + xPos, + offset + (bossBarVisible ? 35 : 18), + 2, + 34, + font.getStringWidth(CurrencyHandler.getBitsFormatted()) + 11, + 14 + ); + drawTexturedModalRect( + xPos + 1, + offset + (bossBarVisible ? 37 : 20), + 75, + 0, + 8, + 8 + ); + drawString( + font, + CurrencyHandler.getBitsFormatted(), + xPos + 10, + offset + (bossBarVisible ? 38 : 21), + 0x55FFFF + ); + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + mc.renderEngine.bindTexture(GuiTextures.overlay); + xPos += font.getStringWidth(CurrencyHandler.getBitsFormatted()) + 11; } - public void drawSlayer(int width, int offset, Minecraft mc){ - if (SlayerHandler.isDoingSlayer){ - int kills = SlayerHandler.progress; - int maxKills = SlayerHandler.maxKills; - int tier = SlayerHandler.slayerTier; - SlayerHandler.slayerTypes slayerType = SlayerHandler.currentSlayer; - if (slayerType != SlayerHandler.slayerTypes.NONE) { - GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); - mc.renderEngine.bindTexture(GuiTextures.overlay); - StringBuilder stringBuilder = new StringBuilder(); - stringBuilder.append(EnumChatFormatting.GREEN); - stringBuilder.append(Utils.intToRomanNumeral(tier)); - stringBuilder.append(" "); - if (SlayerHandler.isKillingBoss){ - stringBuilder.append(EnumChatFormatting.RED); - stringBuilder.append("Slay Boss!"); - } else if (SlayerHandler.bossSlain){ - stringBuilder.append(EnumChatFormatting.RED); - stringBuilder.append("Boss Slain!"); - } else if (kills == 0 && maxKills == 0){ - stringBuilder.append(EnumChatFormatting.RED); - stringBuilder.append("Not Slaying!"); - } else { - stringBuilder.append(EnumChatFormatting.YELLOW); - stringBuilder.append(kills); - stringBuilder.append(EnumChatFormatting.GRAY); - stringBuilder.append("/"); - stringBuilder.append(EnumChatFormatting.RED); - stringBuilder.append(maxKills); - } - String text = stringBuilder.toString(); - drawTexturedModalRect((width / 2) - 33 - (font.getStringWidth(text)), offset + (bossBarVisible ? 35 : 18), 0, 34, 2, 14); - drawTexturedModalRect(((width / 2) - 33 - (font.getStringWidth(text))) + 2, offset + (bossBarVisible ? 35 : 18), 2, 34, font.getStringWidth(text) + 14, 14); - drawTexturedModalRect(((width / 2) - 33 - (font.getStringWidth(text))) + 4, offset + (bossBarVisible ? 38 : 21), slayerType.getX(), 24, 8, 8); - drawString(font, text, (width / 2) - 19 - (font.getStringWidth(text)), offset + (bossBarVisible ? 38 : 21), 0xFFFFFF); + drawTexturedModalRect( + xPos, + offset + (bossBarVisible ? 35 : 18), + 252, + 34, + 4, + 14 + ); + } - } - } + public void drawFlightDuration(int width, int offset, Minecraft mc) { + if (LocationHandler.getCurrentLocation().equals(Locations.YOURISLAND)) { + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + DecimalFormat flightFormat = new DecimalFormat( + "#.#", + DecimalFormatSymbols.getInstance(Locale.CANADA) + ); + String duration; + if (IslandHandler.flightTime < 60) duration = + IslandHandler.flightTime + "s"; else if ( + IslandHandler.flightTime < 3600 + ) duration = + flightFormat.format((double) IslandHandler.flightTime / 60) + + "m"; else if (IslandHandler.flightTime < 86400) duration = + flightFormat.format((double) IslandHandler.flightTime / 3600) + + "hr"; else if (IslandHandler.flightTime < 86460) duration = + flightFormat.format((double) IslandHandler.flightTime / 86400) + + "day"; else duration = + flightFormat.format((double) IslandHandler.flightTime / 86400) + "days"; + mc.renderEngine.bindTexture(GuiTextures.overlay); + drawTexturedModalRect( + (width / 2) - 33 - (font.getStringWidth(duration)), + offset + (bossBarVisible ? 35 : 18), + 0, + 34, + 2, + 14 + ); + drawTexturedModalRect( + ((width / 2) - 33 - (font.getStringWidth(duration))) + 2, + offset + (bossBarVisible ? 35 : 18), + 2, + 34, + font.getStringWidth(duration) + 14, + 14 + ); + drawTexturedModalRect( + ((width / 2) - 33 - (font.getStringWidth(duration))) + 4, + offset + (bossBarVisible ? 38 : 21), + 67, + 0, + 8, + 8 + ); + drawString( + font, + duration, + (width / 2) - 19 - (font.getStringWidth(duration)), + offset + (bossBarVisible ? 38 : 21), + 0xFFFFFF + ); } + } - public void drawMithril(int width, int offset, Minecraft mc){ - if (LocationHandler.getCurrentLocation().getCategory().equals(LocationCategory.DWARVENMINES)){ - GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); - mc.renderEngine.bindTexture(GuiTextures.overlay); - String mithril = DwarvenMineHandler.getMithrilFormatted(); - drawTexturedModalRect((width/ 2) - 33 - (font.getStringWidth(mithril)), offset + (bossBarVisible ? 35 : 18), 0, 34, 2, 14); - drawTexturedModalRect(((width/ 2) - 33 - (font.getStringWidth(mithril))) + 2, offset + (bossBarVisible ? 35 : 18), 2, 34, font.getStringWidth(mithril) + 14, 14); - drawTexturedModalRect(((width/ 2) - 33 - (font.getStringWidth(mithril))) + 4, offset + (bossBarVisible ? 38 : 21), 91, 0, 8, 8); - drawString(font, mithril, (width/ 2) - 19 - (font.getStringWidth(mithril)) , offset + (bossBarVisible ? 38 : 21), 0x00C896); - } + public void drawRainDuration(int width, int offset, Minecraft mc) { + if ( + LocationHandler + .getCurrentLocation() + .getCategory() + .equals(LocationCategory.PARK) + ) { + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + mc.renderEngine.bindTexture(GuiTextures.overlay); + String duration = "Rain: " + ParkIslandHandler.getRainTime(); + drawTexturedModalRect( + (width / 2) - 33 - (font.getStringWidth(duration)), + offset + (bossBarVisible ? 35 : 18), + 0, + 34, + 2, + 14 + ); + drawTexturedModalRect( + ((width / 2) - 33 - (font.getStringWidth(duration))) + 2, + offset + (bossBarVisible ? 35 : 18), + 2, + 34, + font.getStringWidth(duration) + 14, + 14 + ); + drawTexturedModalRect( + ((width / 2) - 33 - (font.getStringWidth(duration))) + 4, + offset + (bossBarVisible ? 38 : 21), + 83, + 0, + 8, + 8 + ); + drawString( + font, + duration, + (width / 2) - 19 - (font.getStringWidth(duration)), + offset + (bossBarVisible ? 38 : 21), + 0xFFFFFF + ); } + } - public void drawTrapperOrPelts(int width, int offset, Minecraft mc){ - if (LocationHandler.getCurrentLocation().getCategory().equals(LocationCategory.MUSHROOMDESERT)){ - GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); - mc.renderEngine.bindTexture(GuiTextures.overlay); - String duration = FarmingIslandHandler.location != Locations.NONE ? FarmingIslandHandler.location.getDisplayName() : ""+FarmingIslandHandler.pelts; - drawTexturedModalRect((width/ 2) - 33 - (font.getStringWidth(duration)), offset + (bossBarVisible ? 35 : 18), 0, 34, 2, 14); - drawTexturedModalRect(((width/ 2) - 33 - (font.getStringWidth(duration))) + 2, offset + (bossBarVisible ? 35 : 18), 2, 34, font.getStringWidth(duration) + 14, 14); - drawTexturedModalRect(((width/ 2) - 33 - (font.getStringWidth(duration))) + 4, offset + (bossBarVisible ? 38 : 21), FarmingIslandHandler.location != Locations.NONE ? 123 : 115, 0, 8, 8); - drawString(font, duration, (width/ 2) - 19 - (font.getStringWidth(duration)) , offset + (bossBarVisible ? 38 : 21), 0xFFFFFF); + public void drawSlayer(int width, int offset, Minecraft mc) { + if (SlayerHandler.isDoingSlayer) { + int kills = SlayerHandler.progress; + int maxKills = SlayerHandler.maxKills; + int tier = SlayerHandler.slayerTier; + SlayerHandler.slayerTypes slayerType = SlayerHandler.currentSlayer; + if (slayerType != SlayerHandler.slayerTypes.NONE) { + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + mc.renderEngine.bindTexture(GuiTextures.overlay); + StringBuilder stringBuilder = new StringBuilder(); + stringBuilder.append(EnumChatFormatting.GREEN); + stringBuilder.append(Utils.intToRomanNumeral(tier)); + stringBuilder.append(" "); + if (SlayerHandler.isKillingBoss) { + stringBuilder.append(EnumChatFormatting.RED); + stringBuilder.append("Slay Boss!"); + } else if (SlayerHandler.bossSlain) { + stringBuilder.append(EnumChatFormatting.RED); + stringBuilder.append("Boss Slain!"); + } else if (kills == 0 && maxKills == 0) { + stringBuilder.append(EnumChatFormatting.RED); + stringBuilder.append("Not Slaying!"); + } else { + stringBuilder.append(EnumChatFormatting.YELLOW); + stringBuilder.append(kills); + stringBuilder.append(EnumChatFormatting.GRAY); + stringBuilder.append("/"); + stringBuilder.append(EnumChatFormatting.RED); + stringBuilder.append(maxKills); } + String text = stringBuilder.toString(); + drawTexturedModalRect( + (width / 2) - 33 - (font.getStringWidth(text)), + offset + (bossBarVisible ? 35 : 18), + 0, + 34, + 2, + 14 + ); + drawTexturedModalRect( + ((width / 2) - 33 - (font.getStringWidth(text))) + 2, + offset + (bossBarVisible ? 35 : 18), + 2, + 34, + font.getStringWidth(text) + 14, + 14 + ); + drawTexturedModalRect( + ((width / 2) - 33 - (font.getStringWidth(text))) + 4, + offset + (bossBarVisible ? 38 : 21), + slayerType.getX(), + 24, + 8, + 8 + ); + drawString( + font, + text, + (width / 2) - 19 - (font.getStringWidth(text)), + offset + (bossBarVisible ? 38 : 21), + 0xFFFFFF + ); + } } + } - public void drawDwarvenEvent(int width, int offset, Minecraft mc){ - if (LocationHandler.getCurrentLocation().getCategory().equals(LocationCategory.DWARVENMINES)){ - GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); - mc.renderEngine.bindTexture(GuiTextures.overlay); - if (DwarvenMineHandler.eventMax > 0) { - String duration = DwarvenMineHandler.eventProgress + "/" + DwarvenMineHandler.eventMax; - drawTexturedModalRect((width / 2) - 33 - (font.getStringWidth(duration)), offset + (bossBarVisible ? 35 : 18), 0, 34, 2, 14); - drawTexturedModalRect(((width / 2) - 33 - (font.getStringWidth(duration))) + 2, offset + (bossBarVisible ? 35 : 18), 2, 34, font.getStringWidth(duration) + 14, 14); - drawTexturedModalRect(((width / 2) - 33 - (font.getStringWidth(duration))) + 4, offset + (bossBarVisible ? 38 : 21), DwarvenMineHandler.currentEvent.x, 0, 8, 8); - drawString(font, duration, (width / 2) - 19 - (font.getStringWidth(duration)), offset + (bossBarVisible ? 38 : 21), 0xFFFFFF); - }else { - String text = DwarvenMineHandler.currentEvent.displayName; - drawTexturedModalRect((width / 2) - 33 - (font.getStringWidth(text)), offset + (bossBarVisible ? 35 : 18), 0, 34, 2, 14); - drawTexturedModalRect(((width / 2) - 33 - (font.getStringWidth(text))) + 2, offset + (bossBarVisible ? 35 : 18), 2, 34, font.getStringWidth(text) + 14, 14); - drawTexturedModalRect(((width / 2) - 33 - (font.getStringWidth(text))) + 4, offset + (bossBarVisible ? 38 : 21), DwarvenMineHandler.currentEvent.x, 0, 8, 8); - drawString(font, text, (width / 2) - 19 - (font.getStringWidth(text)), offset + (bossBarVisible ? 38 : 21), 0xFFFFFF); - } - } + public void drawMithril(int width, int offset, Minecraft mc) { + if ( + LocationHandler + .getCurrentLocation() + .getCategory() + .equals(LocationCategory.DWARVENMINES) + ) { + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + mc.renderEngine.bindTexture(GuiTextures.overlay); + String mithril = DwarvenMineHandler.getMithrilFormatted(); + drawTexturedModalRect( + (width / 2) - 33 - (font.getStringWidth(mithril)), + offset + (bossBarVisible ? 35 : 18), + 0, + 34, + 2, + 14 + ); + drawTexturedModalRect( + ((width / 2) - 33 - (font.getStringWidth(mithril))) + 2, + offset + (bossBarVisible ? 35 : 18), + 2, + 34, + font.getStringWidth(mithril) + 14, + 14 + ); + drawTexturedModalRect( + ((width / 2) - 33 - (font.getStringWidth(mithril))) + 4, + offset + (bossBarVisible ? 38 : 21), + 91, + 0, + 8, + 8 + ); + drawString( + font, + mithril, + (width / 2) - 19 - (font.getStringWidth(mithril)), + offset + (bossBarVisible ? 38 : 21), + 0x00C896 + ); } + } - @SubscribeEvent - public void renderOverlay(RenderGameOverlayEvent.Post event) { - if (Utils.overlayShouldRender(event.type, SkyblockHud.hasSkyblockScoreboard())) { - bossBarVisible = BossStatus.statusBarTime > 0 && GuiIngameForge.renderBossHealth && BossbarHandler.bossBarRendered; - Minecraft mc = Minecraft.getMinecraft(); - GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); - if (LocationHandler.getCurrentLocation() != Locations.CATACOMBS){ - drawClock(event.resolution.getScaledWidth(), SkyblockHud.config.main.mainHudPos.getAbsY(event.resolution, 34), mc); - } - GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); - } + public void drawTrapperOrPelts(int width, int offset, Minecraft mc) { + if ( + LocationHandler + .getCurrentLocation() + .getCategory() + .equals(LocationCategory.MUSHROOMDESERT) + ) { + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + mc.renderEngine.bindTexture(GuiTextures.overlay); + String duration = FarmingIslandHandler.location != Locations.NONE + ? FarmingIslandHandler.location.getDisplayName() + : "" + FarmingIslandHandler.pelts; + drawTexturedModalRect( + (width / 2) - 33 - (font.getStringWidth(duration)), + offset + (bossBarVisible ? 35 : 18), + 0, + 34, + 2, + 14 + ); + drawTexturedModalRect( + ((width / 2) - 33 - (font.getStringWidth(duration))) + 2, + offset + (bossBarVisible ? 35 : 18), + 2, + 34, + font.getStringWidth(duration) + 14, + 14 + ); + drawTexturedModalRect( + ((width / 2) - 33 - (font.getStringWidth(duration))) + 4, + offset + (bossBarVisible ? 38 : 21), + FarmingIslandHandler.location != Locations.NONE ? 123 : 115, + 0, + 8, + 8 + ); + drawString( + font, + duration, + (width / 2) - 19 - (font.getStringWidth(duration)), + offset + (bossBarVisible ? 38 : 21), + 0xFFFFFF + ); } + } + public void drawDwarvenEvent(int width, int offset, Minecraft mc) { + if ( + LocationHandler + .getCurrentLocation() + .getCategory() + .equals(LocationCategory.DWARVENMINES) + ) { + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + mc.renderEngine.bindTexture(GuiTextures.overlay); + if (DwarvenMineHandler.eventMax > 0) { + String duration = + DwarvenMineHandler.eventProgress + "/" + DwarvenMineHandler.eventMax; + drawTexturedModalRect( + (width / 2) - 33 - (font.getStringWidth(duration)), + offset + (bossBarVisible ? 35 : 18), + 0, + 34, + 2, + 14 + ); + drawTexturedModalRect( + ((width / 2) - 33 - (font.getStringWidth(duration))) + 2, + offset + (bossBarVisible ? 35 : 18), + 2, + 34, + font.getStringWidth(duration) + 14, + 14 + ); + drawTexturedModalRect( + ((width / 2) - 33 - (font.getStringWidth(duration))) + 4, + offset + (bossBarVisible ? 38 : 21), + DwarvenMineHandler.currentEvent.x, + 0, + 8, + 8 + ); + drawString( + font, + duration, + (width / 2) - 19 - (font.getStringWidth(duration)), + offset + (bossBarVisible ? 38 : 21), + 0xFFFFFF + ); + } else { + String text = DwarvenMineHandler.currentEvent.displayName; + drawTexturedModalRect( + (width / 2) - 33 - (font.getStringWidth(text)), + offset + (bossBarVisible ? 35 : 18), + 0, + 34, + 2, + 14 + ); + drawTexturedModalRect( + ((width / 2) - 33 - (font.getStringWidth(text))) + 2, + offset + (bossBarVisible ? 35 : 18), + 2, + 34, + font.getStringWidth(text) + 14, + 14 + ); + drawTexturedModalRect( + ((width / 2) - 33 - (font.getStringWidth(text))) + 4, + offset + (bossBarVisible ? 38 : 21), + DwarvenMineHandler.currentEvent.x, + 0, + 8, + 8 + ); + drawString( + font, + text, + (width / 2) - 19 - (font.getStringWidth(text)), + offset + (bossBarVisible ? 38 : 21), + 0xFFFFFF + ); + } + } + } - public void drawScaledString(float factor, int x, int y, String text, int color){ - GlStateManager.scale(factor, factor, 1); - drawCenteredString(font, text, (int)(x/factor), (int)(y/factor), color); - GlStateManager.scale(1/factor, 1/factor, 1); + @SubscribeEvent + public void renderOverlay(RenderGameOverlayEvent.Post event) { + if ( + Utils.overlayShouldRender(event.type, SkyblockHud.hasSkyblockScoreboard()) + ) { + bossBarVisible = + BossStatus.statusBarTime > 0 && + GuiIngameForge.renderBossHealth && + BossbarHandler.bossBarRendered; + Minecraft mc = Minecraft.getMinecraft(); + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + if (LocationHandler.getCurrentLocation() != Locations.CATACOMBS) { + drawClock( + event.resolution.getScaledWidth(), + SkyblockHud.config.main.mainHudPos.getAbsY(event.resolution, 34), + mc + ); + } + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); } + } + + public void drawScaledString( + float factor, + int x, + int y, + String text, + int color + ) { + GlStateManager.scale(factor, factor, 1); + drawCenteredString( + font, + text, + (int) (x / factor), + (int) (y / factor), + color + ); + GlStateManager.scale(1 / factor, 1 / factor, 1); + } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/overlay/RPGHud.java b/src/main/java/com/thatgravyboat/skyblockhud/overlay/RPGHud.java index 9356be6..5a7409e 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/overlay/RPGHud.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/overlay/RPGHud.java @@ -5,6 +5,8 @@ import com.thatgravyboat.skyblockhud.GuiTextures; import com.thatgravyboat.skyblockhud.SkyblockHud; import com.thatgravyboat.skyblockhud.Utils; import com.thatgravyboat.skyblockhud.core.config.Position; +import java.text.DecimalFormat; +import java.text.NumberFormat; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.Gui; @@ -13,92 +15,177 @@ import net.minecraftforge.client.event.RenderGameOverlayEvent; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import java.text.DecimalFormat; -import java.text.NumberFormat; - public class RPGHud extends Gui { - private static int mana, maxMana, overflow = 0; - private static int health, maxHealth = 0; - private static int defense = 0; - - public static void updateMana(int current, int max){ - mana = current; - maxMana = max; - } - - public static void updateOverflow(int current){ - overflow = current; - } - - public static void updateHealth(int current, int max){ - health = current; - maxHealth = max; - } - public static void updateDefense(int input){ defense = input; } - - public static void manaPredictionUpdate(boolean isIncrease, int decrease){ - mana = isIncrease ? Math.min(mana + (maxMana / 50), maxMana) : mana - decrease; - } - - private static final DecimalFormat decimalFormat = new DecimalFormat("#.##"); - - static { - decimalFormat.setGroupingUsed(true); - decimalFormat.setGroupingSize(3); - } - @SubscribeEvent - public void renderOverlay(RenderGameOverlayEvent.Post event) { - if (Utils.overlayShouldRender(event.type, SkyblockHud.hasSkyblockScoreboard(), SkyblockHud.config.renderer.hideXpBar)) - MinecraftForge.EVENT_BUS.post(new RenderGameOverlayEvent.Post(new RenderGameOverlayEvent(event.partialTicks, event.resolution), RenderGameOverlayEvent.ElementType.EXPERIENCE)); - if (Utils.overlayShouldRender(event.type, SkyblockHud.hasSkyblockScoreboard(), SkyblockHud.config.rpg.showRpgHud)) { - Minecraft mc = Minecraft.getMinecraft(); - GlStateManager.enableBlend(); - GlStateManager.color(1.0f,1.0f,1.0f,1.0f); - FontRenderer font = mc.fontRendererObj; - if (mc.thePlayer.getHealth() < mc.thePlayer.getMaxHealth()){ - health = Math.max((int) (maxHealth * (mc.thePlayer.getHealth() / mc.thePlayer.getMaxHealth())), health); - } - - mc.renderEngine.bindTexture(GuiTextures.playerStat); - Position position = SkyblockHud.config.rpg.rpgHudPosition; - - int x = position.getAbsX(event.resolution, 120); - int y = position.getAbsY(event.resolution, 47); - - boolean rightAligned = position.rightAligned(event.resolution, 120); - - drawTexturedModalRect(x,y,rightAligned ? 131 : 5,6,120,47); - - float manaWidth = Math.min(57 * ((float)mana/(float)maxMana), 57); - drawTexturedModalRect(rightAligned ? x + 16 : 47 + x,17 + y,rightAligned ? 199 : 0,64,(int)manaWidth,4); - - float healthWidth = Math.min(70 * ((float)health/(float)maxHealth), 70); - drawTexturedModalRect(rightAligned ? x + 3 : 47+ x,22+ y,rightAligned ? 186 : 0,68,(int)healthWidth,5); - - if (health > maxHealth) { - float absorptionWidth = Math.min(70 * ((float) (health - maxHealth) / (float) maxHealth), 70); - drawTexturedModalRect(rightAligned ? x + 3 : 47 + x, 22 + y, rightAligned ? 186 : 0, 77, (int) absorptionWidth, 5); - } - - float xpWidth = 67 * mc.thePlayer.experience; - drawTexturedModalRect(rightAligned ? x + 7 : 45+ x,28+ y,rightAligned ? 189 : 0,73,(int)xpWidth,4); - //Air in water - NumberFormat myFormat = NumberFormat.getInstance(); - myFormat.setGroupingUsed(true); - if (mc.thePlayer.getAir() < 300){ - float airWidth = 60 * ((float)mc.thePlayer.getAir() / 300); - drawTexturedModalRect(rightAligned ? x + 17 : 39 + x,33+ y,rightAligned ? 192 : 0,82,64,6); - drawTexturedModalRect(rightAligned ? x + 19 : 41+ x,33+ y,rightAligned ? 196 : 0,88,(int)airWidth,4); - } - GlStateManager.scale(0.75f, 0.75f, 1); - drawCenteredString(mc.fontRendererObj, ""+mc.thePlayer.experienceLevel, (rightAligned ? 130 : 0) + (int)(15+ x/0.75f), (int)(45+ y/0.75f), 8453920); - GlStateManager.scale(1/0.75f, 1/0.75f, 1); - GlStateManager.scale(0.75f, 0.75f, 1); - font.drawString( ChatFormatting.RED + " \u2764 " + health +"/"+maxHealth,(rightAligned ? -40 : 0) + (int)(64+ x/0.75f), (int)(8+ y/0.75f), 0xffffff, true); - GlStateManager.scale(1/0.75f, 1/0.75f, 1); - GlStateManager.color(255,255,255); - GlStateManager.disableBlend(); - } + private static int mana, maxMana, overflow = 0; + private static int health, maxHealth = 0; + private static int defense = 0; + + public static void updateMana(int current, int max) { + mana = current; + maxMana = max; + } + + public static void updateOverflow(int current) { + overflow = current; + } + + public static void updateHealth(int current, int max) { + health = current; + maxHealth = max; + } + + public static void updateDefense(int input) { + defense = input; + } + + public static void manaPredictionUpdate(boolean isIncrease, int decrease) { + mana = + isIncrease ? Math.min(mana + (maxMana / 50), maxMana) : mana - decrease; + } + + private static final DecimalFormat decimalFormat = new DecimalFormat("#.##"); + + static { + decimalFormat.setGroupingUsed(true); + decimalFormat.setGroupingSize(3); + } + + @SubscribeEvent + public void renderOverlay(RenderGameOverlayEvent.Post event) { + if ( + Utils.overlayShouldRender( + event.type, + SkyblockHud.hasSkyblockScoreboard(), + SkyblockHud.config.renderer.hideXpBar + ) + ) MinecraftForge.EVENT_BUS.post( + new RenderGameOverlayEvent.Post( + new RenderGameOverlayEvent(event.partialTicks, event.resolution), + RenderGameOverlayEvent.ElementType.EXPERIENCE + ) + ); + if ( + Utils.overlayShouldRender( + event.type, + SkyblockHud.hasSkyblockScoreboard(), + SkyblockHud.config.rpg.showRpgHud + ) + ) { + Minecraft mc = Minecraft.getMinecraft(); + GlStateManager.enableBlend(); + GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f); + FontRenderer font = mc.fontRendererObj; + if (mc.thePlayer.getHealth() < mc.thePlayer.getMaxHealth()) { + health = + Math.max( + (int) ( + maxHealth * + (mc.thePlayer.getHealth() / mc.thePlayer.getMaxHealth()) + ), + health + ); + } + + mc.renderEngine.bindTexture(GuiTextures.playerStat); + Position position = SkyblockHud.config.rpg.rpgHudPosition; + + int x = position.getAbsX(event.resolution, 120); + int y = position.getAbsY(event.resolution, 47); + + boolean rightAligned = position.rightAligned(event.resolution, 120); + + drawTexturedModalRect(x, y, rightAligned ? 131 : 5, 6, 120, 47); + + float manaWidth = Math.min(57 * ((float) mana / (float) maxMana), 57); + drawTexturedModalRect( + rightAligned ? x + 16 : 47 + x, + 17 + y, + rightAligned ? 199 : 0, + 64, + (int) manaWidth, + 4 + ); + + float healthWidth = Math.min( + 70 * ((float) health / (float) maxHealth), + 70 + ); + drawTexturedModalRect( + rightAligned ? x + 3 : 47 + x, + 22 + y, + rightAligned ? 186 : 0, + 68, + (int) healthWidth, + 5 + ); + + if (health > maxHealth) { + float absorptionWidth = Math.min( + 70 * ((float) (health - maxHealth) / (float) maxHealth), + 70 + ); + drawTexturedModalRect( + rightAligned ? x + 3 : 47 + x, + 22 + y, + rightAligned ? 186 : 0, + 77, + (int) absorptionWidth, + 5 + ); + } + + float xpWidth = 67 * mc.thePlayer.experience; + drawTexturedModalRect( + rightAligned ? x + 7 : 45 + x, + 28 + y, + rightAligned ? 189 : 0, + 73, + (int) xpWidth, + 4 + ); + //Air in water + NumberFormat myFormat = NumberFormat.getInstance(); + myFormat.setGroupingUsed(true); + if (mc.thePlayer.getAir() < 300) { + float airWidth = 60 * ((float) mc.thePlayer.getAir() / 300); + drawTexturedModalRect( + rightAligned ? x + 17 : 39 + x, + 33 + y, + rightAligned ? 192 : 0, + 82, + 64, + 6 + ); + drawTexturedModalRect( + rightAligned ? x + 19 : 41 + x, + 33 + y, + rightAligned ? 196 : 0, + 88, + (int) airWidth, + 4 + ); + } + GlStateManager.scale(0.75f, 0.75f, 1); + drawCenteredString( + mc.fontRendererObj, + "" + mc.thePlayer.experienceLevel, + (rightAligned ? 130 : 0) + (int) (15 + x / 0.75f), + (int) (45 + y / 0.75f), + 8453920 + ); + GlStateManager.scale(1 / 0.75f, 1 / 0.75f, 1); + GlStateManager.scale(0.75f, 0.75f, 1); + font.drawString( + ChatFormatting.RED + " \u2764 " + health + "/" + maxHealth, + (rightAligned ? -40 : 0) + (int) (64 + x / 0.75f), + (int) (8 + y / 0.75f), + 0xffffff, + true + ); + GlStateManager.scale(1 / 0.75f, 1 / 0.75f, 1); + GlStateManager.color(255, 255, 255); + GlStateManager.disableBlend(); } + } } |