From bb75fd7b83b238f1f922ffc64b2a0a535c5524b7 Mon Sep 17 00:00:00 2001 From: TymanWasTaken Date: Tue, 6 Jul 2021 17:13:01 -0400 Subject: Format --- .../skyblockhud/overlay/DungeonOverlay.java | 413 +++++++++++++++------ 1 file changed, 304 insertions(+), 109 deletions(-) (limited to 'src/main/java/com/thatgravyboat/skyblockhud/overlay/DungeonOverlay.java') 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 + ); } + } } -- cgit From a8e475fa0a7977f64f072548459d592274169d66 Mon Sep 17 00:00:00 2001 From: TymanWasTaken Date: Tue, 6 Jul 2021 17:15:21 -0400 Subject: Format v2 --- .gitattributes | 1 + .prettierrc.yml | 4 +- .../skyblockhud/ComponentBuilder.java | 108 +- .../skyblockhud/ComponentHandler.java | 398 +++-- .../com/thatgravyboat/skyblockhud/GuiTextures.java | 144 +- .../com/thatgravyboat/skyblockhud/SkyblockHud.java | 301 ++-- .../thatgravyboat/skyblockhud/SpecialColour.java | 205 +-- .../java/com/thatgravyboat/skyblockhud/Utils.java | 772 ++++----- .../skyblockhud/api/LeaderboardGetter.java | 145 +- .../api/events/SidebarLineUpdateEvent.java | 38 +- .../skyblockhud/api/events/SidebarPostEvent.java | 28 +- .../skyblockhud/api/events/SidebarPreGetEvent.java | 12 +- .../skyblockhud/commands/Commands.java | 91 +- .../skyblockhud/commands/SimpleCommand.java | 101 +- .../skyblockhud/config/KeyBindings.java | 10 +- .../skyblockhud/config/SBHConfig.java | 756 +++++---- .../skyblockhud/config/SBHConfigEditor.java | 1745 ++++++++++---------- .../skyblockhud/core/BackgroundBlur.java | 491 +++--- .../skyblockhud/core/ChromaColour.java | 205 +-- .../skyblockhud/core/GlScissorStack.java | 152 +- .../thatgravyboat/skyblockhud/core/GuiElement.java | 6 +- .../skyblockhud/core/GuiElementBoolean.java | 222 +-- .../skyblockhud/core/GuiElementColour.java | 1147 +++++++------ .../skyblockhud/core/GuiElementTextField.java | 1351 +++++++-------- .../skyblockhud/core/GuiScreenElementWrapper.java | 48 +- .../skyblockhud/core/config/Config.java | 2 +- .../skyblockhud/core/config/Position.java | 335 ++-- .../core/config/annotations/Category.java | 4 +- .../core/config/annotations/ConfigAccordionId.java | 2 +- .../config/annotations/ConfigEditorAccordion.java | 2 +- .../config/annotations/ConfigEditorButton.java | 4 +- .../annotations/ConfigEditorDraggableList.java | 2 +- .../config/annotations/ConfigEditorDropdown.java | 4 +- .../config/annotations/ConfigEditorSlider.java | 6 +- .../core/config/annotations/ConfigOption.java | 6 +- .../core/config/gui/GuiOptionEditor.java | 160 +- .../core/config/gui/GuiOptionEditorAccordion.java | 152 +- .../core/config/gui/GuiOptionEditorBoolean.java | 65 +- .../core/config/gui/GuiOptionEditorButton.java | 119 +- .../core/config/gui/GuiOptionEditorColour.java | 134 +- .../config/gui/GuiOptionEditorDraggableList.java | 694 ++++---- .../core/config/gui/GuiOptionEditorDropdown.java | 428 ++--- .../core/config/gui/GuiOptionEditorSlider.java | 302 ++-- .../core/config/gui/GuiOptionEditorText.java | 159 +- .../core/config/gui/GuiPositionEditor.java | 454 ++--- .../core/config/struct/ConfigProcessor.java | 476 +++--- .../skyblockhud/core/util/GuiElementSlider.java | 317 ++-- .../skyblockhud/core/util/MiscUtils.java | 182 +- .../skyblockhud/core/util/Splitters.java | 2 +- .../skyblockhud/core/util/StringUtils.java | 53 +- .../skyblockhud/core/util/lerp/LerpUtils.java | 35 +- .../skyblockhud/core/util/lerp/LerpingFloat.java | 97 +- .../skyblockhud/core/util/lerp/LerpingInteger.java | 109 +- .../skyblockhud/core/util/render/RenderUtils.java | 580 +++---- .../core/util/render/TextRenderUtils.java | 685 ++++---- .../skyblockhud/dungeons/Classes.java | 78 +- .../skyblockhud/dungeons/DungeonHandler.java | 451 ++--- .../skyblockhud/dungeons/DungeonPlayer.java | 54 +- .../skyblockhud/handlers/BossbarHandler.java | 55 +- .../skyblockhud/handlers/CurrencyHandler.java | 208 +-- .../skyblockhud/handlers/HeldItemHandler.java | 86 +- .../skyblockhud/handlers/MapHandler.java | 821 ++++----- .../skyblockhud/handlers/SlayerHandler.java | 270 +-- .../skyblockhud/handlers/TimeHandler.java | 61 +- .../handlers/mapicons/DwarvenIcons.java | 171 +- .../skyblockhud/handlers/mapicons/HubIcons.java | 631 +++---- .../handlers/sbentities/EntityTypeHelper.java | 46 +- .../handlers/sbentities/EntityTypeRegistry.java | 30 +- .../handlers/sbentities/SkyBlockEntity.java | 30 +- .../skyblockhud/location/DwarvenMineHandler.java | 229 +-- .../skyblockhud/location/EndIslandHandler.java | 94 +- .../skyblockhud/location/FarmingIslandHandler.java | 42 +- .../skyblockhud/location/IslandHandler.java | 136 +- .../skyblockhud/location/LocationCategory.java | 82 +- .../skyblockhud/location/LocationHandler.java | 86 +- .../skyblockhud/location/Locations.java | 522 +++--- .../skyblockhud/location/ParkIslandHandler.java | 38 +- .../skyblockhud/mixins/MixinEndermanRenderer.java | 48 +- .../skyblockhud/mixins/MixinEntityArrow.java | 32 +- .../skyblockhud/mixins/MixinGuiIngameForge.java | 233 +-- .../mixins/MixinNetHandlerPlayClient.java | 46 +- .../skyblockhud/overlay/DungeonOverlay.java | 619 +++---- .../skyblockhud/overlay/GenericOverlays.java | 152 +- .../skyblockhud/overlay/OverlayHud.java | 1350 +++++++-------- .../thatgravyboat/skyblockhud/overlay/RPGHud.java | 349 ++-- .../skyblockhud/playerstats/ActionBarParsing.java | 296 ++-- .../thatgravyboat/skyblockhud/seasons/Season.java | 96 +- .../skyblockhud/seasons/SeasonDateHandler.java | 166 +- .../skyblockhud/tracker/KillTrackerHandler.java | 124 +- .../skyblockhud/tracker/TrackerFileLoader.java | 435 ++--- .../skyblockhud/tracker/TrackerHandler.java | 307 ++-- 91 files changed, 11646 insertions(+), 10879 deletions(-) create mode 100644 .gitattributes (limited to 'src/main/java/com/thatgravyboat/skyblockhud/overlay/DungeonOverlay.java') diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..94f480d --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +* text=auto eol=lf \ No newline at end of file diff --git a/.prettierrc.yml b/.prettierrc.yml index 832c026..6001ba5 100644 --- a/.prettierrc.yml +++ b/.prettierrc.yml @@ -3,4 +3,6 @@ overrides: - "*.java" options: useTabs: false - trailingComma: none \ No newline at end of file + trailingComma: none + tabWidth: 4 + endOfLine: lf \ No newline at end of file diff --git a/src/main/java/com/thatgravyboat/skyblockhud/ComponentBuilder.java b/src/main/java/com/thatgravyboat/skyblockhud/ComponentBuilder.java index 4e6f398..28c5485 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/ComponentBuilder.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/ComponentBuilder.java @@ -2,58 +2,58 @@ package com.thatgravyboat.skyblockhud; public class ComponentBuilder { - public StringBuilder builder; - - public ComponentBuilder() { - this.builder = new StringBuilder(); - } - - public ComponentBuilder apd(String text) { - return apd(text, '7'); - } - - public ComponentBuilder apd(String text, char[] colors) { - for (char color : colors) { - builder.append("\u00A7").append(color); - } - builder.append(text).append("\u00A7").append('r'); - return this; - } - - public ComponentBuilder apd(String text, char color) { - builder - .append("\u00A7") - .append(color) - .append(text) - .append("\u00A7") - .append('r'); - return this; - } - - public ComponentBuilder nl() { - builder.append("\n"); - return this; - } - - public ComponentBuilder nl(String text, char color) { - apd(text, color); - builder.append("\n"); - return this; - } - - public ComponentBuilder nl(String text, char[] colors) { - apd(text, colors); - builder.append("\n"); - return this; - } - - public ComponentBuilder nl(String text) { - apd(text); - builder.append("\n"); - return this; - } - - public String build() { - return builder.toString(); - } + public StringBuilder builder; + + public ComponentBuilder() { + this.builder = new StringBuilder(); + } + + public ComponentBuilder apd(String text) { + return apd(text, '7'); + } + + public ComponentBuilder apd(String text, char[] colors) { + for (char color : colors) { + builder.append("\u00A7").append(color); + } + builder.append(text).append("\u00A7").append('r'); + return this; + } + + public ComponentBuilder apd(String text, char color) { + builder + .append("\u00A7") + .append(color) + .append(text) + .append("\u00A7") + .append('r'); + return this; + } + + public ComponentBuilder nl() { + builder.append("\n"); + return this; + } + + public ComponentBuilder nl(String text, char color) { + apd(text, color); + builder.append("\n"); + return this; + } + + public ComponentBuilder nl(String text, char[] colors) { + apd(text, colors); + builder.append("\n"); + return this; + } + + public ComponentBuilder nl(String text) { + apd(text); + builder.append("\n"); + return this; + } + + public String build() { + return builder.toString(); + } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/ComponentHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/ComponentHandler.java index 03bfe04..ef2028d 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/ComponentHandler.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/ComponentHandler.java @@ -22,193 +22,243 @@ import net.minecraftforge.fml.relauncher.SideOnly; public class ComponentHandler { - public static final Pattern SCOREBOARD_CHARACTERS = Pattern.compile( - "[^]\\[a-z A-Z:0-9/'.()+\\d-§?]" - ); - private static final Ordering sortingList = Ordering.from( - new PlayerComparator() - ); - private static int ticksExisted = 0; + public static final Pattern SCOREBOARD_CHARACTERS = Pattern.compile( + "[^]\\[a-z A-Z:0-9/'.()+\\d-§?]" + ); + private static final Ordering sortingList = Ordering.from( + new PlayerComparator() + ); + private static int ticksExisted = 0; - @SubscribeEvent - public void onClientTick(TickEvent.ClientTickEvent event) { - Minecraft mc = Minecraft.getMinecraft(); - ticksExisted++; - boolean eventPass = false; - if (mc.theWorld != null) { - List players = sortingList.sortedCopy( - mc.thePlayer.sendQueue.getPlayerInfoMap() - ); - GuiIngameForge.renderObjective = - !SkyblockHud.hasSkyblockScoreboard() || - !SkyblockHud.config.misc.hideScoreboard; - if (players != null && SkyblockHud.hasSkyblockScoreboard()) { - if (ticksExisted % 60 == 0) { - for (NetworkPlayerInfo player : players) { - if (player.getDisplayName() != null) { - String formattedTabListPlayer = SCOREBOARD_CHARACTERS - .matcher( - Utils.removeColor(player.getDisplayName().getFormattedText()) - ) - .replaceAll(""); - if ( - LocationHandler.getCurrentLocation().equals(Locations.CATACOMBS) - ) { - if ( - formattedTabListPlayer - .toLowerCase() - .contains("secrets found:") - ) DungeonHandler.parseTotalSecrets(formattedTabListPlayer); - if ( - formattedTabListPlayer.toLowerCase().contains("deaths:") - ) DungeonHandler.parseDeaths(formattedTabListPlayer); - if ( - formattedTabListPlayer.toLowerCase().contains("crypts:") - ) DungeonHandler.parseCrypts(formattedTabListPlayer); - } else if ( - LocationHandler - .getCurrentLocation() - .getCategory() - .equals(LocationCategory.DWARVENMINES) - ) { - if ( - formattedTabListPlayer - .toLowerCase() - .contains("mithril powder:") - ) { - DwarvenMineHandler.parseMithril(formattedTabListPlayer); - } - } else if ( - LocationHandler - .getCurrentLocation() - .getCategory() - .equals(LocationCategory.MUSHROOMDESERT) - ) { - if (formattedTabListPlayer.toLowerCase().contains("pelts:")) { - try { - FarmingIslandHandler.pelts = - Integer.parseInt( - formattedTabListPlayer - .toLowerCase() - .replace("pelts:", "") - .trim() - ); - } catch (Exception ignored) {} - } - } - } - } - if (players.size() > 80) { - for (int i = 61; i <= 80; i++) { - if (players.get(i).getDisplayName() != null) { - String formattedTabListPlayer = SCOREBOARD_CHARACTERS - .matcher( - Utils.removeColor( - players.get(i).getDisplayName().getFormattedText() - ) - ) - .replaceAll(""); - if (formattedTabListPlayer.toLowerCase().contains("event:")) { - if (i < 80) { - if (players.get(i + 1).getDisplayName() != null) { - String secondLine = SCOREBOARD_CHARACTERS - .matcher( - Utils.removeColor( - players - .get(i + 1) - .getDisplayName() - .getFormattedText() - ) - ) - .replaceAll(""); - SeasonDateHandler.setCurrentEvent( - formattedTabListPlayer.replace("Event:", ""), - secondLine - ); - eventPass = true; + @SubscribeEvent + public void onClientTick(TickEvent.ClientTickEvent event) { + Minecraft mc = Minecraft.getMinecraft(); + ticksExisted++; + boolean eventPass = false; + if (mc.theWorld != null) { + List players = sortingList.sortedCopy( + mc.thePlayer.sendQueue.getPlayerInfoMap() + ); + GuiIngameForge.renderObjective = + !SkyblockHud.hasSkyblockScoreboard() || + !SkyblockHud.config.misc.hideScoreboard; + if (players != null && SkyblockHud.hasSkyblockScoreboard()) { + if (ticksExisted % 60 == 0) { + for (NetworkPlayerInfo player : players) { + if (player.getDisplayName() != null) { + String formattedTabListPlayer = SCOREBOARD_CHARACTERS + .matcher( + Utils.removeColor( + player + .getDisplayName() + .getFormattedText() + ) + ) + .replaceAll(""); + if ( + LocationHandler + .getCurrentLocation() + .equals(Locations.CATACOMBS) + ) { + if ( + formattedTabListPlayer + .toLowerCase() + .contains("secrets found:") + ) DungeonHandler.parseTotalSecrets( + formattedTabListPlayer + ); + if ( + formattedTabListPlayer + .toLowerCase() + .contains("deaths:") + ) DungeonHandler.parseDeaths( + formattedTabListPlayer + ); + if ( + formattedTabListPlayer + .toLowerCase() + .contains("crypts:") + ) DungeonHandler.parseCrypts( + formattedTabListPlayer + ); + } else if ( + LocationHandler + .getCurrentLocation() + .getCategory() + .equals(LocationCategory.DWARVENMINES) + ) { + if ( + formattedTabListPlayer + .toLowerCase() + .contains("mithril powder:") + ) { + DwarvenMineHandler.parseMithril( + formattedTabListPlayer + ); + } + } else if ( + LocationHandler + .getCurrentLocation() + .getCategory() + .equals(LocationCategory.MUSHROOMDESERT) + ) { + if ( + formattedTabListPlayer + .toLowerCase() + .contains("pelts:") + ) { + try { + FarmingIslandHandler.pelts = + Integer.parseInt( + formattedTabListPlayer + .toLowerCase() + .replace("pelts:", "") + .trim() + ); + } catch (Exception ignored) {} + } + } + } + } + if (players.size() > 80) { + for (int i = 61; i <= 80; i++) { + if (players.get(i).getDisplayName() != null) { + String formattedTabListPlayer = SCOREBOARD_CHARACTERS + .matcher( + Utils.removeColor( + players + .get(i) + .getDisplayName() + .getFormattedText() + ) + ) + .replaceAll(""); + if ( + formattedTabListPlayer + .toLowerCase() + .contains("event:") + ) { + if (i < 80) { + if ( + players + .get(i + 1) + .getDisplayName() != + null + ) { + String secondLine = SCOREBOARD_CHARACTERS + .matcher( + Utils.removeColor( + players + .get(i + 1) + .getDisplayName() + .getFormattedText() + ) + ) + .replaceAll(""); + SeasonDateHandler.setCurrentEvent( + formattedTabListPlayer.replace( + "Event:", + "" + ), + secondLine + ); + eventPass = true; + } + } + } + } + if (i == 80 && !eventPass) { + SeasonDateHandler.setCurrentEvent("", ""); + } + } } - } } - } - if (i == 80 && !eventPass) { - SeasonDateHandler.setCurrentEvent("", ""); - } - } - } - } - if ( - LocationHandler - .getCurrentLocation() - .getCategory() - .equals(LocationCategory.PARK) - ) { - if (players.size() >= 80) { - for (int i = 41; i <= 60; i++) { - if (players.get(i).getDisplayName() != null) { - String formattedTabListPlayer = SCOREBOARD_CHARACTERS - .matcher( - Utils.removeColor( - players.get(i).getDisplayName().getFormattedText() - ) - ) - .replaceAll(""); if ( - LocationHandler - .getCurrentLocation() - .getCategory() - .equals(LocationCategory.PARK) + LocationHandler + .getCurrentLocation() + .getCategory() + .equals(LocationCategory.PARK) ) { - if (formattedTabListPlayer.toLowerCase().contains("rain:")) { - ParkIslandHandler.parseRain( - formattedTabListPlayer.toLowerCase() - ); - } + if (players.size() >= 80) { + for (int i = 41; i <= 60; i++) { + if (players.get(i).getDisplayName() != null) { + String formattedTabListPlayer = SCOREBOARD_CHARACTERS + .matcher( + Utils.removeColor( + players + .get(i) + .getDisplayName() + .getFormattedText() + ) + ) + .replaceAll(""); + if ( + LocationHandler + .getCurrentLocation() + .getCategory() + .equals(LocationCategory.PARK) + ) { + if ( + formattedTabListPlayer + .toLowerCase() + .contains("rain:") + ) { + ParkIslandHandler.parseRain( + formattedTabListPlayer.toLowerCase() + ); + } + } + } + } + } + } else if (ParkIslandHandler.isRaining()) { + ParkIslandHandler.parseRain(null); } - } } - } - } else if (ParkIslandHandler.isRaining()) { - ParkIslandHandler.parseRain(null); } - } } - } - @SubscribeEvent(priority = EventPriority.HIGHEST) - public void onStatusBar(ClientChatReceivedEvent event) { - if (event.type == 2) { - if ( - LocationHandler.getCurrentLocation().equals(Locations.CATACOMBS) - ) DungeonHandler.parseSecrets(event.message.getFormattedText()); + @SubscribeEvent(priority = EventPriority.HIGHEST) + public void onStatusBar(ClientChatReceivedEvent event) { + if (event.type == 2) { + if ( + LocationHandler.getCurrentLocation().equals(Locations.CATACOMBS) + ) DungeonHandler.parseSecrets(event.message.getFormattedText()); + } } - } - @SideOnly(Side.CLIENT) - static class PlayerComparator implements Comparator { + @SideOnly(Side.CLIENT) + static class PlayerComparator implements Comparator { - private PlayerComparator() {} + private PlayerComparator() {} - public int compare( - NetworkPlayerInfo p_compare_1_, - NetworkPlayerInfo p_compare_2_ - ) { - ScorePlayerTeam scoreplayerteam = p_compare_1_.getPlayerTeam(); - ScorePlayerTeam scoreplayerteam1 = p_compare_2_.getPlayerTeam(); - return ComparisonChain - .start() - .compareTrueFirst( - p_compare_1_.getGameType() != WorldSettings.GameType.SPECTATOR, - p_compare_2_.getGameType() != WorldSettings.GameType.SPECTATOR - ) - .compare( - scoreplayerteam != null ? scoreplayerteam.getRegisteredName() : "", - scoreplayerteam1 != null ? scoreplayerteam1.getRegisteredName() : "" - ) - .compare( - p_compare_1_.getGameProfile().getName(), - p_compare_2_.getGameProfile().getName() - ) - .result(); + public int compare( + NetworkPlayerInfo p_compare_1_, + NetworkPlayerInfo p_compare_2_ + ) { + ScorePlayerTeam scoreplayerteam = p_compare_1_.getPlayerTeam(); + ScorePlayerTeam scoreplayerteam1 = p_compare_2_.getPlayerTeam(); + return ComparisonChain + .start() + .compareTrueFirst( + p_compare_1_.getGameType() != + WorldSettings.GameType.SPECTATOR, + p_compare_2_.getGameType() != + WorldSettings.GameType.SPECTATOR + ) + .compare( + scoreplayerteam != null + ? scoreplayerteam.getRegisteredName() + : "", + scoreplayerteam1 != null + ? scoreplayerteam1.getRegisteredName() + : "" + ) + .compare( + p_compare_1_.getGameProfile().getName(), + p_compare_2_.getGameProfile().getName() + ) + .result(); + } } - } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/GuiTextures.java b/src/main/java/com/thatgravyboat/skyblockhud/GuiTextures.java index 927b7c0..d7c2513 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/GuiTextures.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/GuiTextures.java @@ -4,82 +4,82 @@ import net.minecraft.util.ResourceLocation; public class GuiTextures { - private GuiTextures() {} + private GuiTextures() {} - public static final ResourceLocation DISCORD = new ResourceLocation( - "skyblockhud:discord.png" - ); - public static final ResourceLocation TWITTER = new ResourceLocation( - "skyblockhud:twitter.png" - ); + public static final ResourceLocation DISCORD = new ResourceLocation( + "skyblockhud:discord.png" + ); + public static final ResourceLocation TWITTER = new ResourceLocation( + "skyblockhud:twitter.png" + ); - public static final ResourceLocation button_tex = new ResourceLocation( - "skyblockhud:button.png" - ); + public static final ResourceLocation button_tex = new ResourceLocation( + "skyblockhud:button.png" + ); - public static final ResourceLocation button_white = new ResourceLocation( - "skyblockhud:button_white.png" - ); + public static final ResourceLocation button_white = new ResourceLocation( + "skyblockhud:button_white.png" + ); - public static final ResourceLocation BAR = new ResourceLocation( - "skyblockhud:core/bar.png" - ); - public static final ResourceLocation OFF = new ResourceLocation( - "skyblockhud:core/toggle_off.png" - ); - public static final ResourceLocation ONE = new ResourceLocation( - "skyblockhud:core/toggle_1.png" - ); - public static final ResourceLocation TWO = new ResourceLocation( - "skyblockhud:core/toggle_2.png" - ); - public static final ResourceLocation THREE = new ResourceLocation( - "skyblockhud:core/toggle_3.png" - ); - public static final ResourceLocation ON = new ResourceLocation( - "skyblockhud:core/toggle_on.png" - ); + public static final ResourceLocation BAR = new ResourceLocation( + "skyblockhud:core/bar.png" + ); + public static final ResourceLocation OFF = new ResourceLocation( + "skyblockhud:core/toggle_off.png" + ); + public static final ResourceLocation ONE = new ResourceLocation( + "skyblockhud:core/toggle_1.png" + ); + public static final ResourceLocation TWO = new ResourceLocation( + "skyblockhud:core/toggle_2.png" + ); + public static final ResourceLocation THREE = new ResourceLocation( + "skyblockhud:core/toggle_3.png" + ); + public static final ResourceLocation ON = new ResourceLocation( + "skyblockhud:core/toggle_on.png" + ); - public static final ResourceLocation slider_off_cap = new ResourceLocation( - "skyblockhud:core/slider/slider_off_cap.png" - ); - public static final ResourceLocation slider_off_notch = new ResourceLocation( - "skyblockhud:core/slider/slider_off_notch.png" - ); - public static final ResourceLocation slider_off_segment = new ResourceLocation( - "skyblockhud:core/slider/slider_off_segment.png" - ); - public static final ResourceLocation slider_on_cap = new ResourceLocation( - "skyblockhud:core/slider/slider_on_cap.png" - ); - public static final ResourceLocation slider_on_notch = new ResourceLocation( - "skyblockhud:core/slider/slider_on_notch.png" - ); - public static final ResourceLocation slider_on_segment = new ResourceLocation( - "skyblockhud:core/slider/slider_on_segment.png" - ); - public static final ResourceLocation slider_button_new = new ResourceLocation( - "skyblockhud:core/slider/slider_button.png" - ); + public static final ResourceLocation slider_off_cap = new ResourceLocation( + "skyblockhud:core/slider/slider_off_cap.png" + ); + public static final ResourceLocation slider_off_notch = new ResourceLocation( + "skyblockhud:core/slider/slider_off_notch.png" + ); + public static final ResourceLocation slider_off_segment = new ResourceLocation( + "skyblockhud:core/slider/slider_off_segment.png" + ); + public static final ResourceLocation slider_on_cap = new ResourceLocation( + "skyblockhud:core/slider/slider_on_cap.png" + ); + public static final ResourceLocation slider_on_notch = new ResourceLocation( + "skyblockhud:core/slider/slider_on_notch.png" + ); + public static final ResourceLocation slider_on_segment = new ResourceLocation( + "skyblockhud:core/slider/slider_on_segment.png" + ); + public static final ResourceLocation slider_button_new = new ResourceLocation( + "skyblockhud:core/slider/slider_button.png" + ); - public static final ResourceLocation overlay = new ResourceLocation( - "skyblockhud", - "stats.png" - ); - public static final ResourceLocation dungeon = new ResourceLocation( - "skyblockhud", - "dungeon.png" - ); - public static final ResourceLocation playerStat = new ResourceLocation( - "skyblockhud", - "playerstats.png" - ); - public static final ResourceLocation bars = new ResourceLocation( - "skyblockhud", - "bars.png" - ); - public static final ResourceLocation mapOverlay = new ResourceLocation( - "skyblockhud", - "maps/map_overlay.png" - ); + public static final ResourceLocation overlay = new ResourceLocation( + "skyblockhud", + "stats.png" + ); + public static final ResourceLocation dungeon = new ResourceLocation( + "skyblockhud", + "dungeon.png" + ); + public static final ResourceLocation playerStat = new ResourceLocation( + "skyblockhud", + "playerstats.png" + ); + public static final ResourceLocation bars = new ResourceLocation( + "skyblockhud", + "bars.png" + ); + public static final ResourceLocation mapOverlay = new ResourceLocation( + "skyblockhud", + "maps/map_overlay.png" + ); } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/SkyblockHud.java b/src/main/java/com/thatgravyboat/skyblockhud/SkyblockHud.java index 7d06d99..dae040c 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/SkyblockHud.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/SkyblockHud.java @@ -44,105 +44,105 @@ import org.lwjgl.input.Keyboard; @Mod(modid = SkyblockHud.MODID, version = SkyblockHud.VERSION) public class SkyblockHud { - public static final String MODID = "skyblockhud"; - public static final String VERSION = "1.12"; - - public static SBHConfig config; - - private File configFile; - - private static final Set SKYBLOCK_IN_ALL_LANGUAGES = Sets.newHashSet( - "SKYBLOCK", - "\u7A7A\u5C9B\u751F\u5B58" - ); - - private final Gson gson = new GsonBuilder() - .setPrettyPrinting() - .excludeFieldsWithoutExposeAnnotation() - .create(); - - private static File configDirectory; - - @EventHandler - public void preInit(FMLPreInitializationEvent event) { - MinecraftForge.EVENT_BUS.register(this); - MinecraftForge.EVENT_BUS.register(new LeaderboardGetter()); - MinecraftForge.EVENT_BUS.register(new SeasonDateHandler()); - MinecraftForge.EVENT_BUS.register(new LocationHandler()); - MinecraftForge.EVENT_BUS.register(new IslandHandler()); - MinecraftForge.EVENT_BUS.register(new TimeHandler()); - MinecraftForge.EVENT_BUS.register(new CurrencyHandler()); - MinecraftForge.EVENT_BUS.register(new SlayerHandler()); - MinecraftForge.EVENT_BUS.register(new DungeonHandler()); - MinecraftForge.EVENT_BUS.register(new DwarvenMineHandler()); - MinecraftForge.EVENT_BUS.register(new FarmingIslandHandler()); + public static final String MODID = "skyblockhud"; + public static final String VERSION = "1.12"; - /* DISABLE UNTIL NEW SYSTEM + public static SBHConfig config; + + private File configFile; + + private static final Set SKYBLOCK_IN_ALL_LANGUAGES = Sets.newHashSet( + "SKYBLOCK", + "\u7A7A\u5C9B\u751F\u5B58" + ); + + private final Gson gson = new GsonBuilder() + .setPrettyPrinting() + .excludeFieldsWithoutExposeAnnotation() + .create(); + + private static File configDirectory; + + @EventHandler + public void preInit(FMLPreInitializationEvent event) { + MinecraftForge.EVENT_BUS.register(this); + MinecraftForge.EVENT_BUS.register(new LeaderboardGetter()); + MinecraftForge.EVENT_BUS.register(new SeasonDateHandler()); + MinecraftForge.EVENT_BUS.register(new LocationHandler()); + MinecraftForge.EVENT_BUS.register(new IslandHandler()); + MinecraftForge.EVENT_BUS.register(new TimeHandler()); + MinecraftForge.EVENT_BUS.register(new CurrencyHandler()); + MinecraftForge.EVENT_BUS.register(new SlayerHandler()); + MinecraftForge.EVENT_BUS.register(new DungeonHandler()); + MinecraftForge.EVENT_BUS.register(new DwarvenMineHandler()); + MinecraftForge.EVENT_BUS.register(new FarmingIslandHandler()); + + /* DISABLE UNTIL NEW SYSTEM MinecraftForge.EVENT_BUS.register(new TrackerHandler()); MinecraftForge.EVENT_BUS.register(new KillTrackerHandler()); */ - MinecraftForge.EVENT_BUS.register(new HeldItemHandler()); - - ClientRegistry.registerKeyBinding(KeyBindings.map); - - MinecraftForge.EVENT_BUS.register(new ComponentHandler()); - MinecraftForge.EVENT_BUS.register(new ActionBarParsing()); - Commands.init(); - - configFile = - new File(event.getModConfigurationDirectory(), "sbh-config.json"); - - if (configFile.exists()) { - try ( - BufferedReader reader = new BufferedReader( - new InputStreamReader( - new FileInputStream(configFile), - StandardCharsets.UTF_8 - ) - ) - ) { - config = gson.fromJson(reader, SBHConfig.class); - } catch (Exception ignored) {} + MinecraftForge.EVENT_BUS.register(new HeldItemHandler()); + + ClientRegistry.registerKeyBinding(KeyBindings.map); + + MinecraftForge.EVENT_BUS.register(new ComponentHandler()); + MinecraftForge.EVENT_BUS.register(new ActionBarParsing()); + Commands.init(); + + configFile = + new File(event.getModConfigurationDirectory(), "sbh-config.json"); + + if (configFile.exists()) { + try ( + BufferedReader reader = new BufferedReader( + new InputStreamReader( + new FileInputStream(configFile), + StandardCharsets.UTF_8 + ) + ) + ) { + config = gson.fromJson(reader, SBHConfig.class); + } catch (Exception ignored) {} + } + + if (config == null) { + config = new SBHConfig(); + saveConfig(); + } + + configDirectory = event.getModConfigurationDirectory(); + + Runtime.getRuntime().addShutdownHook(new Thread(this::saveConfig)); + //Runtime.getRuntime().addShutdownHook(new Thread(() -> TrackerFileLoader.saveTrackerStatsFile(event.getModConfigurationDirectory()))); } - if (config == null) { - config = new SBHConfig(); - saveConfig(); + public void saveConfig() { + try { + configFile.createNewFile(); + + try ( + BufferedWriter writer = new BufferedWriter( + new OutputStreamWriter( + new FileOutputStream(configFile), + StandardCharsets.UTF_8 + ) + ) + ) { + writer.write(gson.toJson(config)); + } + } catch (IOException ignored) {} } - configDirectory = event.getModConfigurationDirectory(); - - Runtime.getRuntime().addShutdownHook(new Thread(this::saveConfig)); - //Runtime.getRuntime().addShutdownHook(new Thread(() -> TrackerFileLoader.saveTrackerStatsFile(event.getModConfigurationDirectory()))); - } - - public void saveConfig() { - try { - configFile.createNewFile(); - - try ( - BufferedWriter writer = new BufferedWriter( - new OutputStreamWriter( - new FileOutputStream(configFile), - StandardCharsets.UTF_8 - ) - ) - ) { - writer.write(gson.toJson(config)); - } - } catch (IOException ignored) {} - } - - @EventHandler - public void postInit(FMLPostInitializationEvent event) { - MinecraftForge.EVENT_BUS.register(new OverlayHud()); - MinecraftForge.EVENT_BUS.register(new RPGHud()); - MinecraftForge.EVENT_BUS.register(new DungeonOverlay()); - MinecraftForge.EVENT_BUS.register(new BossbarHandler()); - MinecraftForge.EVENT_BUS.register(new MapHandler()); - } - - /* DISABLE UNTIL NEW SYSTEM + @EventHandler + public void postInit(FMLPostInitializationEvent event) { + MinecraftForge.EVENT_BUS.register(new OverlayHud()); + MinecraftForge.EVENT_BUS.register(new RPGHud()); + MinecraftForge.EVENT_BUS.register(new DungeonOverlay()); + MinecraftForge.EVENT_BUS.register(new BossbarHandler()); + MinecraftForge.EVENT_BUS.register(new MapHandler()); + } + + /* DISABLE UNTIL NEW SYSTEM @EventHandler public void loadComplete(FMLLoadCompleteEvent event){ @@ -160,67 +160,72 @@ public class SkyblockHud { */ - public static boolean hasSkyblockScoreboard() { - Minecraft mc = Minecraft.getMinecraft(); - - if (mc != null && mc.theWorld != null) { - Scoreboard scoreboard = mc.theWorld.getScoreboard(); - ScoreObjective sidebarObjective = scoreboard.getObjectiveInDisplaySlot(1); - if (sidebarObjective != null) { - String objectiveName = sidebarObjective - .getDisplayName() - .replaceAll("(?i)\\u00A7.", ""); - for (String skyblock : SKYBLOCK_IN_ALL_LANGUAGES) { - if (objectiveName.startsWith(skyblock)) { - return true; - } + public static boolean hasSkyblockScoreboard() { + Minecraft mc = Minecraft.getMinecraft(); + + if (mc != null && mc.theWorld != null) { + Scoreboard scoreboard = mc.theWorld.getScoreboard(); + ScoreObjective sidebarObjective = scoreboard.getObjectiveInDisplaySlot( + 1 + ); + if (sidebarObjective != null) { + String objectiveName = sidebarObjective + .getDisplayName() + .replaceAll("(?i)\\u00A7.", ""); + for (String skyblock : SKYBLOCK_IN_ALL_LANGUAGES) { + if (objectiveName.startsWith(skyblock)) { + return true; + } + } + } } - } + + return false; } - return false; - } - - @SubscribeEvent - public void onTooltip(ItemTooltipEvent event) { - if (event.itemStack != null && Keyboard.isKeyDown(Keyboard.KEY_BACKSLASH)) { - try { - StringSelection clipboard = new StringSelection( - event.itemStack.serializeNBT().toString() - ); - Toolkit - .getDefaultToolkit() - .getSystemClipboard() - .setContents(clipboard, clipboard); - } catch (Exception ignored) {} + @SubscribeEvent + public void onTooltip(ItemTooltipEvent event) { + if ( + event.itemStack != null && + Keyboard.isKeyDown(Keyboard.KEY_BACKSLASH) + ) { + try { + StringSelection clipboard = new StringSelection( + event.itemStack.serializeNBT().toString() + ); + Toolkit + .getDefaultToolkit() + .getSystemClipboard() + .setContents(clipboard, clipboard); + } catch (Exception ignored) {} + } } - } - - @SubscribeEvent(priority = EventPriority.HIGHEST) - public void onStatusBar(ClientChatReceivedEvent event) { - if ( - Utils - .removeColor(event.message.getUnformattedText()) - .toLowerCase() - .trim() - .startsWith("your profile was changed to:") - ) { - MinecraftForge.EVENT_BUS.post(new ProfileSwitchedEvent()); + + @SubscribeEvent(priority = EventPriority.HIGHEST) + public void onStatusBar(ClientChatReceivedEvent event) { + if ( + Utils + .removeColor(event.message.getUnformattedText()) + .toLowerCase() + .trim() + .startsWith("your profile was changed to:") + ) { + MinecraftForge.EVENT_BUS.post(new ProfileSwitchedEvent()); + } } - } - - public static GuiScreen screenToOpen = null; - private static int screenTicks = 0; - - @SubscribeEvent - public void onClientTick(TickEvent.ClientTickEvent event) { - if (screenToOpen != null) { - screenTicks++; - if (screenTicks == 5) { - Minecraft.getMinecraft().displayGuiScreen(screenToOpen); - screenTicks = 0; - screenToOpen = null; - } + + public static GuiScreen screenToOpen = null; + private static int screenTicks = 0; + + @SubscribeEvent + public void onClientTick(TickEvent.ClientTickEvent event) { + if (screenToOpen != null) { + screenTicks++; + if (screenTicks == 5) { + Minecraft.getMinecraft().displayGuiScreen(screenToOpen); + screenTicks = 0; + screenToOpen = null; + } + } } - } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/SpecialColour.java b/src/main/java/com/thatgravyboat/skyblockhud/SpecialColour.java index 06dd70c..f675778 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/SpecialColour.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/SpecialColour.java @@ -4,111 +4,116 @@ import java.awt.*; public class SpecialColour { - public static String special(int chromaSpeed, int alpha, int rgb) { - return special( - chromaSpeed, - alpha, - (rgb & 0xFF0000) >> 16, - (rgb & 0x00FF00) >> 8, - (rgb & 0x0000FF) - ); - } - - private static final int RADIX = 10; - - public static String special( - int chromaSpeed, - int alpha, - int r, - int g, - int b - ) { - StringBuilder sb = new StringBuilder(); - sb.append(Integer.toString(chromaSpeed, RADIX)).append(":"); - sb.append(Integer.toString(alpha, RADIX)).append(":"); - sb.append(Integer.toString(r, RADIX)).append(":"); - sb.append(Integer.toString(g, RADIX)).append(":"); - sb.append(Integer.toString(b, RADIX)); - return sb.toString(); - } - - private static int[] decompose(String csv) { - String[] split = csv.split(":"); - - int[] arr = new int[split.length]; - - for (int i = 0; i < split.length; i++) { - arr[i] = Integer.parseInt(split[split.length - 1 - i], RADIX); + public static String special(int chromaSpeed, int alpha, int rgb) { + return special( + chromaSpeed, + alpha, + (rgb & 0xFF0000) >> 16, + (rgb & 0x00FF00) >> 8, + (rgb & 0x0000FF) + ); } - return arr; - } - - public static int specialToSimpleRGB(String special) { - int[] d = decompose(special); - int r = d[2]; - int g = d[1]; - int b = d[0]; - int a = d[3]; - int chr = d[4]; - - return (a & 0xFF) << 24 | (r & 0xFF) << 16 | (g & 0xFF) << 8 | (b & 0xFF); - } - - public static int getSpeed(String special) { - return decompose(special)[4]; - } - - public static float getSecondsForSpeed(int speed) { - return ( - (255 - speed) / - 254f * - (MAX_CHROMA_SECS - MIN_CHROMA_SECS) + - MIN_CHROMA_SECS - ); - } - - private static final int MIN_CHROMA_SECS = 1; - private static final int MAX_CHROMA_SECS = 60; - - public static long startTime = -1; - - public static int specialToChromaRGB(String special) { - if (startTime < 0) startTime = System.currentTimeMillis(); - - int[] d = decompose(special); - int chr = d[4]; - int a = d[3]; - int r = d[2]; - int g = d[1]; - int b = d[0]; - - float[] hsv = Color.RGBtoHSB(r, g, b, null); - - if (chr > 0) { - float seconds = getSecondsForSpeed(chr); - hsv[0] += (System.currentTimeMillis() - startTime) / 1000f / seconds; - hsv[0] %= 1; - if (hsv[0] < 0) hsv[0] += 1; + + private static final int RADIX = 10; + + public static String special( + int chromaSpeed, + int alpha, + int r, + int g, + int b + ) { + StringBuilder sb = new StringBuilder(); + sb.append(Integer.toString(chromaSpeed, RADIX)).append(":"); + sb.append(Integer.toString(alpha, RADIX)).append(":"); + sb.append(Integer.toString(r, RADIX)).append(":"); + sb.append(Integer.toString(g, RADIX)).append(":"); + sb.append(Integer.toString(b, RADIX)); + return sb.toString(); + } + + private static int[] decompose(String csv) { + String[] split = csv.split(":"); + + int[] arr = new int[split.length]; + + for (int i = 0; i < split.length; i++) { + arr[i] = Integer.parseInt(split[split.length - 1 - i], RADIX); + } + return arr; } - return ( - (a & 0xFF) << 24 | (Color.HSBtoRGB(hsv[0], hsv[1], hsv[2]) & 0x00FFFFFF) - ); - } + public static int specialToSimpleRGB(String special) { + int[] d = decompose(special); + int r = d[2]; + int g = d[1]; + int b = d[0]; + int a = d[3]; + int chr = d[4]; + + return ( + (a & 0xFF) << 24 | (r & 0xFF) << 16 | (g & 0xFF) << 8 | (b & 0xFF) + ); + } + + public static int getSpeed(String special) { + return decompose(special)[4]; + } + + public static float getSecondsForSpeed(int speed) { + return ( + (255 - speed) / + 254f * + (MAX_CHROMA_SECS - MIN_CHROMA_SECS) + + MIN_CHROMA_SECS + ); + } - public static int rotateHue(int argb, int degrees) { - int a = (argb >> 24) & 0xFF; - int r = (argb >> 16) & 0xFF; - int g = (argb >> 8) & 0xFF; - int b = (argb) & 0xFF; + private static final int MIN_CHROMA_SECS = 1; + private static final int MAX_CHROMA_SECS = 60; - float[] hsv = Color.RGBtoHSB(r, g, b, null); + public static long startTime = -1; - hsv[0] += degrees / 360f; - hsv[0] %= 1; + public static int specialToChromaRGB(String special) { + if (startTime < 0) startTime = System.currentTimeMillis(); - return ( - (a & 0xFF) << 24 | (Color.HSBtoRGB(hsv[0], hsv[1], hsv[2]) & 0x00FFFFFF) - ); - } + int[] d = decompose(special); + int chr = d[4]; + int a = d[3]; + int r = d[2]; + int g = d[1]; + int b = d[0]; + + float[] hsv = Color.RGBtoHSB(r, g, b, null); + + if (chr > 0) { + float seconds = getSecondsForSpeed(chr); + hsv[0] += + (System.currentTimeMillis() - startTime) / 1000f / seconds; + hsv[0] %= 1; + if (hsv[0] < 0) hsv[0] += 1; + } + + return ( + (a & 0xFF) << 24 | + (Color.HSBtoRGB(hsv[0], hsv[1], hsv[2]) & 0x00FFFFFF) + ); + } + + public static int rotateHue(int argb, int degrees) { + int a = (argb >> 24) & 0xFF; + int r = (argb >> 16) & 0xFF; + int g = (argb >> 8) & 0xFF; + int b = (argb) & 0xFF; + + float[] hsv = Color.RGBtoHSB(r, g, b, null); + + hsv[0] += degrees / 360f; + hsv[0] %= 1; + + return ( + (a & 0xFF) << 24 | + (Color.HSBtoRGB(hsv[0], hsv[1], hsv[2]) & 0x00FFFFFF) + ); + } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/Utils.java b/src/main/java/com/thatgravyboat/skyblockhud/Utils.java index c52af7c..9f6712c 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/Utils.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/Utils.java @@ -22,404 +22,410 @@ import org.lwjgl.opengl.GL14; public class Utils { - private static LinkedList guiScales = new LinkedList<>(); - private static ScaledResolution lastScale = new ScaledResolution( - Minecraft.getMinecraft() - ); - //Labymod compatibility - private static FloatBuffer projectionMatrixOld = BufferUtils.createFloatBuffer( - 16 - ); - private static FloatBuffer modelviewMatrixOld = BufferUtils.createFloatBuffer( - 16 - ); - - public static String removeColor(String input) { - return input.replaceAll("(?i)\\u00A7.", ""); - } - - public static String removeWhiteSpaceAndRemoveWord( - String input, - String replace - ) { - return input.toLowerCase().replace(" ", "").replace(replace, ""); - } - - public static boolean isPlayerHoldingRedstone(EntityPlayerSP player) { - if (!SkyblockHud.config.main.requireRedstone) return true; - ArrayList redstoneItems = new ArrayList<>( - Arrays.asList( - Items.redstone, - Items.repeater, - Items.comparator, - Item.getByNameOrId("minecraft:redstone_torch") - ) + private static LinkedList guiScales = new LinkedList<>(); + private static ScaledResolution lastScale = new ScaledResolution( + Minecraft.getMinecraft() ); - if (player.getHeldItem() != null) return redstoneItems.contains( - player.getHeldItem().getItem() + //Labymod compatibility + private static FloatBuffer projectionMatrixOld = BufferUtils.createFloatBuffer( + 16 ); - return false; - } - - public static boolean inRangeInclusive(int value, int min, int max) { - return value <= max && value >= min; - } - - public static int whatRomanNumeral(String roman) { - switch (roman.toLowerCase()) { - case "i": - return 1; - case "ii": - return 2; - case "iii": - return 3; - case "iv": - return 4; - case "v": - return 5; - case "vi": - return 6; - case "vii": - return 7; - case "viii": - return 8; - case "ix": - return 9; - case "x": - return 10; - default: - return 0; + private static FloatBuffer modelviewMatrixOld = BufferUtils.createFloatBuffer( + 16 + ); + + public static String removeColor(String input) { + return input.replaceAll("(?i)\\u00A7.", ""); } - } - - public static String intToRomanNumeral(int i) { - switch (i) { - case 1: - return "I"; - case 2: - return "II"; - case 3: - return "III"; - case 4: - return "IV"; - case 5: - return "V"; - case 6: - return "VI"; - case 7: - return "VII"; - case 8: - return "VIII"; - case 9: - return "IX"; - case 10: - return "X"; - default: - return ""; + + public static String removeWhiteSpaceAndRemoveWord( + String input, + String replace + ) { + return input.toLowerCase().replace(" ", "").replace(replace, ""); } - } - - public static boolean overlayShouldRender( - RenderGameOverlayEvent.ElementType type, - boolean... booleans - ) { - return overlayShouldRender( - false, - type, - RenderGameOverlayEvent.ElementType.HOTBAR, - booleans - ); - } - - public static boolean overlayShouldRender( - boolean hideOnf3, - RenderGameOverlayEvent.ElementType type, - RenderGameOverlayEvent.ElementType checkType, - boolean... booleans - ) { - Minecraft mc = Minecraft.getMinecraft(); - boolean shouldRender; - if (booleans.length > 1) { - for (boolean aBoolean : booleans) if (!aBoolean) return false; - shouldRender = true; - } else shouldRender = booleans.length != 1 || booleans[0]; - if (hideOnf3) { - if ( - mc.gameSettings.showDebugInfo || - ( - mc.gameSettings.keyBindPlayerList.isKeyDown() && - ( - !mc.isIntegratedServerRunning() || - mc.thePlayer.sendQueue.getPlayerInfoMap().size() > 1 - ) - ) - ) { + + public static boolean isPlayerHoldingRedstone(EntityPlayerSP player) { + if (!SkyblockHud.config.main.requireRedstone) return true; + ArrayList redstoneItems = new ArrayList<>( + Arrays.asList( + Items.redstone, + Items.repeater, + Items.comparator, + Item.getByNameOrId("minecraft:redstone_torch") + ) + ); + if (player.getHeldItem() != null) return redstoneItems.contains( + player.getHeldItem().getItem() + ); return false; - } } - return ( - shouldRender && - ((type == null && Loader.isModLoaded("labymod")) || type == checkType) - ); - } - - public static void drawStringScaledMaxWidth( - String str, - FontRenderer fr, - float x, - float y, - boolean shadow, - int len, - int colour - ) { - int strLen = fr.getStringWidth(str); - float factor = len / (float) strLen; - factor = Math.min(1, factor); - - drawStringScaled(str, fr, x, y, shadow, colour, factor); - } - - public static void drawStringScaled( - String str, - FontRenderer fr, - float x, - float y, - boolean shadow, - int colour, - float factor - ) { - GlStateManager.scale(factor, factor, 1); - fr.drawString(str, x / factor, y / factor, colour, shadow); - GlStateManager.scale(1 / factor, 1 / factor, 1); - } - - public static void drawStringCenteredScaled( - String str, - FontRenderer fr, - float x, - float y, - boolean shadow, - int len, - int colour - ) { - int strLen = fr.getStringWidth(str); - float factor = len / (float) strLen; - float fontHeight = 8 * factor; - - drawStringScaled( - str, - fr, - x - len / 2f, - y - fontHeight / 2f, - shadow, - colour, - factor - ); - } - - public static void drawTexturedRect( - float x, - float y, - float width, - float height, - float uMin, - float uMax, - float vMin, - float vMax, - int filter - ) { - GlStateManager.enableTexture2D(); - GlStateManager.enableBlend(); - GL14.glBlendFuncSeparate( - GL11.GL_SRC_ALPHA, - GL11.GL_ONE_MINUS_SRC_ALPHA, - GL11.GL_ONE, - GL11.GL_ONE_MINUS_SRC_ALPHA - ); - GL11.glTexParameteri( - GL11.GL_TEXTURE_2D, - GL11.GL_TEXTURE_MIN_FILTER, - filter - ); - GL11.glTexParameteri( - GL11.GL_TEXTURE_2D, - GL11.GL_TEXTURE_MAG_FILTER, - filter - ); + public static boolean inRangeInclusive(int value, int min, int max) { + return value <= max && value >= min; + } - Tessellator tessellator = Tessellator.getInstance(); - WorldRenderer worldrenderer = tessellator.getWorldRenderer(); - worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX); - worldrenderer.pos(x, y + height, 0.0D).tex(uMin, vMax).endVertex(); - worldrenderer.pos(x + width, y + height, 0.0D).tex(uMax, vMax).endVertex(); - worldrenderer.pos(x + width, y, 0.0D).tex(uMax, vMin).endVertex(); - worldrenderer.pos(x, y, 0.0D).tex(uMin, vMin).endVertex(); - tessellator.draw(); - - GL11.glTexParameteri( - GL11.GL_TEXTURE_2D, - GL11.GL_TEXTURE_MIN_FILTER, - GL11.GL_NEAREST - ); - GL11.glTexParameteri( - GL11.GL_TEXTURE_2D, - GL11.GL_TEXTURE_MAG_FILTER, - GL11.GL_NEAREST - ); + public static int whatRomanNumeral(String roman) { + switch (roman.toLowerCase()) { + case "i": + return 1; + case "ii": + return 2; + case "iii": + return 3; + case "iv": + return 4; + case "v": + return 5; + case "vi": + return 6; + case "vii": + return 7; + case "viii": + return 8; + case "ix": + return 9; + case "x": + return 10; + default: + return 0; + } + } - GlStateManager.disableBlend(); - } - - public static void drawTexturedRect( - float x, - float y, - float width, - float height - ) { - drawTexturedRect(x, y, width, height, 0, 1, 0, 1); - } - - public static void drawTexturedRect( - float x, - float y, - float width, - float height, - int filter - ) { - drawTexturedRect(x, y, width, height, 0, 1, 0, 1, filter); - } - - public static void drawTexturedRect( - float x, - float y, - float width, - float height, - float uMin, - float uMax, - float vMin, - float vMax - ) { - drawTexturedRect( - x, - y, - width, - height, - uMin, - uMax, - vMin, - vMax, - GL11.GL_LINEAR - ); - } - - public static void resetGuiScale() { - guiScales.clear(); - } - - public static ScaledResolution peekGuiScale() { - return lastScale; - } - - public static ScaledResolution pushGuiScale(int scale) { - if (guiScales.size() == 0) { - if (Loader.isModLoaded("labymod")) { - GL11.glGetFloat(GL11.GL_PROJECTION_MATRIX, projectionMatrixOld); - GL11.glGetFloat(GL11.GL_MODELVIEW_MATRIX, modelviewMatrixOld); - } + public static String intToRomanNumeral(int i) { + switch (i) { + case 1: + return "I"; + case 2: + return "II"; + case 3: + return "III"; + case 4: + return "IV"; + case 5: + return "V"; + case 6: + return "VI"; + case 7: + return "VII"; + case 8: + return "VIII"; + case 9: + return "IX"; + case 10: + return "X"; + default: + return ""; + } + } + + public static boolean overlayShouldRender( + RenderGameOverlayEvent.ElementType type, + boolean... booleans + ) { + return overlayShouldRender( + false, + type, + RenderGameOverlayEvent.ElementType.HOTBAR, + booleans + ); + } + + public static boolean overlayShouldRender( + boolean hideOnf3, + RenderGameOverlayEvent.ElementType type, + RenderGameOverlayEvent.ElementType checkType, + boolean... booleans + ) { + Minecraft mc = Minecraft.getMinecraft(); + boolean shouldRender; + if (booleans.length > 1) { + for (boolean aBoolean : booleans) if (!aBoolean) return false; + shouldRender = true; + } else shouldRender = booleans.length != 1 || booleans[0]; + if (hideOnf3) { + if ( + mc.gameSettings.showDebugInfo || + ( + mc.gameSettings.keyBindPlayerList.isKeyDown() && + ( + !mc.isIntegratedServerRunning() || + mc.thePlayer.sendQueue.getPlayerInfoMap().size() > 1 + ) + ) + ) { + return false; + } + } + return ( + shouldRender && + ( + (type == null && Loader.isModLoaded("labymod")) || + type == checkType + ) + ); } - if (scale < 0) { - if (guiScales.size() > 0) { - guiScales.pop(); - } - } else { - if (scale == 0) { - guiScales.push(Minecraft.getMinecraft().gameSettings.guiScale); - } else { - guiScales.push(scale); - } + public static void drawStringScaledMaxWidth( + String str, + FontRenderer fr, + float x, + float y, + boolean shadow, + int len, + int colour + ) { + int strLen = fr.getStringWidth(str); + float factor = len / (float) strLen; + factor = Math.min(1, factor); + + drawStringScaled(str, fr, x, y, shadow, colour, factor); } - int newScale = guiScales.size() > 0 - ? Math.max(0, Math.min(4, guiScales.peek())) - : Minecraft.getMinecraft().gameSettings.guiScale; - if (newScale == 0) newScale = - Minecraft.getMinecraft().gameSettings.guiScale; + public static void drawStringScaled( + String str, + FontRenderer fr, + float x, + float y, + boolean shadow, + int colour, + float factor + ) { + GlStateManager.scale(factor, factor, 1); + fr.drawString(str, x / factor, y / factor, colour, shadow); + GlStateManager.scale(1 / factor, 1 / factor, 1); + } - int oldScale = Minecraft.getMinecraft().gameSettings.guiScale; - Minecraft.getMinecraft().gameSettings.guiScale = newScale; - ScaledResolution scaledresolution = new ScaledResolution( - Minecraft.getMinecraft() - ); - Minecraft.getMinecraft().gameSettings.guiScale = oldScale; - - if (guiScales.size() > 0) { - GlStateManager.viewport( - 0, - 0, - Minecraft.getMinecraft().displayWidth, - Minecraft.getMinecraft().displayHeight - ); - GlStateManager.matrixMode(GL11.GL_PROJECTION); - GlStateManager.loadIdentity(); - GlStateManager.ortho( - 0.0D, - scaledresolution.getScaledWidth_double(), - scaledresolution.getScaledHeight_double(), - 0.0D, - 1000.0D, - 3000.0D - ); - GlStateManager.matrixMode(GL11.GL_MODELVIEW); - GlStateManager.loadIdentity(); - GlStateManager.translate(0.0F, 0.0F, -2000.0F); - } else { - if ( - Loader.isModLoaded("labymod") && - projectionMatrixOld.limit() > 0 && - modelviewMatrixOld.limit() > 0 - ) { - GlStateManager.matrixMode(GL11.GL_PROJECTION); - GL11.glLoadMatrix(projectionMatrixOld); - GlStateManager.matrixMode(GL11.GL_MODELVIEW); - GL11.glLoadMatrix(modelviewMatrixOld); - } else { - GlStateManager.matrixMode(GL11.GL_PROJECTION); - GlStateManager.loadIdentity(); - GlStateManager.ortho( - 0.0D, - scaledresolution.getScaledWidth_double(), - scaledresolution.getScaledHeight_double(), - 0.0D, - 1000.0D, - 3000.0D + public static void drawStringCenteredScaled( + String str, + FontRenderer fr, + float x, + float y, + boolean shadow, + int len, + int colour + ) { + int strLen = fr.getStringWidth(str); + float factor = len / (float) strLen; + float fontHeight = 8 * factor; + + drawStringScaled( + str, + fr, + x - len / 2f, + y - fontHeight / 2f, + shadow, + colour, + factor ); - GlStateManager.matrixMode(GL11.GL_MODELVIEW); - GlStateManager.loadIdentity(); - GlStateManager.translate(0.0F, 0.0F, -2000.0F); - } } - lastScale = scaledresolution; - return scaledresolution; - } - - public static void drawStringCentered( - String str, - FontRenderer fr, - float x, - float y, - boolean shadow, - int colour - ) { - int strLen = fr.getStringWidth(str); - - float x2 = x - strLen / 2f; - float y2 = y - fr.FONT_HEIGHT / 2f; - - GL11.glTranslatef(x2, y2, 0); - fr.drawString(str, 0, 0, colour, shadow); - GL11.glTranslatef(-x2, -y2, 0); - } + public static void drawTexturedRect( + float x, + float y, + float width, + float height, + float uMin, + float uMax, + float vMin, + float vMax, + int filter + ) { + GlStateManager.enableTexture2D(); + GlStateManager.enableBlend(); + GL14.glBlendFuncSeparate( + GL11.GL_SRC_ALPHA, + GL11.GL_ONE_MINUS_SRC_ALPHA, + GL11.GL_ONE, + GL11.GL_ONE_MINUS_SRC_ALPHA + ); + + GL11.glTexParameteri( + GL11.GL_TEXTURE_2D, + GL11.GL_TEXTURE_MIN_FILTER, + filter + ); + GL11.glTexParameteri( + GL11.GL_TEXTURE_2D, + GL11.GL_TEXTURE_MAG_FILTER, + filter + ); + + Tessellator tessellator = Tessellator.getInstance(); + WorldRenderer worldrenderer = tessellator.getWorldRenderer(); + worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX); + worldrenderer.pos(x, y + height, 0.0D).tex(uMin, vMax).endVertex(); + worldrenderer + .pos(x + width, y + height, 0.0D) + .tex(uMax, vMax) + .endVertex(); + worldrenderer.pos(x + width, y, 0.0D).tex(uMax, vMin).endVertex(); + worldrenderer.pos(x, y, 0.0D).tex(uMin, vMin).endVertex(); + tessellator.draw(); + + GL11.glTexParameteri( + GL11.GL_TEXTURE_2D, + GL11.GL_TEXTURE_MIN_FILTER, + GL11.GL_NEAREST + ); + GL11.glTexParameteri( + GL11.GL_TEXTURE_2D, + GL11.GL_TEXTURE_MAG_FILTER, + GL11.GL_NEAREST + ); + + GlStateManager.disableBlend(); + } + + public static void drawTexturedRect( + float x, + float y, + float width, + float height + ) { + drawTexturedRect(x, y, width, height, 0, 1, 0, 1); + } + + public static void drawTexturedRect( + float x, + float y, + float width, + float height, + int filter + ) { + drawTexturedRect(x, y, width, height, 0, 1, 0, 1, filter); + } + + public static void drawTexturedRect( + float x, + float y, + float width, + float height, + float uMin, + float uMax, + float vMin, + float vMax + ) { + drawTexturedRect( + x, + y, + width, + height, + uMin, + uMax, + vMin, + vMax, + GL11.GL_LINEAR + ); + } + + public static void resetGuiScale() { + guiScales.clear(); + } + + public static ScaledResolution peekGuiScale() { + return lastScale; + } + + public static ScaledResolution pushGuiScale(int scale) { + if (guiScales.size() == 0) { + if (Loader.isModLoaded("labymod")) { + GL11.glGetFloat(GL11.GL_PROJECTION_MATRIX, projectionMatrixOld); + GL11.glGetFloat(GL11.GL_MODELVIEW_MATRIX, modelviewMatrixOld); + } + } + + if (scale < 0) { + if (guiScales.size() > 0) { + guiScales.pop(); + } + } else { + if (scale == 0) { + guiScales.push(Minecraft.getMinecraft().gameSettings.guiScale); + } else { + guiScales.push(scale); + } + } + + int newScale = guiScales.size() > 0 + ? Math.max(0, Math.min(4, guiScales.peek())) + : Minecraft.getMinecraft().gameSettings.guiScale; + if (newScale == 0) newScale = + Minecraft.getMinecraft().gameSettings.guiScale; + + int oldScale = Minecraft.getMinecraft().gameSettings.guiScale; + Minecraft.getMinecraft().gameSettings.guiScale = newScale; + ScaledResolution scaledresolution = new ScaledResolution( + Minecraft.getMinecraft() + ); + Minecraft.getMinecraft().gameSettings.guiScale = oldScale; + + if (guiScales.size() > 0) { + GlStateManager.viewport( + 0, + 0, + Minecraft.getMinecraft().displayWidth, + Minecraft.getMinecraft().displayHeight + ); + GlStateManager.matrixMode(GL11.GL_PROJECTION); + GlStateManager.loadIdentity(); + GlStateManager.ortho( + 0.0D, + scaledresolution.getScaledWidth_double(), + scaledresolution.getScaledHeight_double(), + 0.0D, + 1000.0D, + 3000.0D + ); + GlStateManager.matrixMode(GL11.GL_MODELVIEW); + GlStateManager.loadIdentity(); + GlStateManager.translate(0.0F, 0.0F, -2000.0F); + } else { + if ( + Loader.isModLoaded("labymod") && + projectionMatrixOld.limit() > 0 && + modelviewMatrixOld.limit() > 0 + ) { + GlStateManager.matrixMode(GL11.GL_PROJECTION); + GL11.glLoadMatrix(projectionMatrixOld); + GlStateManager.matrixMode(GL11.GL_MODELVIEW); + GL11.glLoadMatrix(modelviewMatrixOld); + } else { + GlStateManager.matrixMode(GL11.GL_PROJECTION); + GlStateManager.loadIdentity(); + GlStateManager.ortho( + 0.0D, + scaledresolution.getScaledWidth_double(), + scaledresolution.getScaledHeight_double(), + 0.0D, + 1000.0D, + 3000.0D + ); + GlStateManager.matrixMode(GL11.GL_MODELVIEW); + GlStateManager.loadIdentity(); + GlStateManager.translate(0.0F, 0.0F, -2000.0F); + } + } + + lastScale = scaledresolution; + return scaledresolution; + } + + public static void drawStringCentered( + String str, + FontRenderer fr, + float x, + float y, + boolean shadow, + int colour + ) { + int strLen = fr.getStringWidth(str); + + float x2 = x - strLen / 2f; + float y2 = y - fr.FONT_HEIGHT / 2f; + + GL11.glTranslatef(x2, y2, 0); + fr.drawString(str, 0, 0, colour, shadow); + GL11.glTranslatef(-x2, -y2, 0); + } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/api/LeaderboardGetter.java b/src/main/java/com/thatgravyboat/skyblockhud/api/LeaderboardGetter.java index 0833a0d..b722df1 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/api/LeaderboardGetter.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/api/LeaderboardGetter.java @@ -19,79 +19,96 @@ import net.minecraftforge.fml.common.gameevent.TickEvent; public class LeaderboardGetter { - private static Map cachedScores = new HashMap<>(); - private static List cachedScoresList = new ArrayList<>(); + private static Map cachedScores = new HashMap<>(); + private static List cachedScoresList = new ArrayList<>(); - private static int ticks = 0; + private static int ticks = 0; - @SubscribeEvent - public void onClientUpdate(TickEvent.ClientTickEvent event) { - if (event.phase.equals(TickEvent.Phase.START)) return; - ticks++; - if (ticks % 5 != 0) return; + @SubscribeEvent + public void onClientUpdate(TickEvent.ClientTickEvent event) { + if (event.phase.equals(TickEvent.Phase.START)) return; + ticks++; + if (ticks % 5 != 0) return; - Minecraft mc = Minecraft.getMinecraft(); - if (mc.theWorld != null) { - Scoreboard scoreboard = mc.theWorld.getScoreboard(); - ScoreObjective sidebarObjective = scoreboard.getObjectiveInDisplaySlot(1); + Minecraft mc = Minecraft.getMinecraft(); + if (mc.theWorld != null) { + Scoreboard scoreboard = mc.theWorld.getScoreboard(); + ScoreObjective sidebarObjective = scoreboard.getObjectiveInDisplaySlot( + 1 + ); - if ( - sidebarObjective != null && - !MinecraftForge.EVENT_BUS.post( - new SidebarPreGetEvent(scoreboard, sidebarObjective) - ) - ) { - Collection scoreList = sidebarObjective - .getScoreboard() - .getSortedScores(sidebarObjective); - Map scores = scoreList - .stream() - .collect(Collectors.toMap(Score::getScorePoints, this::getLine)); + if ( + sidebarObjective != null && + !MinecraftForge.EVENT_BUS.post( + new SidebarPreGetEvent(scoreboard, sidebarObjective) + ) + ) { + Collection scoreList = sidebarObjective + .getScoreboard() + .getSortedScores(sidebarObjective); + Map scores = scoreList + .stream() + .collect( + Collectors.toMap(Score::getScorePoints, this::getLine) + ); - if (!cachedScores.equals(scores)) { - scores.forEach( - (score, name) -> { - if ( - cachedScores.get(score) == null || - !cachedScores.get(score).equals(name) - ) { + if (!cachedScores.equals(scores)) { + scores.forEach( + (score, name) -> { + if ( + cachedScores.get(score) == null || + !cachedScores.get(score).equals(name) + ) { + MinecraftForge.EVENT_BUS.post( + new SidebarLineUpdateEvent( + name, + SCOREBOARD_CHARACTERS + .matcher(name) + .replaceAll("") + .trim(), + score, + scores.size(), + scoreboard, + sidebarObjective + ) + ); + } + } + ); + cachedScores = scores; + cachedScoresList = + scores + .values() + .stream() + .map( + name -> + SCOREBOARD_CHARACTERS + .matcher(name) + .replaceAll("") + .trim() + ) + .collect(Collectors.toList()); + } MinecraftForge.EVENT_BUS.post( - new SidebarLineUpdateEvent( - name, - SCOREBOARD_CHARACTERS.matcher(name).replaceAll("").trim(), - score, - scores.size(), - scoreboard, - sidebarObjective - ) + new SidebarPostEvent( + scoreboard, + sidebarObjective, + cachedScoresList + ) ); - } } - ); - cachedScores = scores; - cachedScoresList = - scores - .values() - .stream() - .map( - name -> - SCOREBOARD_CHARACTERS.matcher(name).replaceAll("").trim() - ) - .collect(Collectors.toList()); } - MinecraftForge.EVENT_BUS.post( - new SidebarPostEvent(scoreboard, sidebarObjective, cachedScoresList) - ); - } } - } - public String getLine(Score score) { - ScorePlayerTeam scorePlayerTeam = score - .getScoreScoreboard() - .getPlayersTeam(score.getPlayerName()); - return Utils.removeColor( - ScorePlayerTeam.formatPlayerName(scorePlayerTeam, score.getPlayerName()) - ); - } + public String getLine(Score score) { + ScorePlayerTeam scorePlayerTeam = score + .getScoreScoreboard() + .getPlayersTeam(score.getPlayerName()); + return Utils.removeColor( + ScorePlayerTeam.formatPlayerName( + scorePlayerTeam, + score.getPlayerName() + ) + ); + } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/api/events/SidebarLineUpdateEvent.java b/src/main/java/com/thatgravyboat/skyblockhud/api/events/SidebarLineUpdateEvent.java index 843ad05..8a7aa39 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/api/events/SidebarLineUpdateEvent.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/api/events/SidebarLineUpdateEvent.java @@ -6,24 +6,24 @@ import net.minecraftforge.fml.common.eventhandler.Event; public class SidebarLineUpdateEvent extends Event { - public String rawLine; - public String formattedLine; - public int position; - public Scoreboard scoreboard; - public ScoreObjective objective; + public String rawLine; + public String formattedLine; + public int position; + public Scoreboard scoreboard; + public ScoreObjective objective; - public SidebarLineUpdateEvent( - String rawLine, - String formattedLine, - int score, - int max, - Scoreboard scoreboard, - ScoreObjective objective - ) { - this.rawLine = rawLine; - this.formattedLine = formattedLine; - this.position = max - score; - this.scoreboard = scoreboard; - this.objective = objective; - } + public SidebarLineUpdateEvent( + String rawLine, + String formattedLine, + int score, + int max, + Scoreboard scoreboard, + ScoreObjective objective + ) { + this.rawLine = rawLine; + this.formattedLine = formattedLine; + this.position = max - score; + this.scoreboard = scoreboard; + this.objective = objective; + } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/api/events/SidebarPostEvent.java b/src/main/java/com/thatgravyboat/skyblockhud/api/events/SidebarPostEvent.java index b020e12..92ed25e 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/api/events/SidebarPostEvent.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/api/events/SidebarPostEvent.java @@ -7,19 +7,19 @@ import net.minecraftforge.fml.common.eventhandler.Event; public class SidebarPostEvent extends Event { - public Scoreboard scoreboard; - public ScoreObjective objective; - public List scores; - public String[] arrayScores; + public Scoreboard scoreboard; + public ScoreObjective objective; + public List scores; + public String[] arrayScores; - public SidebarPostEvent( - Scoreboard scoreboard, - ScoreObjective objective, - List scores - ) { - this.scoreboard = scoreboard; - this.objective = objective; - this.scores = scores; - this.arrayScores = scores.toArray(new String[] {}); - } + public SidebarPostEvent( + Scoreboard scoreboard, + ScoreObjective objective, + List scores + ) { + this.scoreboard = scoreboard; + this.objective = objective; + this.scores = scores; + this.arrayScores = scores.toArray(new String[] {}); + } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/api/events/SidebarPreGetEvent.java b/src/main/java/com/thatgravyboat/skyblockhud/api/events/SidebarPreGetEvent.java index 1176b9a..0db1895 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/api/events/SidebarPreGetEvent.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/api/events/SidebarPreGetEvent.java @@ -8,11 +8,11 @@ import net.minecraftforge.fml.common.eventhandler.Event; @Cancelable public class SidebarPreGetEvent extends Event { - public Scoreboard scoreboard; - public ScoreObjective objective; + public Scoreboard scoreboard; + public ScoreObjective objective; - public SidebarPreGetEvent(Scoreboard scoreboard, ScoreObjective objective) { - this.scoreboard = scoreboard; - this.objective = objective; - } + public SidebarPreGetEvent(Scoreboard scoreboard, ScoreObjective objective) { + this.scoreboard = scoreboard; + this.objective = objective; + } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/commands/Commands.java b/src/main/java/com/thatgravyboat/skyblockhud/commands/Commands.java index 3e1c995..e09f324 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/commands/Commands.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/commands/Commands.java @@ -12,48 +12,57 @@ import org.apache.commons.lang3.StringUtils; public class Commands { - private static final SimpleCommand.ProcessCommandRunnable settingsRunnable = new SimpleCommand.ProcessCommandRunnable() { - public void processCommand(ICommandSender sender, String[] args) { - if (args.length > 0) { - SkyblockHud.screenToOpen = - new GuiScreenElementWrapper( - new SBHConfigEditor(SkyblockHud.config, StringUtils.join(args, " ")) - ); - } else { - SkyblockHud.screenToOpen = - new GuiScreenElementWrapper(new SBHConfigEditor(SkyblockHud.config)); - } - } - }; + private static final SimpleCommand.ProcessCommandRunnable settingsRunnable = new SimpleCommand.ProcessCommandRunnable() { + public void processCommand(ICommandSender sender, String[] args) { + if (args.length > 0) { + SkyblockHud.screenToOpen = + new GuiScreenElementWrapper( + new SBHConfigEditor( + SkyblockHud.config, + StringUtils.join(args, " ") + ) + ); + } else { + SkyblockHud.screenToOpen = + new GuiScreenElementWrapper( + new SBHConfigEditor(SkyblockHud.config) + ); + } + } + }; - private static final SimpleCommand settingsCommand = new SimpleCommand( - "sbh", - settingsRunnable - ); - private static final SimpleCommand settingsCommand2 = new SimpleCommand( - "sbhsettings", - settingsRunnable - ); - private static final SimpleCommand settingsCommand3 = new SimpleCommand( - "sbhud", - settingsRunnable - ); + private static final SimpleCommand settingsCommand = new SimpleCommand( + "sbh", + settingsRunnable + ); + private static final SimpleCommand settingsCommand2 = new SimpleCommand( + "sbhsettings", + settingsRunnable + ); + private static final SimpleCommand settingsCommand3 = new SimpleCommand( + "sbhud", + settingsRunnable + ); - private static final SimpleCommand mapCommand = new SimpleCommand( - "sbhmap", - new SimpleCommand.ProcessCommandRunnable() { - public void processCommand(ICommandSender sender, String[] args) { - if ( - LocationHandler.getCurrentLocation().getCategory().getMap() != null - ) SkyblockHud.screenToOpen = new MapHandler.MapScreen(); - } - } - ); + private static final SimpleCommand mapCommand = new SimpleCommand( + "sbhmap", + new SimpleCommand.ProcessCommandRunnable() { + public void processCommand(ICommandSender sender, String[] args) { + if ( + LocationHandler + .getCurrentLocation() + .getCategory() + .getMap() != + null + ) SkyblockHud.screenToOpen = new MapHandler.MapScreen(); + } + } + ); - public static void init() { - ClientCommandHandler.instance.registerCommand(settingsCommand); - ClientCommandHandler.instance.registerCommand(settingsCommand2); - ClientCommandHandler.instance.registerCommand(settingsCommand3); - ClientCommandHandler.instance.registerCommand(mapCommand); - } + public static void init() { + ClientCommandHandler.instance.registerCommand(settingsCommand); + ClientCommandHandler.instance.registerCommand(settingsCommand2); + ClientCommandHandler.instance.registerCommand(settingsCommand3); + ClientCommandHandler.instance.registerCommand(mapCommand); + } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/commands/SimpleCommand.java b/src/main/java/com/thatgravyboat/skyblockhud/commands/SimpleCommand.java index 49a02a8..358ebe0 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/commands/SimpleCommand.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/commands/SimpleCommand.java @@ -11,62 +11,69 @@ import net.minecraft.util.BlockPos; **/ public class SimpleCommand extends CommandBase { - private String commandName; - private ProcessCommandRunnable runnable; - private TabCompleteRunnable tabRunnable; + private String commandName; + private ProcessCommandRunnable runnable; + private TabCompleteRunnable tabRunnable; - public SimpleCommand(String commandName, ProcessCommandRunnable runnable) { - this.commandName = commandName; - this.runnable = runnable; - } + public SimpleCommand(String commandName, ProcessCommandRunnable runnable) { + this.commandName = commandName; + this.runnable = runnable; + } - public SimpleCommand( - String commandName, - ProcessCommandRunnable runnable, - TabCompleteRunnable tabRunnable - ) { - this.commandName = commandName; - this.runnable = runnable; - this.tabRunnable = tabRunnable; - } + public SimpleCommand( + String commandName, + ProcessCommandRunnable runnable, + TabCompleteRunnable tabRunnable + ) { + this.commandName = commandName; + this.runnable = runnable; + this.tabRunnable = tabRunnable; + } - public abstract static class ProcessCommandRunnable { + public abstract static class ProcessCommandRunnable { - public abstract void processCommand(ICommandSender sender, String[] args); - } + public abstract void processCommand( + ICommandSender sender, + String[] args + ); + } - public abstract static class TabCompleteRunnable { + public abstract static class TabCompleteRunnable { - public abstract List tabComplete( - ICommandSender sender, - String[] args, - BlockPos pos - ); - } + public abstract List tabComplete( + ICommandSender sender, + String[] args, + BlockPos pos + ); + } - public boolean canCommandSenderUseCommand(ICommandSender sender) { - return true; - } + public boolean canCommandSenderUseCommand(ICommandSender sender) { + return true; + } - public String getCommandName() { - return commandName; - } + public String getCommandName() { + return commandName; + } - public String getCommandUsage(ICommandSender sender) { - return "/" + commandName; - } + public String getCommandUsage(ICommandSender sender) { + return "/" + commandName; + } - public void processCommand(ICommandSender sender, String[] args) - throws CommandException { - runnable.processCommand(sender, args); - } + public void processCommand(ICommandSender sender, String[] args) + throws CommandException { + runnable.processCommand(sender, args); + } - public List addTabCompletionOptions( - ICommandSender sender, - String[] args, - BlockPos pos - ) { - if (tabRunnable != null) return tabRunnable.tabComplete(sender, args, pos); - return null; - } + public List addTabCompletionOptions( + ICommandSender sender, + String[] args, + BlockPos pos + ) { + if (tabRunnable != null) return tabRunnable.tabComplete( + sender, + args, + pos + ); + return null; + } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/config/KeyBindings.java b/src/main/java/com/thatgravyboat/skyblockhud/config/KeyBindings.java index 511ab86..044bab9 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/config/KeyBindings.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/config/KeyBindings.java @@ -4,9 +4,9 @@ import net.minecraft.client.settings.KeyBinding; public class KeyBindings { - public static KeyBinding map = new KeyBinding( - "Opens the big map.", - 50, - "SkyblockHud" - ); + public static KeyBinding map = new KeyBinding( + "Opens the big map.", + 50, + "SkyblockHud" + ); } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/config/SBHConfig.java b/src/main/java/com/thatgravyboat/skyblockhud/config/SBHConfig.java index 031f2b7..52272b7 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/config/SBHConfig.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/config/SBHConfig.java @@ -11,404 +11,440 @@ import net.minecraft.client.Minecraft; public class SBHConfig extends Config { - private void editOverlay( - String activeConfig, - int width, - int height, - Position position - ) { - Minecraft - .getMinecraft() - .displayGuiScreen( - new GuiPositionEditor( - position, - width, - height, - () -> {}, - () -> {}, - () -> - SkyblockHud.screenToOpen = - new GuiScreenElementWrapper( - new SBHConfigEditor(SkyblockHud.config, activeConfig) - ) - ) - ); - } - - @Override - public void executeRunnable(String runnableId) { - String activeConfigCategory = null; - if ( - Minecraft.getMinecraft().currentScreen instanceof GuiScreenElementWrapper + private void editOverlay( + String activeConfig, + int width, + int height, + Position position ) { - GuiScreenElementWrapper wrapper = (GuiScreenElementWrapper) Minecraft.getMinecraft() - .currentScreen; - if (wrapper.element instanceof SBHConfigEditor) { - activeConfigCategory = - ((SBHConfigEditor) wrapper.element).getSelectedCategoryName(); - } + Minecraft + .getMinecraft() + .displayGuiScreen( + new GuiPositionEditor( + position, + width, + height, + () -> {}, + () -> {}, + () -> + SkyblockHud.screenToOpen = + new GuiScreenElementWrapper( + new SBHConfigEditor( + SkyblockHud.config, + activeConfig + ) + ) + ) + ); } - switch (runnableId) { - case "rpg": - editOverlay(activeConfigCategory, 120, 47, rpg.rpgHudPosition); - return; - case "d1": - editOverlay(activeConfigCategory, 120, 32, dungeon.dungeonPlayer1); - return; - case "d2": - editOverlay(activeConfigCategory, 120, 32, dungeon.dungeonPlayer2); - return; - case "d3": - editOverlay(activeConfigCategory, 120, 32, dungeon.dungeonPlayer3); - return; - case "d4": - editOverlay(activeConfigCategory, 120, 32, dungeon.dungeonPlayer4); - return; - case "main": - editOverlay(activeConfigCategory, 1000, 34, main.mainHudPos); - return; - case "ultimate": - editOverlay(activeConfigCategory, 182, 5, dungeon.barPosition); - return; - case "map": - editOverlay(activeConfigCategory, 72, 72, map.miniMapPosition); - return; - case "tracker": - editOverlay(activeConfigCategory, 120, 70, trackers.trackerPosition); - return; + @Override + public void executeRunnable(String runnableId) { + String activeConfigCategory = null; + if ( + Minecraft.getMinecraft() + .currentScreen instanceof GuiScreenElementWrapper + ) { + GuiScreenElementWrapper wrapper = (GuiScreenElementWrapper) Minecraft.getMinecraft() + .currentScreen; + if (wrapper.element instanceof SBHConfigEditor) { + activeConfigCategory = + ( + (SBHConfigEditor) wrapper.element + ).getSelectedCategoryName(); + } + } + + switch (runnableId) { + case "rpg": + editOverlay(activeConfigCategory, 120, 47, rpg.rpgHudPosition); + return; + case "d1": + editOverlay( + activeConfigCategory, + 120, + 32, + dungeon.dungeonPlayer1 + ); + return; + case "d2": + editOverlay( + activeConfigCategory, + 120, + 32, + dungeon.dungeonPlayer2 + ); + return; + case "d3": + editOverlay( + activeConfigCategory, + 120, + 32, + dungeon.dungeonPlayer3 + ); + return; + case "d4": + editOverlay( + activeConfigCategory, + 120, + 32, + dungeon.dungeonPlayer4 + ); + return; + case "main": + editOverlay(activeConfigCategory, 1000, 34, main.mainHudPos); + return; + case "ultimate": + editOverlay(activeConfigCategory, 182, 5, dungeon.barPosition); + return; + case "map": + editOverlay(activeConfigCategory, 72, 72, map.miniMapPosition); + return; + case "tracker": + editOverlay( + activeConfigCategory, + 120, + 70, + trackers.trackerPosition + ); + return; + } } - } - - @Expose - @Category(name = "Misc Options", desc = "Just a bunch of random options.") - public Misc misc = new Misc(); - - @Expose - @Category(name = "Main Hud", desc = "All Options for the main hud.") - public MainHud main = new MainHud(); - - @Expose - @Category(name = "RPG Hud", desc = "All Options for the RPG hud.") - public RPGHud rpg = new RPGHud(); - - @Expose - @Category(name = "Dungeon Hud", desc = "All Options for the Dungeon hud.") - public DungeonHud dungeon = new DungeonHud(); - - @Expose - @Category(name = "Renderer", desc = "All Options for rendering.") - public Renderer renderer = new Renderer(); - - @Expose - @Category(name = "Map", desc = "All Options for the Map.") - public Map map = new Map(); - - @Expose - @Category(name = "Tracker", desc = "All Options for the Trackers.") - public Trackers trackers = new Trackers(); - - public static class Misc { @Expose - @ConfigOption( - name = "Hide Scoreboard", - desc = "Hides the scoreboard when in skyblock." - ) - @ConfigEditorBoolean - public boolean hideScoreboard = false; - } - - public static class MainHud { + @Category(name = "Misc Options", desc = "Just a bunch of random options.") + public Misc misc = new Misc(); @Expose - @ConfigOption(name = "Main Hud Position", desc = "") - @ConfigEditorButton(runnableId = "main", buttonText = "Edit") - public Position mainHudPos = new Position(0, 1, true, false); + @Category(name = "Main Hud", desc = "All Options for the main hud.") + public MainHud main = new MainHud(); @Expose - @ConfigOption( - name = "Twelve Hour Clock", - desc = "Allows you to change the clock to be 12 hour instead of 24 hour." - ) - @ConfigEditorBoolean - public boolean twelveHourClock = false; + @Category(name = "RPG Hud", desc = "All Options for the RPG hud.") + public RPGHud rpg = new RPGHud(); @Expose - @ConfigOption( - name = "Shift hud with boss", - desc = "Shifts the hud when bossbar is visible." - ) - @ConfigEditorBoolean - public boolean bossShiftHud = true; + @Category(name = "Dungeon Hud", desc = "All Options for the Dungeon hud.") + public DungeonHud dungeon = new DungeonHud(); @Expose - @ConfigOption( - name = "Require Redstone", - desc = "Allows to make it so that the redstone percentage requires you to hold a redstone item to show." - ) - @ConfigEditorBoolean - public boolean requireRedstone = true; - } - - public static class RPGHud { + @Category(name = "Renderer", desc = "All Options for rendering.") + public Renderer renderer = new Renderer(); @Expose - @ConfigOption( - name = "Show RPG Hud", - desc = "Allows you to show or hide the RPG Hud." - ) - @ConfigEditorBoolean - public boolean showRpgHud = true; + @Category(name = "Map", desc = "All Options for the Map.") + public Map map = new Map(); @Expose - @ConfigOption( - name = "RPG Hud Position", - desc = "Allows you to change the position of the RPG Hud." - ) - @ConfigEditorButton(runnableId = "rpg", buttonText = "Edit") - public Position rpgHudPosition = new Position(1, 1); - } - - public static class DungeonHud { + @Category(name = "Tracker", desc = "All Options for the Trackers.") + public Trackers trackers = new Trackers(); - @Expose - @ConfigOption(name = "Dungeon Ultimate Bar", desc = "") - @ConfigEditorAccordion(id = 2) - public boolean ultimateBar = false; - - @Expose - @ConfigOption( - name = "Hide Ultimate Bar", - desc = "Hides the custom ultimate bar." - ) - @ConfigEditorBoolean - @ConfigAccordionId(id = 2) - public boolean hideUltimateBar = false; - - @Expose - @ConfigOption( - name = "Bar Position", - desc = "Change the position of the bar." - ) - @ConfigEditorButton(runnableId = "ultimate", buttonText = "Edit") - @ConfigAccordionId(id = 2) - public Position barPosition = new Position(0, 50, true, false); - - @Expose - @ConfigOption( - name = "Bar Loading Color", - desc = "The color of the bar when its loading." - ) - @ConfigEditorColour - @ConfigAccordionId(id = 2) - public String barLoadColor = "159:0:0:0:255"; - - @Expose - @ConfigOption( - name = "Bar Full Color", - desc = "The color of the bar when its full." - ) - @ConfigEditorColour - @ConfigAccordionId(id = 2) - public String barFullColor = "255:0:0:0:255"; - - @Expose - @ConfigOption(name = "Bar Style", desc = "Change the style of the bar") - @ConfigEditorDropdown( - values = { "No Notch", "6 Notch", "10 Notch", "12 Notch", "20 Notch" } - ) - @ConfigAccordionId(id = 2) - public int barStyle = 2; + public static class Misc { - @Expose - @ConfigOption(name = "Dungeon Players", desc = "") - @ConfigEditorAccordion(id = 1) - public boolean dungeonPlayerAccordion = false; - - @Expose - @ConfigOption( - name = "Hide Dungeon Players", - desc = "Allows you to hide the dungeon player hud" - ) - @ConfigEditorBoolean - @ConfigAccordionId(id = 1) - public boolean hideDungeonPlayers = false; - - @Expose - @ConfigOption( - name = "Dungeon Player Opacity", - desc = "Allows you to change the opacity of the dungeon players." - ) - @ConfigEditorSlider(minValue = 0, maxValue = 100, minStep = 1) - @ConfigAccordionId(id = 1) - public int dungeonPlayerOpacity = 0; - - @Expose - @ConfigOption( - name = "Hide Dead Players", - desc = "Allows you to hide players that are dead or have left." - ) - @ConfigEditorBoolean - @ConfigAccordionId(id = 1) - public boolean hideDeadDungeonPlayers = false; - - @Expose - @ConfigOption( - name = "Player Position 1", - desc = "Change the position of this dungeon player." - ) - @ConfigEditorButton(runnableId = "d1", buttonText = "Edit") - @ConfigAccordionId(id = 1) - public Position dungeonPlayer1 = new Position(5, 5); - - @Expose - @ConfigOption( - name = "Player Position 2", - desc = "Change the position of this dungeon player." - ) - @ConfigEditorButton(runnableId = "d2", buttonText = "Edit") - @ConfigAccordionId(id = 1) - public Position dungeonPlayer2 = new Position(5, 42); - - @Expose - @ConfigOption( - name = "Player Position 3", - desc = "Change the position of this dungeon player." - ) - @ConfigEditorButton(runnableId = "d3", buttonText = "Edit") - @ConfigAccordionId(id = 1) - public Position dungeonPlayer3 = new Position(5, 79); - - @Expose - @ConfigOption( - name = "Player Position 4", - desc = "Change the position of this dungeon player." - ) - @ConfigEditorButton(runnableId = "d4", buttonText = "Edit") - @ConfigAccordionId(id = 1) - public Position dungeonPlayer4 = new Position(5, 116); - } - - public static class Renderer { + @Expose + @ConfigOption( + name = "Hide Scoreboard", + desc = "Hides the scoreboard when in skyblock." + ) + @ConfigEditorBoolean + public boolean hideScoreboard = false; + } - @Expose - @ConfigOption( - name = "Hide Boss Bar", - desc = "Hides Boss Bar when certain conditions are met such as the name is just wither or it starts with objective:" - ) - @ConfigEditorBoolean - public boolean hideBossBar = true; + public static class MainHud { - @Expose - @ConfigOption(name = "Hide XP Bar", desc = "Hides xp bar.") - @ConfigEditorBoolean - public boolean hideXpBar = true; + @Expose + @ConfigOption(name = "Main Hud Position", desc = "") + @ConfigEditorButton(runnableId = "main", buttonText = "Edit") + public Position mainHudPos = new Position(0, 1, true, false); - @Expose - @ConfigOption(name = "Hide Food", desc = "Hides food.") - @ConfigEditorBoolean - public boolean hideFood = true; + @Expose + @ConfigOption( + name = "Twelve Hour Clock", + desc = "Allows you to change the clock to be 12 hour instead of 24 hour." + ) + @ConfigEditorBoolean + public boolean twelveHourClock = false; - @Expose - @ConfigOption(name = "Hide air", desc = "Hides air.") - @ConfigEditorBoolean - public boolean hideAir = true; + @Expose + @ConfigOption( + name = "Shift hud with boss", + desc = "Shifts the hud when bossbar is visible." + ) + @ConfigEditorBoolean + public boolean bossShiftHud = true; - @Expose - @ConfigOption(name = "Hide hearts", desc = "Hides hearts.") - @ConfigEditorBoolean - public boolean hideHearts = true; + @Expose + @ConfigOption( + name = "Require Redstone", + desc = "Allows to make it so that the redstone percentage requires you to hold a redstone item to show." + ) + @ConfigEditorBoolean + public boolean requireRedstone = true; + } - @Expose - @ConfigOption(name = "Hide armor", desc = "Hides armor.") - @ConfigEditorBoolean - public boolean hideArmor = true; + public static class RPGHud { - @Expose - @ConfigOption(name = "Hide Animal Hearts", desc = "Hides Animal Hearts.") - @ConfigEditorBoolean - public boolean hideAnimalHearts = true; - } + @Expose + @ConfigOption( + name = "Show RPG Hud", + desc = "Allows you to show or hide the RPG Hud." + ) + @ConfigEditorBoolean + public boolean showRpgHud = true; - public static class Map { + @Expose + @ConfigOption( + name = "RPG Hud Position", + desc = "Allows you to change the position of the RPG Hud." + ) + @ConfigEditorButton(runnableId = "rpg", buttonText = "Edit") + public Position rpgHudPosition = new Position(1, 1); + } - @Expose - @ConfigOption( - name = "Show Player Location", - desc = "This feature is off by default as Hypixel's rules are so vague that this would fall under their disallowed modifications." - ) - @ConfigEditorBoolean - public boolean showPlayerLocation = false; + public static class DungeonHud { - @Expose - @ConfigOption( - name = "Show Mini-Map", - desc = "Shows the Mini-Map on your overlay if turned off you can still use /sbhmap to see the map in fullscreen." - ) - @ConfigEditorBoolean - public boolean showMiniMap = false; + @Expose + @ConfigOption(name = "Dungeon Ultimate Bar", desc = "") + @ConfigEditorAccordion(id = 2) + public boolean ultimateBar = false; - @Expose - @ConfigOption( - name = "Mini-Map Position", - desc = "Allows you to change the position of the Mini-Map." - ) - @ConfigEditorButton(runnableId = "map", buttonText = "Edit") - public Position miniMapPosition = new Position(0, 100, false, false); + @Expose + @ConfigOption( + name = "Hide Ultimate Bar", + desc = "Hides the custom ultimate bar." + ) + @ConfigEditorBoolean + @ConfigAccordionId(id = 2) + public boolean hideUltimateBar = false; + + @Expose + @ConfigOption( + name = "Bar Position", + desc = "Change the position of the bar." + ) + @ConfigEditorButton(runnableId = "ultimate", buttonText = "Edit") + @ConfigAccordionId(id = 2) + public Position barPosition = new Position(0, 50, true, false); + + @Expose + @ConfigOption( + name = "Bar Loading Color", + desc = "The color of the bar when its loading." + ) + @ConfigEditorColour + @ConfigAccordionId(id = 2) + public String barLoadColor = "159:0:0:0:255"; + + @Expose + @ConfigOption( + name = "Bar Full Color", + desc = "The color of the bar when its full." + ) + @ConfigEditorColour + @ConfigAccordionId(id = 2) + public String barFullColor = "255:0:0:0:255"; + + @Expose + @ConfigOption(name = "Bar Style", desc = "Change the style of the bar") + @ConfigEditorDropdown( + values = { + "No Notch", "6 Notch", "10 Notch", "12 Notch", "20 Notch" + } + ) + @ConfigAccordionId(id = 2) + public int barStyle = 2; + + @Expose + @ConfigOption(name = "Dungeon Players", desc = "") + @ConfigEditorAccordion(id = 1) + public boolean dungeonPlayerAccordion = false; + + @Expose + @ConfigOption( + name = "Hide Dungeon Players", + desc = "Allows you to hide the dungeon player hud" + ) + @ConfigEditorBoolean + @ConfigAccordionId(id = 1) + public boolean hideDungeonPlayers = false; + + @Expose + @ConfigOption( + name = "Dungeon Player Opacity", + desc = "Allows you to change the opacity of the dungeon players." + ) + @ConfigEditorSlider(minValue = 0, maxValue = 100, minStep = 1) + @ConfigAccordionId(id = 1) + public int dungeonPlayerOpacity = 0; + + @Expose + @ConfigOption( + name = "Hide Dead Players", + desc = "Allows you to hide players that are dead or have left." + ) + @ConfigEditorBoolean + @ConfigAccordionId(id = 1) + public boolean hideDeadDungeonPlayers = false; + + @Expose + @ConfigOption( + name = "Player Position 1", + desc = "Change the position of this dungeon player." + ) + @ConfigEditorButton(runnableId = "d1", buttonText = "Edit") + @ConfigAccordionId(id = 1) + public Position dungeonPlayer1 = new Position(5, 5); + + @Expose + @ConfigOption( + name = "Player Position 2", + desc = "Change the position of this dungeon player." + ) + @ConfigEditorButton(runnableId = "d2", buttonText = "Edit") + @ConfigAccordionId(id = 1) + public Position dungeonPlayer2 = new Position(5, 42); + + @Expose + @ConfigOption( + name = "Player Position 3", + desc = "Change the position of this dungeon player." + ) + @ConfigEditorButton(runnableId = "d3", buttonText = "Edit") + @ConfigAccordionId(id = 1) + public Position dungeonPlayer3 = new Position(5, 79); + + @Expose + @ConfigOption( + name = "Player Position 4", + desc = "Change the position of this dungeon player." + ) + @ConfigEditorButton(runnableId = "d4", buttonText = "Edit") + @ConfigAccordionId(id = 1) + public Position dungeonPlayer4 = new Position(5, 116); + } - @Expose - @ConfigOption(name = "Icons", desc = "") - @ConfigEditorAccordion(id = 3) - public boolean icons = false; + public static class Renderer { - @Expose - @ConfigOption(name = "NPC", desc = "Show NPC Icons") - @ConfigEditorBoolean - @ConfigAccordionId(id = 3) - public boolean showNpcIcons = true; + @Expose + @ConfigOption( + name = "Hide Boss Bar", + desc = "Hides Boss Bar when certain conditions are met such as the name is just wither or it starts with objective:" + ) + @ConfigEditorBoolean + public boolean hideBossBar = true; + + @Expose + @ConfigOption(name = "Hide XP Bar", desc = "Hides xp bar.") + @ConfigEditorBoolean + public boolean hideXpBar = true; + + @Expose + @ConfigOption(name = "Hide Food", desc = "Hides food.") + @ConfigEditorBoolean + public boolean hideFood = true; + + @Expose + @ConfigOption(name = "Hide air", desc = "Hides air.") + @ConfigEditorBoolean + public boolean hideAir = true; + + @Expose + @ConfigOption(name = "Hide hearts", desc = "Hides hearts.") + @ConfigEditorBoolean + public boolean hideHearts = true; + + @Expose + @ConfigOption(name = "Hide armor", desc = "Hides armor.") + @ConfigEditorBoolean + public boolean hideArmor = true; + + @Expose + @ConfigOption( + name = "Hide Animal Hearts", + desc = "Hides Animal Hearts." + ) + @ConfigEditorBoolean + public boolean hideAnimalHearts = true; + } - @Expose - @ConfigOption(name = "Info", desc = "Show Info Icons") - @ConfigEditorBoolean - @ConfigAccordionId(id = 3) - public boolean showInfoIcons = true; + public static class Map { - @Expose - @ConfigOption(name = "Misc", desc = "Show Misc Icons") - @ConfigEditorBoolean - @ConfigAccordionId(id = 3) - public boolean showMiscIcons = true; + @Expose + @ConfigOption( + name = "Show Player Location", + desc = "This feature is off by default as Hypixel's rules are so vague that this would fall under their disallowed modifications." + ) + @ConfigEditorBoolean + public boolean showPlayerLocation = false; - @Expose - @ConfigOption(name = "Shops", desc = "Show Shop Icons") - @ConfigEditorBoolean - @ConfigAccordionId(id = 3) - public boolean showShopIcons = true; + @Expose + @ConfigOption( + name = "Show Mini-Map", + desc = "Shows the Mini-Map on your overlay if turned off you can still use /sbhmap to see the map in fullscreen." + ) + @ConfigEditorBoolean + public boolean showMiniMap = false; - @Expose - @ConfigOption(name = "Quests", desc = "Show Quest Icons") - @ConfigEditorBoolean - @ConfigAccordionId(id = 3) - public boolean showQuestIcons = false; - } + @Expose + @ConfigOption( + name = "Mini-Map Position", + desc = "Allows you to change the position of the Mini-Map." + ) + @ConfigEditorButton(runnableId = "map", buttonText = "Edit") + public Position miniMapPosition = new Position(0, 100, false, false); + + @Expose + @ConfigOption(name = "Icons", desc = "") + @ConfigEditorAccordion(id = 3) + public boolean icons = false; + + @Expose + @ConfigOption(name = "NPC", desc = "Show NPC Icons") + @ConfigEditorBoolean + @ConfigAccordionId(id = 3) + public boolean showNpcIcons = true; + + @Expose + @ConfigOption(name = "Info", desc = "Show Info Icons") + @ConfigEditorBoolean + @ConfigAccordionId(id = 3) + public boolean showInfoIcons = true; + + @Expose + @ConfigOption(name = "Misc", desc = "Show Misc Icons") + @ConfigEditorBoolean + @ConfigAccordionId(id = 3) + public boolean showMiscIcons = true; + + @Expose + @ConfigOption(name = "Shops", desc = "Show Shop Icons") + @ConfigEditorBoolean + @ConfigAccordionId(id = 3) + public boolean showShopIcons = true; + + @Expose + @ConfigOption(name = "Quests", desc = "Show Quest Icons") + @ConfigEditorBoolean + @ConfigAccordionId(id = 3) + public boolean showQuestIcons = false; + } - public static class Trackers { + public static class Trackers { - @Expose - @ConfigOption( - name = "Tracker Position", - desc = "Allows you to change the position of the Trackers." - ) - @ConfigEditorButton(runnableId = "tracker", buttonText = "Edit") - public Position trackerPosition = new Position(-1, 200); + @Expose + @ConfigOption( + name = "Tracker Position", + desc = "Allows you to change the position of the Trackers." + ) + @ConfigEditorButton(runnableId = "tracker", buttonText = "Edit") + public Position trackerPosition = new Position(-1, 200); - @Expose - @ConfigOption( - name = "Hide Tracker", - desc = "It will still track the data just in case." - ) - @ConfigEditorBoolean - public boolean hideTracker = false; - } + @Expose + @ConfigOption( + name = "Hide Tracker", + desc = "It will still track the data just in case." + ) + @ConfigEditorBoolean + public boolean hideTracker = false; + } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/config/SBHConfigEditor.java b/src/main/java/com/thatgravyboat/skyblockhud/config/SBHConfigEditor.java index dc0d8a0..0407607 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/config/SBHConfigEditor.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/config/SBHConfigEditor.java @@ -29,906 +29,979 @@ import org.lwjgl.opengl.GL11; public class SBHConfigEditor extends GuiElement { - private static final ResourceLocation[] socialsIco = new ResourceLocation[] { - DISCORD, - TWITTER - }; - private static final String[] socialsLink = new String[] { - "https://discord.gg/moulberry", - "https://twitter.com/thatgravytboat/" - }; + private static final ResourceLocation[] socialsIco = new ResourceLocation[] { + DISCORD, + TWITTER + }; + private static final String[] socialsLink = new String[] { + "https://discord.gg/moulberry", + "https://twitter.com/thatgravytboat/" + }; - private final long openedMillis; + private final long openedMillis; - private String selectedCategory = null; + private String selectedCategory = null; - private final LerpingInteger optionsScroll = new LerpingInteger(0, 150); - private final LerpingInteger categoryScroll = new LerpingInteger(0, 150); + private final LerpingInteger optionsScroll = new LerpingInteger(0, 150); + private final LerpingInteger categoryScroll = new LerpingInteger(0, 150); - private LinkedHashMap processedConfig; - private HashMap categoryForOption = new HashMap<>(); + private LinkedHashMap processedConfig; + private HashMap categoryForOption = new HashMap<>(); - public SBHConfigEditor(Config config) { - this(config, null); - } - - public SBHConfigEditor(Config config, String categoryOpen) { - this.openedMillis = System.currentTimeMillis(); - this.processedConfig = ConfigProcessor.create(config); - - for (ConfigProcessor.ProcessedCategory category : processedConfig.values()) { - for (ConfigProcessor.ProcessedOption option : category.options.values()) { - categoryForOption.put(option, category); - } + public SBHConfigEditor(Config config) { + this(config, null); } - if (categoryOpen != null) { - for (Map.Entry category : processedConfig.entrySet()) { - if (category.getValue().name.equalsIgnoreCase(categoryOpen)) { - selectedCategory = category.getKey(); - break; - } - } - if (selectedCategory == null) { - for (Map.Entry category : processedConfig.entrySet()) { - if ( - category - .getValue() - .name.toLowerCase() - .startsWith(categoryOpen.toLowerCase()) - ) { - selectedCategory = category.getKey(); - break; - } + public SBHConfigEditor(Config config, String categoryOpen) { + this.openedMillis = System.currentTimeMillis(); + this.processedConfig = ConfigProcessor.create(config); + + for (ConfigProcessor.ProcessedCategory category : processedConfig.values()) { + for (ConfigProcessor.ProcessedOption option : category.options.values()) { + categoryForOption.put(option, category); + } } - } - if (selectedCategory == null) { - for (Map.Entry category : processedConfig.entrySet()) { - if ( - category - .getValue() - .name.toLowerCase() - .contains(categoryOpen.toLowerCase()) - ) { - selectedCategory = category.getKey(); - break; - } + + if (categoryOpen != null) { + for (Map.Entry category : processedConfig.entrySet()) { + if (category.getValue().name.equalsIgnoreCase(categoryOpen)) { + selectedCategory = category.getKey(); + break; + } + } + if (selectedCategory == null) { + for (Map.Entry category : processedConfig.entrySet()) { + if ( + category + .getValue() + .name.toLowerCase() + .startsWith(categoryOpen.toLowerCase()) + ) { + selectedCategory = category.getKey(); + break; + } + } + } + if (selectedCategory == null) { + for (Map.Entry category : processedConfig.entrySet()) { + if ( + category + .getValue() + .name.toLowerCase() + .contains(categoryOpen.toLowerCase()) + ) { + selectedCategory = category.getKey(); + break; + } + } + } } - } - } - } - - private LinkedHashMap getCurrentConfigEditing() { - return new LinkedHashMap<>(processedConfig); - } - - private LinkedHashMap getOptionsInCategory( - ConfigProcessor.ProcessedCategory cat - ) { - return new LinkedHashMap<>(cat.options); - } - - public String getSelectedCategory() { - return selectedCategory; - } - - public String getSelectedCategoryName() { - return processedConfig.get(selectedCategory).name; - } - - private void setSelectedCategory(String category) { - selectedCategory = category; - optionsScroll.setValue(0); - } - - public void render() { - optionsScroll.tick(); - categoryScroll.tick(); - - List tooltipToDisplay = null; - - long currentTime = System.currentTimeMillis(); - long delta = currentTime - openedMillis; - - ScaledResolution scaledResolution = new ScaledResolution( - Minecraft.getMinecraft() - ); - int width = scaledResolution.getScaledWidth(); - int height = scaledResolution.getScaledHeight(); - int mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth; - int mouseY = - height - - Mouse.getY() * - height / - Minecraft.getMinecraft().displayHeight - - 1; - - float opacityFactor = LerpUtils.sigmoidZeroOne(delta / 500f); - RenderUtils.drawGradientRect( - 0, - 0, - 0, - width, - height, - (int) (0x80 * opacityFactor) << 24 | 0x101010, - (int) (0x90 * opacityFactor) << 24 | 0x101010 - ); - - int xSize = Math.min( - scaledResolution.getScaledWidth() - - 100 / - scaledResolution.getScaleFactor(), - 500 - ); - int ySize = Math.min( - scaledResolution.getScaledHeight() - - 100 / - scaledResolution.getScaleFactor(), - 400 - ); - - int x = (scaledResolution.getScaledWidth() - xSize) / 2; - int y = (scaledResolution.getScaledHeight() - ySize) / 2; - - int adjScaleFactor = Math.max(2, scaledResolution.getScaleFactor()); - - int openingXSize = xSize; - int openingYSize = ySize; - if (delta < 150) { - openingXSize = (int) (delta * xSize / 150); - openingYSize = 5; - } else if (delta < 300) { - openingYSize = 5 + (int) (delta - 150) * (ySize - 5) / 150; - } - RenderUtils.drawFloatingRectDark( - (scaledResolution.getScaledWidth() - openingXSize) / 2, - (scaledResolution.getScaledHeight() - openingYSize) / 2, - openingXSize, - openingYSize - ); - GlScissorStack.clear(); - GlScissorStack.push( - (scaledResolution.getScaledWidth() - openingXSize) / 2, - (scaledResolution.getScaledHeight() - openingYSize) / 2, - (scaledResolution.getScaledWidth() + openingXSize) / 2, - (scaledResolution.getScaledHeight() + openingYSize) / 2, - scaledResolution - ); - - RenderUtils.drawFloatingRectDark(x + 5, y + 5, xSize - 10, 20, false); - - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - TextRenderUtils.drawStringCenteredScaledMaxWidth( - "SkyBlockHud by " + - EnumChatFormatting.RED + - "ThatGravyBoat" + - EnumChatFormatting.RESET + - ", config by " + - EnumChatFormatting.DARK_PURPLE + - "Moulberry", - fr, - x + xSize / 2f, - y + 15, - false, - 200, - 0xa0a0a0 - ); - - RenderUtils.drawFloatingRectDark( - x + 4, - y + 49 - 20, - 140, - ySize - 54 + 20, - false - ); - - int innerPadding = 20 / adjScaleFactor; - int innerLeft = x + 4 + innerPadding; - int innerRight = x + 144 - innerPadding; - int innerTop = y + 49 + innerPadding; - int innerBottom = y + ySize - 5 - innerPadding; - Gui.drawRect(innerLeft, innerTop, innerLeft + 1, innerBottom, 0xff08080E); //Left - Gui.drawRect(innerLeft + 1, innerTop, innerRight, innerTop + 1, 0xff08080E); //Top - Gui.drawRect( - innerRight - 1, - innerTop + 1, - innerRight, - innerBottom, - 0xff28282E - ); //Right - Gui.drawRect( - innerLeft + 1, - innerBottom - 1, - innerRight - 1, - innerBottom, - 0xff28282E - ); //Bottom - Gui.drawRect( - innerLeft + 1, - innerTop + 1, - innerRight - 1, - innerBottom - 1, - 0x6008080E - ); //Middle - - GlScissorStack.push( - 0, - innerTop + 1, - scaledResolution.getScaledWidth(), - innerBottom - 1, - scaledResolution - ); - - float catBarSize = 1; - int catY = -categoryScroll.getValue(); - - LinkedHashMap currentConfigEditing = getCurrentConfigEditing(); - for (Map.Entry entry : currentConfigEditing.entrySet()) { - String selectedCategory = getSelectedCategory(); - if ( - selectedCategory == null || - !currentConfigEditing.containsKey(selectedCategory) - ) { - setSelectedCategory(entry.getKey()); - } - String catName = entry.getValue().name; - if (entry.getKey().equals(getSelectedCategory())) { - catName = - EnumChatFormatting.DARK_AQUA.toString() + - EnumChatFormatting.UNDERLINE + - catName; - } else { - catName = EnumChatFormatting.GRAY + catName; - } - TextRenderUtils.drawStringCenteredScaledMaxWidth( - catName, - fr, - x + 75, - y + 70 + catY, - false, - 100, - -1 - ); - catY += 15; - if (catY > 0) { - catBarSize = - LerpUtils.clampZeroOne( - (float) (innerBottom - innerTop - 2) / - (catY + 5 + categoryScroll.getValue()) - ); - } } - float catBarStart = - categoryScroll.getValue() / (float) (catY + categoryScroll.getValue()); - float catBarEnd = catBarStart + catBarSize; - if (catBarEnd > 1) { - catBarEnd = 1; - if ( - categoryScroll.getTarget() / - (float) (catY + categoryScroll.getValue()) + - catBarSize < - 1 - ) { - int target = optionsScroll.getTarget(); - categoryScroll.setValue( - (int) Math.ceil( - (catY + 5 + categoryScroll.getValue()) - - catBarSize * - (catY + 5 + categoryScroll.getValue()) - ) - ); - categoryScroll.setTarget(target); - } else { - categoryScroll.setValue( - (int) Math.ceil( - (catY + 5 + categoryScroll.getValue()) - - catBarSize * - (catY + 5 + categoryScroll.getValue()) - ) - ); - } + private LinkedHashMap getCurrentConfigEditing() { + return new LinkedHashMap<>(processedConfig); } - int catDist = innerBottom - innerTop - 12; - Gui.drawRect( - innerLeft + 2, - innerTop + 5, - innerLeft + 7, - innerBottom - 5, - 0xff101010 - ); - Gui.drawRect( - innerLeft + 3, - innerTop + 6 + (int) (catDist * catBarStart), - innerLeft + 6, - innerTop + 6 + (int) (catDist * catBarEnd), - 0xff303030 - ); - - GlScissorStack.pop(scaledResolution); - - TextRenderUtils.drawStringCenteredScaledMaxWidth( - "Categories", - fr, - x + 75, - y + 44, - false, - 120, - 0xa368ef - ); - - RenderUtils.drawFloatingRectDark( - x + 149, - y + 29, - xSize - 154, - ySize - 34, - false - ); - - innerLeft = x + 149 + innerPadding; - innerRight = x + xSize - 5 - innerPadding; - innerBottom = y + ySize - 5 - innerPadding; - - GlStateManager.color(1, 1, 1, 1); - int rightStuffLen = 20; - - if ( - getSelectedCategory() != null && - currentConfigEditing.containsKey(getSelectedCategory()) + + private LinkedHashMap getOptionsInCategory( + ConfigProcessor.ProcessedCategory cat ) { - ConfigProcessor.ProcessedCategory cat = currentConfigEditing.get( - getSelectedCategory() - ); - - TextRenderUtils.drawStringScaledMaxWidth( - cat.desc, - fr, - innerLeft + 5, - y + 40, - true, - innerRight - innerLeft - rightStuffLen - 10, - 0xb0b0b0 - ); + return new LinkedHashMap<>(cat.options); } - Gui.drawRect(innerLeft, innerTop, innerLeft + 1, innerBottom, 0xff08080E); //Left - Gui.drawRect(innerLeft + 1, innerTop, innerRight, innerTop + 1, 0xff08080E); //Top - Gui.drawRect( - innerRight - 1, - innerTop + 1, - innerRight, - innerBottom, - 0xff303036 - ); //Right - Gui.drawRect( - innerLeft + 1, - innerBottom - 1, - innerRight - 1, - innerBottom, - 0xff303036 - ); //Bottom - Gui.drawRect( - innerLeft + 1, - innerTop + 1, - innerRight - 1, - innerBottom - 1, - 0x6008080E - ); //Middle - - GlScissorStack.push( - innerLeft + 1, - innerTop + 1, - innerRight - 1, - innerBottom - 1, - scaledResolution - ); - float barSize = 1; - int optionY = -optionsScroll.getValue(); - if ( - getSelectedCategory() != null && - currentConfigEditing.containsKey(getSelectedCategory()) - ) { - ConfigProcessor.ProcessedCategory cat = currentConfigEditing.get( - getSelectedCategory() - ); - int optionWidthDefault = innerRight - innerLeft - 20; - GlStateManager.enableDepth(); - Set activeAccordions = new HashSet<>(); - for (ConfigProcessor.ProcessedOption option : getOptionsInCategory(cat) - .values()) { - int optionWidth = optionWidthDefault; - if (option.accordionId >= 0) { - if (!activeAccordions.contains(option.accordionId)) { - continue; - } - optionWidth = optionWidthDefault - 2 * innerPadding; - } + public String getSelectedCategory() { + return selectedCategory; + } - GuiOptionEditor editor = option.editor; - if (editor == null) { - continue; - } - if (editor instanceof GuiOptionEditorAccordion) { - GuiOptionEditorAccordion accordion = (GuiOptionEditorAccordion) editor; - if (accordion.getToggled()) { - activeAccordions.add(accordion.getAccordionId()); - } - } - int optionHeight = editor.getHeight(); - if ( - innerTop + 5 + optionY + optionHeight > innerTop + 1 && - innerTop + 5 + optionY < innerBottom - 1 - ) { - editor.render( - (innerLeft + innerRight - optionWidth) / 2 - 5, - innerTop + 5 + optionY, - optionWidth - ); - } - optionY += optionHeight + 5; - } - GlStateManager.disableDepth(); - if (optionY > 0) { - barSize = - LerpUtils.clampZeroOne( - (float) (innerBottom - innerTop - 2) / - (optionY + 5 + optionsScroll.getValue()) - ); - } + public String getSelectedCategoryName() { + return processedConfig.get(selectedCategory).name; } - GlScissorStack.pop(scaledResolution); + private void setSelectedCategory(String category) { + selectedCategory = category; + optionsScroll.setValue(0); + } - GL11.glDisable(GL11.GL_SCISSOR_TEST); - if ( - getSelectedCategory() != null && - currentConfigEditing.containsKey(getSelectedCategory()) - ) { - int optionYOverlay = -optionsScroll.getValue(); - ConfigProcessor.ProcessedCategory cat = currentConfigEditing.get( - getSelectedCategory() - ); - int optionWidthDefault = innerRight - innerLeft - 20; - - GlStateManager.translate(0, 0, 10); - GlStateManager.enableDepth(); - Set activeAccordions = new HashSet<>(); - for (ConfigProcessor.ProcessedOption option : getOptionsInCategory(cat) - .values()) { - int optionWidth = optionWidthDefault; - if (option.accordionId >= 0) { - if (!activeAccordions.contains(option.accordionId)) { - continue; - } - optionWidth = optionWidthDefault - 2 * innerPadding; - } + public void render() { + optionsScroll.tick(); + categoryScroll.tick(); - GuiOptionEditor editor = option.editor; - if (editor == null) { - continue; - } - if (editor instanceof GuiOptionEditorAccordion) { - GuiOptionEditorAccordion accordion = (GuiOptionEditorAccordion) editor; - if (accordion.getToggled()) { - activeAccordions.add(accordion.getAccordionId()); - } - } - int optionHeight = editor.getHeight(); - if ( - innerTop + 5 + optionYOverlay + optionHeight > innerTop + 1 && - innerTop + 5 + optionYOverlay < innerBottom - 1 - ) { - editor.renderOverlay( - (innerLeft + innerRight - optionWidth) / 2 - 5, - innerTop + 5 + optionYOverlay, - optionWidth - ); - } - optionYOverlay += optionHeight + 5; - } - GlStateManager.disableDepth(); - GlStateManager.translate(0, 0, -10); - } - GL11.glEnable(GL11.GL_SCISSOR_TEST); - - float barStart = - optionsScroll.getValue() / (float) (optionY + optionsScroll.getValue()); - float barEnd = barStart + barSize; - if (barEnd > 1) { - barEnd = 1; - if ( - optionsScroll.getTarget() / - (float) (optionY + optionsScroll.getValue()) + - barSize < - 1 - ) { - int target = optionsScroll.getTarget(); - optionsScroll.setValue( - (int) Math.ceil( - (optionY + 5 + optionsScroll.getValue()) - - barSize * - (optionY + 5 + optionsScroll.getValue()) - ) + List tooltipToDisplay = null; + + long currentTime = System.currentTimeMillis(); + long delta = currentTime - openedMillis; + + ScaledResolution scaledResolution = new ScaledResolution( + Minecraft.getMinecraft() ); - optionsScroll.setTarget(target); - } else { - optionsScroll.setValue( - (int) Math.ceil( - (optionY + 5 + optionsScroll.getValue()) - - barSize * - (optionY + 5 + optionsScroll.getValue()) - ) + int width = scaledResolution.getScaledWidth(); + int height = scaledResolution.getScaledHeight(); + int mouseX = + Mouse.getX() * width / Minecraft.getMinecraft().displayWidth; + int mouseY = + height - + Mouse.getY() * + height / + Minecraft.getMinecraft().displayHeight - + 1; + + float opacityFactor = LerpUtils.sigmoidZeroOne(delta / 500f); + RenderUtils.drawGradientRect( + 0, + 0, + 0, + width, + height, + (int) (0x80 * opacityFactor) << 24 | 0x101010, + (int) (0x90 * opacityFactor) << 24 | 0x101010 ); - } - } - int dist = innerBottom - innerTop - 12; - Gui.drawRect( - innerRight - 10, - innerTop + 5, - innerRight - 5, - innerBottom - 5, - 0xff101010 - ); - Gui.drawRect( - innerRight - 9, - innerTop + 6 + (int) (dist * barStart), - innerRight - 6, - innerTop + 6 + (int) (dist * barEnd), - 0xff303030 - ); - - for (int socialIndex = 0; socialIndex < socialsIco.length; socialIndex++) { - Minecraft - .getMinecraft() - .getTextureManager() - .bindTexture(socialsIco[socialIndex]); - GlStateManager.color(1, 1, 1, 1); - int socialLeft = x + xSize - 23 - 18 * socialIndex; - RenderUtils.drawTexturedRect(socialLeft, y + 7, 16, 16, GL11.GL_LINEAR); - - if ( - mouseX >= socialLeft && - mouseX <= socialLeft + 16 && - mouseY >= y + 6 && - mouseY <= y + 23 - ) { - tooltipToDisplay = - Lists.newArrayList( - EnumChatFormatting.YELLOW + - "Go to: " + - EnumChatFormatting.RESET + - socialsLink[socialIndex] - ); - } - } - GlScissorStack.clear(); - - if (tooltipToDisplay != null) { - TextRenderUtils.drawHoveringText( - tooltipToDisplay, - mouseX, - mouseY, - width, - height, - -1, - fr - ); - } + int xSize = Math.min( + scaledResolution.getScaledWidth() - + 100 / + scaledResolution.getScaleFactor(), + 500 + ); + int ySize = Math.min( + scaledResolution.getScaledHeight() - + 100 / + scaledResolution.getScaleFactor(), + 400 + ); - GlStateManager.translate(0, 0, -2); - } - - public boolean mouseInput(int mouseX, int mouseY) { - ScaledResolution scaledResolution = new ScaledResolution( - Minecraft.getMinecraft() - ); - int width = scaledResolution.getScaledWidth(); - int height = scaledResolution.getScaledHeight(); - - int xSize = Math.min(width - 100 / scaledResolution.getScaleFactor(), 500); - int ySize = Math.min(height - 100 / scaledResolution.getScaleFactor(), 400); - - int x = (scaledResolution.getScaledWidth() - xSize) / 2; - int y = (scaledResolution.getScaledHeight() - ySize) / 2; - - int adjScaleFactor = Math.max(2, scaledResolution.getScaleFactor()); - - int innerPadding = 20 / adjScaleFactor; - int innerTop = y + 49 + innerPadding; - int innerBottom = y + ySize - 5 - innerPadding; - int innerLeft = x + 149 + innerPadding; - int innerRight = x + xSize - 5 - innerPadding; - - int dWheel = Mouse.getEventDWheel(); - if (mouseY > innerTop && mouseY < innerBottom && dWheel != 0) { - if (dWheel < 0) { - dWheel = -1; - } - if (dWheel > 0) { - dWheel = 1; - } - if (mouseX < innerLeft) { - int newTarget = categoryScroll.getTarget() - dWheel * 30; - if (newTarget < 0) { - newTarget = 0; - } + int x = (scaledResolution.getScaledWidth() - xSize) / 2; + int y = (scaledResolution.getScaledHeight() - ySize) / 2; - float catBarSize = 1; - int catY = -newTarget; - for (Map.Entry entry : getCurrentConfigEditing() - .entrySet()) { - if (getSelectedCategory() == null) { - setSelectedCategory(entry.getKey()); - } - - catY += 15; - if (catY > 0) { - catBarSize = - LerpUtils.clampZeroOne( - (float) (innerBottom - innerTop - 2) / (catY + 5 + newTarget) - ); - } + int adjScaleFactor = Math.max(2, scaledResolution.getScaleFactor()); + + int openingXSize = xSize; + int openingYSize = ySize; + if (delta < 150) { + openingXSize = (int) (delta * xSize / 150); + openingYSize = 5; + } else if (delta < 300) { + openingYSize = 5 + (int) (delta - 150) * (ySize - 5) / 150; } + RenderUtils.drawFloatingRectDark( + (scaledResolution.getScaledWidth() - openingXSize) / 2, + (scaledResolution.getScaledHeight() - openingYSize) / 2, + openingXSize, + openingYSize + ); + GlScissorStack.clear(); + GlScissorStack.push( + (scaledResolution.getScaledWidth() - openingXSize) / 2, + (scaledResolution.getScaledHeight() - openingYSize) / 2, + (scaledResolution.getScaledWidth() + openingXSize) / 2, + (scaledResolution.getScaledHeight() + openingYSize) / 2, + scaledResolution + ); + + RenderUtils.drawFloatingRectDark(x + 5, y + 5, xSize - 10, 20, false); - int barMax = (int) Math.floor( - (catY + 5 + newTarget) - catBarSize * (catY + 5 + newTarget) + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + TextRenderUtils.drawStringCenteredScaledMaxWidth( + "SkyBlockHud by " + + EnumChatFormatting.RED + + "ThatGravyBoat" + + EnumChatFormatting.RESET + + ", config by " + + EnumChatFormatting.DARK_PURPLE + + "Moulberry", + fr, + x + xSize / 2f, + y + 15, + false, + 200, + 0xa0a0a0 ); - if (newTarget > barMax) { - newTarget = barMax; - } - categoryScroll.resetTimer(); - categoryScroll.setTarget(newTarget); - } else { - int newTarget = optionsScroll.getTarget() - dWheel * 30; - if (newTarget < 0) { - newTarget = 0; - } - float barSize = 1; - int optionY = -newTarget; - if ( - getSelectedCategory() != null && - getCurrentConfigEditing() != null && - getCurrentConfigEditing().containsKey(getSelectedCategory()) - ) { - ConfigProcessor.ProcessedCategory cat = getCurrentConfigEditing() - .get(getSelectedCategory()); - Set activeAccordions = new HashSet<>(); - for (ConfigProcessor.ProcessedOption option : getOptionsInCategory( - cat - ) - .values()) { - if (option.accordionId >= 0) { - if (!activeAccordions.contains(option.accordionId)) { - continue; - } - } + RenderUtils.drawFloatingRectDark( + x + 4, + y + 49 - 20, + 140, + ySize - 54 + 20, + false + ); - GuiOptionEditor editor = option.editor; - if (editor == null) { - continue; + int innerPadding = 20 / adjScaleFactor; + int innerLeft = x + 4 + innerPadding; + int innerRight = x + 144 - innerPadding; + int innerTop = y + 49 + innerPadding; + int innerBottom = y + ySize - 5 - innerPadding; + Gui.drawRect( + innerLeft, + innerTop, + innerLeft + 1, + innerBottom, + 0xff08080E + ); //Left + Gui.drawRect( + innerLeft + 1, + innerTop, + innerRight, + innerTop + 1, + 0xff08080E + ); //Top + Gui.drawRect( + innerRight - 1, + innerTop + 1, + innerRight, + innerBottom, + 0xff28282E + ); //Right + Gui.drawRect( + innerLeft + 1, + innerBottom - 1, + innerRight - 1, + innerBottom, + 0xff28282E + ); //Bottom + Gui.drawRect( + innerLeft + 1, + innerTop + 1, + innerRight - 1, + innerBottom - 1, + 0x6008080E + ); //Middle + + GlScissorStack.push( + 0, + innerTop + 1, + scaledResolution.getScaledWidth(), + innerBottom - 1, + scaledResolution + ); + + float catBarSize = 1; + int catY = -categoryScroll.getValue(); + + LinkedHashMap currentConfigEditing = getCurrentConfigEditing(); + for (Map.Entry entry : currentConfigEditing.entrySet()) { + String selectedCategory = getSelectedCategory(); + if ( + selectedCategory == null || + !currentConfigEditing.containsKey(selectedCategory) + ) { + setSelectedCategory(entry.getKey()); } - if (editor instanceof GuiOptionEditorAccordion) { - GuiOptionEditorAccordion accordion = (GuiOptionEditorAccordion) editor; - if (accordion.getToggled()) { - activeAccordions.add(accordion.getAccordionId()); - } + String catName = entry.getValue().name; + if (entry.getKey().equals(getSelectedCategory())) { + catName = + EnumChatFormatting.DARK_AQUA.toString() + + EnumChatFormatting.UNDERLINE + + catName; + } else { + catName = EnumChatFormatting.GRAY + catName; } - optionY += editor.getHeight() + 5; + TextRenderUtils.drawStringCenteredScaledMaxWidth( + catName, + fr, + x + 75, + y + 70 + catY, + false, + 100, + -1 + ); + catY += 15; + if (catY > 0) { + catBarSize = + LerpUtils.clampZeroOne( + (float) (innerBottom - innerTop - 2) / + (catY + 5 + categoryScroll.getValue()) + ); + } + } - if (optionY > 0) { - barSize = - LerpUtils.clampZeroOne( - (float) (innerBottom - innerTop - 2) / - (optionY + 5 + newTarget) + float catBarStart = + categoryScroll.getValue() / + (float) (catY + categoryScroll.getValue()); + float catBarEnd = catBarStart + catBarSize; + if (catBarEnd > 1) { + catBarEnd = 1; + if ( + categoryScroll.getTarget() / + (float) (catY + categoryScroll.getValue()) + + catBarSize < + 1 + ) { + int target = optionsScroll.getTarget(); + categoryScroll.setValue( + (int) Math.ceil( + (catY + 5 + categoryScroll.getValue()) - + catBarSize * + (catY + 5 + categoryScroll.getValue()) + ) + ); + categoryScroll.setTarget(target); + } else { + categoryScroll.setValue( + (int) Math.ceil( + (catY + 5 + categoryScroll.getValue()) - + catBarSize * + (catY + 5 + categoryScroll.getValue()) + ) ); } - } } + int catDist = innerBottom - innerTop - 12; + Gui.drawRect( + innerLeft + 2, + innerTop + 5, + innerLeft + 7, + innerBottom - 5, + 0xff101010 + ); + Gui.drawRect( + innerLeft + 3, + innerTop + 6 + (int) (catDist * catBarStart), + innerLeft + 6, + innerTop + 6 + (int) (catDist * catBarEnd), + 0xff303030 + ); - int barMax = (int) Math.floor( - (optionY + 5 + newTarget) - barSize * (optionY + 5 + newTarget) + GlScissorStack.pop(scaledResolution); + + TextRenderUtils.drawStringCenteredScaledMaxWidth( + "Categories", + fr, + x + 75, + y + 44, + false, + 120, + 0xa368ef ); - if (newTarget > barMax) { - newTarget = barMax; - } - optionsScroll.setTimeToReachTarget( - Math.min( - 150, - Math.max(10, 5 * Math.abs(newTarget - optionsScroll.getValue())) - ) + + RenderUtils.drawFloatingRectDark( + x + 149, + y + 29, + xSize - 154, + ySize - 34, + false ); - optionsScroll.resetTimer(); - optionsScroll.setTarget(newTarget); - } - } else if (Mouse.getEventButtonState() && Mouse.getEventButton() == 0) { - if (getCurrentConfigEditing() != null) { - int catY = -categoryScroll.getValue(); - for (Map.Entry entry : getCurrentConfigEditing() - .entrySet()) { - if (getSelectedCategory() == null) { - setSelectedCategory(entry.getKey()); - } - if ( - mouseX >= x + 5 && - mouseX <= x + 145 && - mouseY >= y + 70 + catY - 7 && - mouseY <= y + 70 + catY + 7 - ) { - setSelectedCategory(entry.getKey()); - return true; - } - catY += 15; - } - } - for ( - int socialIndex = 0; - socialIndex < socialsLink.length; - socialIndex++ - ) { - int socialLeft = x + xSize - 23 - 18 * socialIndex; + innerLeft = x + 149 + innerPadding; + innerRight = x + xSize - 5 - innerPadding; + innerBottom = y + ySize - 5 - innerPadding; + + GlStateManager.color(1, 1, 1, 1); + int rightStuffLen = 20; if ( - mouseX >= socialLeft && - mouseX <= socialLeft + 16 && - mouseY >= y + 6 && - mouseY <= y + 23 + getSelectedCategory() != null && + currentConfigEditing.containsKey(getSelectedCategory()) ) { - try { - Desktop.getDesktop().browse(new URI(socialsLink[socialIndex])); - } catch (Exception ignored) {} - return true; + ConfigProcessor.ProcessedCategory cat = currentConfigEditing.get( + getSelectedCategory() + ); + + TextRenderUtils.drawStringScaledMaxWidth( + cat.desc, + fr, + innerLeft + 5, + y + 40, + true, + innerRight - innerLeft - rightStuffLen - 10, + 0xb0b0b0 + ); } - } - } - int optionY = -optionsScroll.getValue(); - if ( - getSelectedCategory() != null && - getCurrentConfigEditing() != null && - getCurrentConfigEditing().containsKey(getSelectedCategory()) - ) { - int optionWidthDefault = innerRight - innerLeft - 20; - ConfigProcessor.ProcessedCategory cat = getCurrentConfigEditing() - .get(getSelectedCategory()); - Set activeAccordions = new HashSet<>(); - for (ConfigProcessor.ProcessedOption option : getOptionsInCategory(cat) - .values()) { - int optionWidth = optionWidthDefault; - if (option.accordionId >= 0) { - if (!activeAccordions.contains(option.accordionId)) { - continue; - } - optionWidth = optionWidthDefault - 2 * innerPadding; + Gui.drawRect( + innerLeft, + innerTop, + innerLeft + 1, + innerBottom, + 0xff08080E + ); //Left + Gui.drawRect( + innerLeft + 1, + innerTop, + innerRight, + innerTop + 1, + 0xff08080E + ); //Top + Gui.drawRect( + innerRight - 1, + innerTop + 1, + innerRight, + innerBottom, + 0xff303036 + ); //Right + Gui.drawRect( + innerLeft + 1, + innerBottom - 1, + innerRight - 1, + innerBottom, + 0xff303036 + ); //Bottom + Gui.drawRect( + innerLeft + 1, + innerTop + 1, + innerRight - 1, + innerBottom - 1, + 0x6008080E + ); //Middle + + GlScissorStack.push( + innerLeft + 1, + innerTop + 1, + innerRight - 1, + innerBottom - 1, + scaledResolution + ); + float barSize = 1; + int optionY = -optionsScroll.getValue(); + if ( + getSelectedCategory() != null && + currentConfigEditing.containsKey(getSelectedCategory()) + ) { + ConfigProcessor.ProcessedCategory cat = currentConfigEditing.get( + getSelectedCategory() + ); + int optionWidthDefault = innerRight - innerLeft - 20; + GlStateManager.enableDepth(); + Set activeAccordions = new HashSet<>(); + for (ConfigProcessor.ProcessedOption option : getOptionsInCategory( + cat + ) + .values()) { + int optionWidth = optionWidthDefault; + if (option.accordionId >= 0) { + if (!activeAccordions.contains(option.accordionId)) { + continue; + } + optionWidth = optionWidthDefault - 2 * innerPadding; + } + + GuiOptionEditor editor = option.editor; + if (editor == null) { + continue; + } + if (editor instanceof GuiOptionEditorAccordion) { + GuiOptionEditorAccordion accordion = (GuiOptionEditorAccordion) editor; + if (accordion.getToggled()) { + activeAccordions.add(accordion.getAccordionId()); + } + } + int optionHeight = editor.getHeight(); + if ( + innerTop + 5 + optionY + optionHeight > innerTop + 1 && + innerTop + 5 + optionY < innerBottom - 1 + ) { + editor.render( + (innerLeft + innerRight - optionWidth) / 2 - 5, + innerTop + 5 + optionY, + optionWidth + ); + } + optionY += optionHeight + 5; + } + GlStateManager.disableDepth(); + if (optionY > 0) { + barSize = + LerpUtils.clampZeroOne( + (float) (innerBottom - innerTop - 2) / + (optionY + 5 + optionsScroll.getValue()) + ); + } } - GuiOptionEditor editor = option.editor; - if (editor == null) { - continue; - } - if (editor instanceof GuiOptionEditorAccordion) { - GuiOptionEditorAccordion accordion = (GuiOptionEditorAccordion) editor; - if (accordion.getToggled()) { - activeAccordions.add(accordion.getAccordionId()); - } - } + GlScissorStack.pop(scaledResolution); + + GL11.glDisable(GL11.GL_SCISSOR_TEST); if ( - editor.mouseInputOverlay( - (innerLeft + innerRight - optionWidth) / 2 - 5, - innerTop + 5 + optionY, - optionWidth, - mouseX, - mouseY - ) + getSelectedCategory() != null && + currentConfigEditing.containsKey(getSelectedCategory()) ) { - return true; + int optionYOverlay = -optionsScroll.getValue(); + ConfigProcessor.ProcessedCategory cat = currentConfigEditing.get( + getSelectedCategory() + ); + int optionWidthDefault = innerRight - innerLeft - 20; + + GlStateManager.translate(0, 0, 10); + GlStateManager.enableDepth(); + Set activeAccordions = new HashSet<>(); + for (ConfigProcessor.ProcessedOption option : getOptionsInCategory( + cat + ) + .values()) { + int optionWidth = optionWidthDefault; + if (option.accordionId >= 0) { + if (!activeAccordions.contains(option.accordionId)) { + continue; + } + optionWidth = optionWidthDefault - 2 * innerPadding; + } + + GuiOptionEditor editor = option.editor; + if (editor == null) { + continue; + } + if (editor instanceof GuiOptionEditorAccordion) { + GuiOptionEditorAccordion accordion = (GuiOptionEditorAccordion) editor; + if (accordion.getToggled()) { + activeAccordions.add(accordion.getAccordionId()); + } + } + int optionHeight = editor.getHeight(); + if ( + innerTop + + 5 + + optionYOverlay + + optionHeight > + innerTop + + 1 && + innerTop + 5 + optionYOverlay < innerBottom - 1 + ) { + editor.renderOverlay( + (innerLeft + innerRight - optionWidth) / 2 - 5, + innerTop + 5 + optionYOverlay, + optionWidth + ); + } + optionYOverlay += optionHeight + 5; + } + GlStateManager.disableDepth(); + GlStateManager.translate(0, 0, -10); } - optionY += editor.getHeight() + 5; - } - } - - if ( - mouseX > innerLeft && - mouseX < innerRight && - mouseY > innerTop && - mouseY < innerBottom - ) { - optionY = -optionsScroll.getValue(); - if ( - getSelectedCategory() != null && - getCurrentConfigEditing() != null && - getCurrentConfigEditing().containsKey(getSelectedCategory()) - ) { - int optionWidthDefault = innerRight - innerLeft - 20; - ConfigProcessor.ProcessedCategory cat = getCurrentConfigEditing() - .get(getSelectedCategory()); - Set activeAccordions = new HashSet<>(); - for (ConfigProcessor.ProcessedOption option : getOptionsInCategory(cat) - .values()) { - int optionWidth = optionWidthDefault; - if (option.accordionId >= 0) { - if (!activeAccordions.contains(option.accordionId)) { - continue; + GL11.glEnable(GL11.GL_SCISSOR_TEST); + + float barStart = + optionsScroll.getValue() / + (float) (optionY + optionsScroll.getValue()); + float barEnd = barStart + barSize; + if (barEnd > 1) { + barEnd = 1; + if ( + optionsScroll.getTarget() / + (float) (optionY + optionsScroll.getValue()) + + barSize < + 1 + ) { + int target = optionsScroll.getTarget(); + optionsScroll.setValue( + (int) Math.ceil( + (optionY + 5 + optionsScroll.getValue()) - + barSize * + (optionY + 5 + optionsScroll.getValue()) + ) + ); + optionsScroll.setTarget(target); + } else { + optionsScroll.setValue( + (int) Math.ceil( + (optionY + 5 + optionsScroll.getValue()) - + barSize * + (optionY + 5 + optionsScroll.getValue()) + ) + ); } - optionWidth = optionWidthDefault - 2 * innerPadding; - } - - GuiOptionEditor editor = option.editor; - if (editor == null) { - continue; - } - if (editor instanceof GuiOptionEditorAccordion) { - GuiOptionEditorAccordion accordion = (GuiOptionEditorAccordion) editor; - if (accordion.getToggled()) { - activeAccordions.add(accordion.getAccordionId()); + } + int dist = innerBottom - innerTop - 12; + Gui.drawRect( + innerRight - 10, + innerTop + 5, + innerRight - 5, + innerBottom - 5, + 0xff101010 + ); + Gui.drawRect( + innerRight - 9, + innerTop + 6 + (int) (dist * barStart), + innerRight - 6, + innerTop + 6 + (int) (dist * barEnd), + 0xff303030 + ); + + for ( + int socialIndex = 0; + socialIndex < socialsIco.length; + socialIndex++ + ) { + Minecraft + .getMinecraft() + .getTextureManager() + .bindTexture(socialsIco[socialIndex]); + GlStateManager.color(1, 1, 1, 1); + int socialLeft = x + xSize - 23 - 18 * socialIndex; + RenderUtils.drawTexturedRect( + socialLeft, + y + 7, + 16, + 16, + GL11.GL_LINEAR + ); + + if ( + mouseX >= socialLeft && + mouseX <= socialLeft + 16 && + mouseY >= y + 6 && + mouseY <= y + 23 + ) { + tooltipToDisplay = + Lists.newArrayList( + EnumChatFormatting.YELLOW + + "Go to: " + + EnumChatFormatting.RESET + + socialsLink[socialIndex] + ); } - } - if ( - editor.mouseInput( - (innerLeft + innerRight - optionWidth) / 2 - 5, - innerTop + 5 + optionY, - optionWidth, - mouseX, - mouseY - ) - ) { - return true; - } - optionY += editor.getHeight() + 5; } - } + + GlScissorStack.clear(); + + if (tooltipToDisplay != null) { + TextRenderUtils.drawHoveringText( + tooltipToDisplay, + mouseX, + mouseY, + width, + height, + -1, + fr + ); + } + + GlStateManager.translate(0, 0, -2); } - return true; - } + public boolean mouseInput(int mouseX, int mouseY) { + ScaledResolution scaledResolution = new ScaledResolution( + Minecraft.getMinecraft() + ); + int width = scaledResolution.getScaledWidth(); + int height = scaledResolution.getScaledHeight(); - public boolean keyboardInput() { - ScaledResolution scaledResolution = new ScaledResolution( - Minecraft.getMinecraft() - ); - int width = scaledResolution.getScaledWidth(); + int xSize = Math.min( + width - 100 / scaledResolution.getScaleFactor(), + 500 + ); + int ySize = Math.min( + height - 100 / scaledResolution.getScaleFactor(), + 400 + ); - int xSize = Math.min(width - 100 / scaledResolution.getScaleFactor(), 500); + int x = (scaledResolution.getScaledWidth() - xSize) / 2; + int y = (scaledResolution.getScaledHeight() - ySize) / 2; - int adjScaleFactor = Math.max(2, scaledResolution.getScaleFactor()); + int adjScaleFactor = Math.max(2, scaledResolution.getScaleFactor()); - int innerPadding = 20 / adjScaleFactor; - int innerWidth = xSize - 154 - innerPadding * 2; + int innerPadding = 20 / adjScaleFactor; + int innerTop = y + 49 + innerPadding; + int innerBottom = y + ySize - 5 - innerPadding; + int innerLeft = x + 149 + innerPadding; + int innerRight = x + xSize - 5 - innerPadding; - if ( - getSelectedCategory() != null && - getCurrentConfigEditing() != null && - getCurrentConfigEditing().containsKey(getSelectedCategory()) - ) { - ConfigProcessor.ProcessedCategory cat = getCurrentConfigEditing() - .get(getSelectedCategory()); - Set activeAccordions = new HashSet<>(); - for (ConfigProcessor.ProcessedOption option : getOptionsInCategory(cat) - .values()) { - if (option.accordionId >= 0) { - if (!activeAccordions.contains(option.accordionId)) { - continue; - } - } + int dWheel = Mouse.getEventDWheel(); + if (mouseY > innerTop && mouseY < innerBottom && dWheel != 0) { + if (dWheel < 0) { + dWheel = -1; + } + if (dWheel > 0) { + dWheel = 1; + } + if (mouseX < innerLeft) { + int newTarget = categoryScroll.getTarget() - dWheel * 30; + if (newTarget < 0) { + newTarget = 0; + } + + float catBarSize = 1; + int catY = -newTarget; + for (Map.Entry entry : getCurrentConfigEditing() + .entrySet()) { + if (getSelectedCategory() == null) { + setSelectedCategory(entry.getKey()); + } + + catY += 15; + if (catY > 0) { + catBarSize = + LerpUtils.clampZeroOne( + (float) (innerBottom - innerTop - 2) / + (catY + 5 + newTarget) + ); + } + } + + int barMax = (int) Math.floor( + (catY + 5 + newTarget) - catBarSize * (catY + 5 + newTarget) + ); + if (newTarget > barMax) { + newTarget = barMax; + } + categoryScroll.resetTimer(); + categoryScroll.setTarget(newTarget); + } else { + int newTarget = optionsScroll.getTarget() - dWheel * 30; + if (newTarget < 0) { + newTarget = 0; + } + + float barSize = 1; + int optionY = -newTarget; + if ( + getSelectedCategory() != null && + getCurrentConfigEditing() != null && + getCurrentConfigEditing().containsKey(getSelectedCategory()) + ) { + ConfigProcessor.ProcessedCategory cat = getCurrentConfigEditing() + .get(getSelectedCategory()); + Set activeAccordions = new HashSet<>(); + for (ConfigProcessor.ProcessedOption option : getOptionsInCategory( + cat + ) + .values()) { + if (option.accordionId >= 0) { + if ( + !activeAccordions.contains(option.accordionId) + ) { + continue; + } + } + + GuiOptionEditor editor = option.editor; + if (editor == null) { + continue; + } + if (editor instanceof GuiOptionEditorAccordion) { + GuiOptionEditorAccordion accordion = (GuiOptionEditorAccordion) editor; + if (accordion.getToggled()) { + activeAccordions.add( + accordion.getAccordionId() + ); + } + } + optionY += editor.getHeight() + 5; + + if (optionY > 0) { + barSize = + LerpUtils.clampZeroOne( + (float) (innerBottom - innerTop - 2) / + (optionY + 5 + newTarget) + ); + } + } + } + + int barMax = (int) Math.floor( + (optionY + 5 + newTarget) - + barSize * + (optionY + 5 + newTarget) + ); + if (newTarget > barMax) { + newTarget = barMax; + } + optionsScroll.setTimeToReachTarget( + Math.min( + 150, + Math.max( + 10, + 5 * Math.abs(newTarget - optionsScroll.getValue()) + ) + ) + ); + optionsScroll.resetTimer(); + optionsScroll.setTarget(newTarget); + } + } else if (Mouse.getEventButtonState() && Mouse.getEventButton() == 0) { + if (getCurrentConfigEditing() != null) { + int catY = -categoryScroll.getValue(); + for (Map.Entry entry : getCurrentConfigEditing() + .entrySet()) { + if (getSelectedCategory() == null) { + setSelectedCategory(entry.getKey()); + } + if ( + mouseX >= x + 5 && + mouseX <= x + 145 && + mouseY >= y + 70 + catY - 7 && + mouseY <= y + 70 + catY + 7 + ) { + setSelectedCategory(entry.getKey()); + return true; + } + catY += 15; + } + } - GuiOptionEditor editor = option.editor; - if (editor == null) { - continue; + for ( + int socialIndex = 0; + socialIndex < socialsLink.length; + socialIndex++ + ) { + int socialLeft = x + xSize - 23 - 18 * socialIndex; + + if ( + mouseX >= socialLeft && + mouseX <= socialLeft + 16 && + mouseY >= y + 6 && + mouseY <= y + 23 + ) { + try { + Desktop + .getDesktop() + .browse(new URI(socialsLink[socialIndex])); + } catch (Exception ignored) {} + return true; + } + } } - if (editor instanceof GuiOptionEditorAccordion) { - GuiOptionEditorAccordion accordion = (GuiOptionEditorAccordion) editor; - if (accordion.getToggled()) { - activeAccordions.add(accordion.getAccordionId()); - } + + int optionY = -optionsScroll.getValue(); + if ( + getSelectedCategory() != null && + getCurrentConfigEditing() != null && + getCurrentConfigEditing().containsKey(getSelectedCategory()) + ) { + int optionWidthDefault = innerRight - innerLeft - 20; + ConfigProcessor.ProcessedCategory cat = getCurrentConfigEditing() + .get(getSelectedCategory()); + Set activeAccordions = new HashSet<>(); + for (ConfigProcessor.ProcessedOption option : getOptionsInCategory( + cat + ) + .values()) { + int optionWidth = optionWidthDefault; + if (option.accordionId >= 0) { + if (!activeAccordions.contains(option.accordionId)) { + continue; + } + optionWidth = optionWidthDefault - 2 * innerPadding; + } + + GuiOptionEditor editor = option.editor; + if (editor == null) { + continue; + } + if (editor instanceof GuiOptionEditorAccordion) { + GuiOptionEditorAccordion accordion = (GuiOptionEditorAccordion) editor; + if (accordion.getToggled()) { + activeAccordions.add(accordion.getAccordionId()); + } + } + if ( + editor.mouseInputOverlay( + (innerLeft + innerRight - optionWidth) / 2 - 5, + innerTop + 5 + optionY, + optionWidth, + mouseX, + mouseY + ) + ) { + return true; + } + optionY += editor.getHeight() + 5; + } } - if (editor.keyboardInput()) { - return true; + + if ( + mouseX > innerLeft && + mouseX < innerRight && + mouseY > innerTop && + mouseY < innerBottom + ) { + optionY = -optionsScroll.getValue(); + if ( + getSelectedCategory() != null && + getCurrentConfigEditing() != null && + getCurrentConfigEditing().containsKey(getSelectedCategory()) + ) { + int optionWidthDefault = innerRight - innerLeft - 20; + ConfigProcessor.ProcessedCategory cat = getCurrentConfigEditing() + .get(getSelectedCategory()); + Set activeAccordions = new HashSet<>(); + for (ConfigProcessor.ProcessedOption option : getOptionsInCategory( + cat + ) + .values()) { + int optionWidth = optionWidthDefault; + if (option.accordionId >= 0) { + if (!activeAccordions.contains(option.accordionId)) { + continue; + } + optionWidth = optionWidthDefault - 2 * innerPadding; + } + + GuiOptionEditor editor = option.editor; + if (editor == null) { + continue; + } + if (editor instanceof GuiOptionEditorAccordion) { + GuiOptionEditorAccordion accordion = (GuiOptionEditorAccordion) editor; + if (accordion.getToggled()) { + activeAccordions.add(accordion.getAccordionId()); + } + } + if ( + editor.mouseInput( + (innerLeft + innerRight - optionWidth) / 2 - 5, + innerTop + 5 + optionY, + optionWidth, + mouseX, + mouseY + ) + ) { + return true; + } + optionY += editor.getHeight() + 5; + } + } } - } + + return true; } - return true; - } + public boolean keyboardInput() { + ScaledResolution scaledResolution = new ScaledResolution( + Minecraft.getMinecraft() + ); + int width = scaledResolution.getScaledWidth(); + + int xSize = Math.min( + width - 100 / scaledResolution.getScaleFactor(), + 500 + ); + + int adjScaleFactor = Math.max(2, scaledResolution.getScaleFactor()); + + int innerPadding = 20 / adjScaleFactor; + int innerWidth = xSize - 154 - innerPadding * 2; + + if ( + getSelectedCategory() != null && + getCurrentConfigEditing() != null && + getCurrentConfigEditing().containsKey(getSelectedCategory()) + ) { + ConfigProcessor.ProcessedCategory cat = getCurrentConfigEditing() + .get(getSelectedCategory()); + Set activeAccordions = new HashSet<>(); + for (ConfigProcessor.ProcessedOption option : getOptionsInCategory( + cat + ) + .values()) { + if (option.accordionId >= 0) { + if (!activeAccordions.contains(option.accordionId)) { + continue; + } + } + + GuiOptionEditor editor = option.editor; + if (editor == null) { + continue; + } + if (editor instanceof GuiOptionEditorAccordion) { + GuiOptionEditorAccordion accordion = (GuiOptionEditorAccordion) editor; + if (accordion.getToggled()) { + activeAccordions.add(accordion.getAccordionId()); + } + } + if (editor.keyboardInput()) { + return true; + } + } + } + + return true; + } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/BackgroundBlur.java b/src/main/java/com/thatgravyboat/skyblockhud/core/BackgroundBlur.java index 9379d62..e95e896 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/BackgroundBlur.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/BackgroundBlur.java @@ -21,273 +21,288 @@ import org.lwjgl.opengl.GL11; public class BackgroundBlur { - private static HashMap blurOutput = new HashMap<>(); - private static HashMap lastBlurUse = new HashMap<>(); - private static long lastBlur = 0; - private static HashSet requestedBlurs = new HashSet<>(); - - private static int fogColour = 0; - private static boolean registered = false; - - public static void registerListener() { - if (!registered) { - registered = true; - MinecraftForge.EVENT_BUS.register(new BackgroundBlur()); + private static HashMap blurOutput = new HashMap<>(); + private static HashMap lastBlurUse = new HashMap<>(); + private static long lastBlur = 0; + private static HashSet requestedBlurs = new HashSet<>(); + + private static int fogColour = 0; + private static boolean registered = false; + + public static void registerListener() { + if (!registered) { + registered = true; + MinecraftForge.EVENT_BUS.register(new BackgroundBlur()); + } } - } - private static boolean shouldBlur = true; + private static boolean shouldBlur = true; - public static void markDirty() { - if (Minecraft.getMinecraft().theWorld != null) { - shouldBlur = true; + public static void markDirty() { + if (Minecraft.getMinecraft().theWorld != null) { + shouldBlur = true; + } } - } - public static void processBlurs() { - if (shouldBlur) { - shouldBlur = false; + public static void processBlurs() { + if (shouldBlur) { + shouldBlur = false; - long currentTime = System.currentTimeMillis(); + long currentTime = System.currentTimeMillis(); - for (float blur : requestedBlurs) { - lastBlur = currentTime; - lastBlurUse.put(blur, currentTime); + for (float blur : requestedBlurs) { + lastBlur = currentTime; + lastBlurUse.put(blur, currentTime); - int width = Minecraft.getMinecraft().displayWidth; - int height = Minecraft.getMinecraft().displayHeight; + int width = Minecraft.getMinecraft().displayWidth; + int height = Minecraft.getMinecraft().displayHeight; - Framebuffer output = blurOutput.computeIfAbsent( - blur, - k -> { - Framebuffer fb = new Framebuffer(width, height, false); - fb.setFramebufferFilter(GL11.GL_NEAREST); - return fb; - } - ); + Framebuffer output = blurOutput.computeIfAbsent( + blur, + k -> { + Framebuffer fb = new Framebuffer(width, height, false); + fb.setFramebufferFilter(GL11.GL_NEAREST); + return fb; + } + ); - output.framebufferWidth = output.framebufferTextureWidth = width; - output.framebufferHeight = output.framebufferTextureHeight = height; + output.framebufferWidth = + output.framebufferTextureWidth = width; + output.framebufferHeight = + output.framebufferTextureHeight = height; - blurBackground(output, blur); - } + blurBackground(output, blur); + } - Set remove = new HashSet<>(); - for (Map.Entry entry : lastBlurUse.entrySet()) { - if (currentTime - entry.getValue() > 30 * 1000) { - remove.add(entry.getKey()); - } - } - remove.remove(5f); + Set remove = new HashSet<>(); + for (Map.Entry entry : lastBlurUse.entrySet()) { + if (currentTime - entry.getValue() > 30 * 1000) { + remove.add(entry.getKey()); + } + } + remove.remove(5f); - lastBlurUse.keySet().removeAll(remove); - blurOutput.keySet().removeAll(remove); + lastBlurUse.keySet().removeAll(remove); + blurOutput.keySet().removeAll(remove); - requestedBlurs.clear(); + requestedBlurs.clear(); + } } - } - @SubscribeEvent(priority = EventPriority.HIGHEST) - public void onScreenRender(RenderGameOverlayEvent.Pre event) { - if (event.type == RenderGameOverlayEvent.ElementType.ALL) { - processBlurs(); - } - } - - @SubscribeEvent - public void onFogColour(EntityViewRenderEvent.FogColors event) { - fogColour = 0xff000000; - fogColour |= ((int) (event.red * 255) & 0xFF) << 16; - fogColour |= ((int) (event.green * 255) & 0xFF) << 8; - fogColour |= (int) (event.blue * 255) & 0xFF; - } - - private static Shader blurShaderHorz = null; - private static Shader blurShaderVert = null; - private static Framebuffer blurOutputHorz = null; - - /** - * Creates a projection matrix that projects from our coordinate space [0->width; 0->height] to OpenGL coordinate - * space [-1 -> 1; 1 -> -1] (Note: flipped y-axis). - * - * This is so that we can render to and from the framebuffer in a way that is familiar to us, instead of needing to - * apply scales and translations manually. - */ - private static Matrix4f createProjectionMatrix(int width, int height) { - Matrix4f projMatrix = new Matrix4f(); - projMatrix.setIdentity(); - projMatrix.m00 = 2.0F / (float) width; - projMatrix.m11 = 2.0F / (float) (-height); - projMatrix.m22 = -0.0020001999F; - projMatrix.m33 = 1.0F; - projMatrix.m03 = -1.0F; - projMatrix.m13 = 1.0F; - projMatrix.m23 = -1.0001999F; - return projMatrix; - } - - private static void blurBackground(Framebuffer output, float blurFactor) { - if ( - !OpenGlHelper.isFramebufferEnabled() || - !OpenGlHelper.areShadersSupported() - ) return; - - int width = Minecraft.getMinecraft().displayWidth; - int height = Minecraft.getMinecraft().displayHeight; - - GlStateManager.matrixMode(GL11.GL_PROJECTION); - GlStateManager.loadIdentity(); - GlStateManager.ortho(0.0D, width, height, 0.0D, 1000.0D, 3000.0D); - GlStateManager.matrixMode(GL11.GL_MODELVIEW); - GlStateManager.loadIdentity(); - GlStateManager.translate(0.0F, 0.0F, -2000.0F); - - if (blurOutputHorz == null) { - blurOutputHorz = new Framebuffer(width, height, false); - blurOutputHorz.setFramebufferFilter(GL11.GL_NEAREST); + @SubscribeEvent(priority = EventPriority.HIGHEST) + public void onScreenRender(RenderGameOverlayEvent.Pre event) { + if (event.type == RenderGameOverlayEvent.ElementType.ALL) { + processBlurs(); + } } - if (blurOutputHorz == null || output == null) { - return; + + @SubscribeEvent + public void onFogColour(EntityViewRenderEvent.FogColors event) { + fogColour = 0xff000000; + fogColour |= ((int) (event.red * 255) & 0xFF) << 16; + fogColour |= ((int) (event.green * 255) & 0xFF) << 8; + fogColour |= (int) (event.blue * 255) & 0xFF; } - if ( - blurOutputHorz.framebufferWidth != width || - blurOutputHorz.framebufferHeight != height - ) { - blurOutputHorz.createBindFramebuffer(width, height); - blurShaderHorz.setProjectionMatrix(createProjectionMatrix(width, height)); - Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(false); + + private static Shader blurShaderHorz = null; + private static Shader blurShaderVert = null; + private static Framebuffer blurOutputHorz = null; + + /** + * Creates a projection matrix that projects from our coordinate space [0->width; 0->height] to OpenGL coordinate + * space [-1 -> 1; 1 -> -1] (Note: flipped y-axis). + * + * This is so that we can render to and from the framebuffer in a way that is familiar to us, instead of needing to + * apply scales and translations manually. + */ + private static Matrix4f createProjectionMatrix(int width, int height) { + Matrix4f projMatrix = new Matrix4f(); + projMatrix.setIdentity(); + projMatrix.m00 = 2.0F / (float) width; + projMatrix.m11 = 2.0F / (float) (-height); + projMatrix.m22 = -0.0020001999F; + projMatrix.m33 = 1.0F; + projMatrix.m03 = -1.0F; + projMatrix.m13 = 1.0F; + projMatrix.m23 = -1.0001999F; + return projMatrix; } - try { - blurShaderHorz = - new Shader( - Minecraft.getMinecraft().getResourceManager(), - "blur", - Minecraft.getMinecraft().getFramebuffer(), - blurOutputHorz - ); - blurShaderHorz.getShaderManager().getShaderUniform("BlurDir").set(1, 0); - blurShaderHorz.setProjectionMatrix(createProjectionMatrix(width, height)); - } catch (Exception ignored) {} - try { - blurShaderVert = - new Shader( - Minecraft.getMinecraft().getResourceManager(), - "blur", - blurOutputHorz, - output - ); - blurShaderVert.getShaderManager().getShaderUniform("BlurDir").set(0, 1); - blurShaderVert.setProjectionMatrix(createProjectionMatrix(width, height)); - } catch (Exception ignored) {} - if (blurShaderHorz != null && blurShaderVert != null) { - if ( - blurShaderHorz.getShaderManager().getShaderUniform("Radius") == null - ) { - //Corrupted shader? - return; - } - - blurShaderHorz - .getShaderManager() - .getShaderUniform("Radius") - .set(blurFactor); - blurShaderVert - .getShaderManager() - .getShaderUniform("Radius") - .set(blurFactor); - - GL11.glPushMatrix(); - /*GL30.glBindFramebuffer(GL30.GL_READ_FRAMEBUFFER, Minecraft.getMinecraft().getFramebuffer().framebufferObject); + private static void blurBackground(Framebuffer output, float blurFactor) { + if ( + !OpenGlHelper.isFramebufferEnabled() || + !OpenGlHelper.areShadersSupported() + ) return; + + int width = Minecraft.getMinecraft().displayWidth; + int height = Minecraft.getMinecraft().displayHeight; + + GlStateManager.matrixMode(GL11.GL_PROJECTION); + GlStateManager.loadIdentity(); + GlStateManager.ortho(0.0D, width, height, 0.0D, 1000.0D, 3000.0D); + GlStateManager.matrixMode(GL11.GL_MODELVIEW); + GlStateManager.loadIdentity(); + GlStateManager.translate(0.0F, 0.0F, -2000.0F); + + if (blurOutputHorz == null) { + blurOutputHorz = new Framebuffer(width, height, false); + blurOutputHorz.setFramebufferFilter(GL11.GL_NEAREST); + } + if (blurOutputHorz == null || output == null) { + return; + } + if ( + blurOutputHorz.framebufferWidth != width || + blurOutputHorz.framebufferHeight != height + ) { + blurOutputHorz.createBindFramebuffer(width, height); + blurShaderHorz.setProjectionMatrix( + createProjectionMatrix(width, height) + ); + Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(false); + } + + try { + blurShaderHorz = + new Shader( + Minecraft.getMinecraft().getResourceManager(), + "blur", + Minecraft.getMinecraft().getFramebuffer(), + blurOutputHorz + ); + blurShaderHorz + .getShaderManager() + .getShaderUniform("BlurDir") + .set(1, 0); + blurShaderHorz.setProjectionMatrix( + createProjectionMatrix(width, height) + ); + } catch (Exception ignored) {} + try { + blurShaderVert = + new Shader( + Minecraft.getMinecraft().getResourceManager(), + "blur", + blurOutputHorz, + output + ); + blurShaderVert + .getShaderManager() + .getShaderUniform("BlurDir") + .set(0, 1); + blurShaderVert.setProjectionMatrix( + createProjectionMatrix(width, height) + ); + } catch (Exception ignored) {} + if (blurShaderHorz != null && blurShaderVert != null) { + if ( + blurShaderHorz.getShaderManager().getShaderUniform("Radius") == + null + ) { + //Corrupted shader? + return; + } + + blurShaderHorz + .getShaderManager() + .getShaderUniform("Radius") + .set(blurFactor); + blurShaderVert + .getShaderManager() + .getShaderUniform("Radius") + .set(blurFactor); + + GL11.glPushMatrix(); + /*GL30.glBindFramebuffer(GL30.GL_READ_FRAMEBUFFER, Minecraft.getMinecraft().getFramebuffer().framebufferObject); GL30.glBindFramebuffer(GL30.GL_DRAW_FRAMEBUFFER, output.framebufferObject); GL30.glBlitFramebuffer(0, 0, width, height, 0, 0, output.framebufferWidth, output.framebufferHeight, GL11.GL_COLOR_BUFFER_BIT, GL11.GL_NEAREST);*/ - blurShaderHorz.loadShader(0); - blurShaderVert.loadShader(0); - GlStateManager.enableDepth(); - GL11.glPopMatrix(); + blurShaderHorz.loadShader(0); + blurShaderVert.loadShader(0); + GlStateManager.enableDepth(); + GL11.glPopMatrix(); - Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(false); + Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(false); + } } - } - - public static void renderBlurredBackground( - float blurStrength, - int screenWidth, - int screenHeight, - int x, - int y, - int blurWidth, - int blurHeight - ) { - renderBlurredBackground( - blurStrength, - screenWidth, - screenHeight, - x, - y, - blurWidth, - blurHeight, - false - ); - } - - /** - * Renders a subsection of the blurred framebuffer on to the corresponding section of the screen. - * Essentially, this method will "blur" the background inside the bounds specified by [x->x+blurWidth, y->y+blurHeight] - */ - public static void renderBlurredBackground( - float blurStrength, - int screenWidth, - int screenHeight, - int x, - int y, - int blurWidth, - int blurHeight, - boolean forcedUpdate - ) { - if ( - !OpenGlHelper.isFramebufferEnabled() || - !OpenGlHelper.areShadersSupported() - ) return; - if (blurStrength < 0.5) return; - requestedBlurs.add(blurStrength); - - long currentTime = System.currentTimeMillis(); - if (currentTime - lastBlur > 300) { - shouldBlur = true; - if (currentTime - lastBlur > 400 && forcedUpdate) return; + + public static void renderBlurredBackground( + float blurStrength, + int screenWidth, + int screenHeight, + int x, + int y, + int blurWidth, + int blurHeight + ) { + renderBlurredBackground( + blurStrength, + screenWidth, + screenHeight, + x, + y, + blurWidth, + blurHeight, + false + ); } - if (blurOutput.isEmpty()) return; + /** + * Renders a subsection of the blurred framebuffer on to the corresponding section of the screen. + * Essentially, this method will "blur" the background inside the bounds specified by [x->x+blurWidth, y->y+blurHeight] + */ + public static void renderBlurredBackground( + float blurStrength, + int screenWidth, + int screenHeight, + int x, + int y, + int blurWidth, + int blurHeight, + boolean forcedUpdate + ) { + if ( + !OpenGlHelper.isFramebufferEnabled() || + !OpenGlHelper.areShadersSupported() + ) return; + if (blurStrength < 0.5) return; + requestedBlurs.add(blurStrength); + + long currentTime = System.currentTimeMillis(); + if (currentTime - lastBlur > 300) { + shouldBlur = true; + if (currentTime - lastBlur > 400 && forcedUpdate) return; + } - Framebuffer fb = blurOutput.get(blurStrength); - if (fb == null) { - fb = blurOutput.values().iterator().next(); - } + if (blurOutput.isEmpty()) return; - float uMin = x / (float) screenWidth; - float uMax = (x + blurWidth) / (float) screenWidth; - float vMin = (screenHeight - y) / (float) screenHeight; - float vMax = (screenHeight - y - blurHeight) / (float) screenHeight; - - GlStateManager.depthMask(false); - Gui.drawRect(x, y, x + blurWidth, y + blurHeight, fogColour); - fb.bindFramebufferTexture(); - GlStateManager.color(1f, 1f, 1f, 1f); - RenderUtils.drawTexturedRect( - x, - y, - blurWidth, - blurHeight, - uMin, - uMax, - vMin, - vMax - ); - fb.unbindFramebufferTexture(); - GlStateManager.depthMask(true); - } + Framebuffer fb = blurOutput.get(blurStrength); + if (fb == null) { + fb = blurOutput.values().iterator().next(); + } + + float uMin = x / (float) screenWidth; + float uMax = (x + blurWidth) / (float) screenWidth; + float vMin = (screenHeight - y) / (float) screenHeight; + float vMax = (screenHeight - y - blurHeight) / (float) screenHeight; + + GlStateManager.depthMask(false); + Gui.drawRect(x, y, x + blurWidth, y + blurHeight, fogColour); + fb.bindFramebufferTexture(); + GlStateManager.color(1f, 1f, 1f, 1f); + RenderUtils.drawTexturedRect( + x, + y, + blurWidth, + blurHeight, + uMin, + uMax, + vMin, + vMax + ); + fb.unbindFramebufferTexture(); + GlStateManager.depthMask(true); + } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/ChromaColour.java b/src/main/java/com/thatgravyboat/skyblockhud/core/ChromaColour.java index c8fc14b..b8e97ee 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/ChromaColour.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/ChromaColour.java @@ -4,111 +4,116 @@ import java.awt.*; public class ChromaColour { - public static String special(int chromaSpeed, int alpha, int rgb) { - return special( - chromaSpeed, - alpha, - (rgb & 0xFF0000) >> 16, - (rgb & 0x00FF00) >> 8, - (rgb & 0x0000FF) - ); - } - - private static final int RADIX = 10; - - public static String special( - int chromaSpeed, - int alpha, - int r, - int g, - int b - ) { - StringBuilder sb = new StringBuilder(); - sb.append(Integer.toString(chromaSpeed, RADIX)).append(":"); - sb.append(Integer.toString(alpha, RADIX)).append(":"); - sb.append(Integer.toString(r, RADIX)).append(":"); - sb.append(Integer.toString(g, RADIX)).append(":"); - sb.append(Integer.toString(b, RADIX)); - return sb.toString(); - } - - private static int[] decompose(String csv) { - String[] split = csv.split(":"); - - int[] arr = new int[split.length]; - - for (int i = 0; i < split.length; i++) { - arr[i] = Integer.parseInt(split[split.length - 1 - i], RADIX); + public static String special(int chromaSpeed, int alpha, int rgb) { + return special( + chromaSpeed, + alpha, + (rgb & 0xFF0000) >> 16, + (rgb & 0x00FF00) >> 8, + (rgb & 0x0000FF) + ); } - return arr; - } - - public static int specialToSimpleRGB(String special) { - int[] d = decompose(special); - int r = d[2]; - int g = d[1]; - int b = d[0]; - int a = d[3]; - int chr = d[4]; - - return (a & 0xFF) << 24 | (r & 0xFF) << 16 | (g & 0xFF) << 8 | (b & 0xFF); - } - - public static int getSpeed(String special) { - return decompose(special)[4]; - } - - public static float getSecondsForSpeed(int speed) { - return ( - (255 - speed) / - 254f * - (MAX_CHROMA_SECS - MIN_CHROMA_SECS) + - MIN_CHROMA_SECS - ); - } - - private static final int MIN_CHROMA_SECS = 1; - private static final int MAX_CHROMA_SECS = 60; - - public static long startTime = -1; - - public static int specialToChromaRGB(String special) { - if (startTime < 0) startTime = System.currentTimeMillis(); - - int[] d = decompose(special); - int chr = d[4]; - int a = d[3]; - int r = d[2]; - int g = d[1]; - int b = d[0]; - - float[] hsv = Color.RGBtoHSB(r, g, b, null); - - if (chr > 0) { - float seconds = getSecondsForSpeed(chr); - hsv[0] += (System.currentTimeMillis() - startTime) / 1000f / seconds; - hsv[0] %= 1; - if (hsv[0] < 0) hsv[0] += 1; + + private static final int RADIX = 10; + + public static String special( + int chromaSpeed, + int alpha, + int r, + int g, + int b + ) { + StringBuilder sb = new StringBuilder(); + sb.append(Integer.toString(chromaSpeed, RADIX)).append(":"); + sb.append(Integer.toString(alpha, RADIX)).append(":"); + sb.append(Integer.toString(r, RADIX)).append(":"); + sb.append(Integer.toString(g, RADIX)).append(":"); + sb.append(Integer.toString(b, RADIX)); + return sb.toString(); + } + + private static int[] decompose(String csv) { + String[] split = csv.split(":"); + + int[] arr = new int[split.length]; + + for (int i = 0; i < split.length; i++) { + arr[i] = Integer.parseInt(split[split.length - 1 - i], RADIX); + } + return arr; } - return ( - (a & 0xFF) << 24 | (Color.HSBtoRGB(hsv[0], hsv[1], hsv[2]) & 0x00FFFFFF) - ); - } + public static int specialToSimpleRGB(String special) { + int[] d = decompose(special); + int r = d[2]; + int g = d[1]; + int b = d[0]; + int a = d[3]; + int chr = d[4]; + + return ( + (a & 0xFF) << 24 | (r & 0xFF) << 16 | (g & 0xFF) << 8 | (b & 0xFF) + ); + } + + public static int getSpeed(String special) { + return decompose(special)[4]; + } + + public static float getSecondsForSpeed(int speed) { + return ( + (255 - speed) / + 254f * + (MAX_CHROMA_SECS - MIN_CHROMA_SECS) + + MIN_CHROMA_SECS + ); + } - public static int rotateHue(int argb, int degrees) { - int a = (argb >> 24) & 0xFF; - int r = (argb >> 16) & 0xFF; - int g = (argb >> 8) & 0xFF; - int b = (argb) & 0xFF; + private static final int MIN_CHROMA_SECS = 1; + private static final int MAX_CHROMA_SECS = 60; - float[] hsv = Color.RGBtoHSB(r, g, b, null); + public static long startTime = -1; - hsv[0] += degrees / 360f; - hsv[0] %= 1; + public static int specialToChromaRGB(String special) { + if (startTime < 0) startTime = System.currentTimeMillis(); - return ( - (a & 0xFF) << 24 | (Color.HSBtoRGB(hsv[0], hsv[1], hsv[2]) & 0x00FFFFFF) - ); - } + int[] d = decompose(special); + int chr = d[4]; + int a = d[3]; + int r = d[2]; + int g = d[1]; + int b = d[0]; + + float[] hsv = Color.RGBtoHSB(r, g, b, null); + + if (chr > 0) { + float seconds = getSecondsForSpeed(chr); + hsv[0] += + (System.currentTimeMillis() - startTime) / 1000f / seconds; + hsv[0] %= 1; + if (hsv[0] < 0) hsv[0] += 1; + } + + return ( + (a & 0xFF) << 24 | + (Color.HSBtoRGB(hsv[0], hsv[1], hsv[2]) & 0x00FFFFFF) + ); + } + + public static int rotateHue(int argb, int degrees) { + int a = (argb >> 24) & 0xFF; + int r = (argb >> 16) & 0xFF; + int g = (argb >> 8) & 0xFF; + int b = (argb) & 0xFF; + + float[] hsv = Color.RGBtoHSB(r, g, b, null); + + hsv[0] += degrees / 360f; + hsv[0] %= 1; + + return ( + (a & 0xFF) << 24 | + (Color.HSBtoRGB(hsv[0], hsv[1], hsv[2]) & 0x00FFFFFF) + ); + } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/GlScissorStack.java b/src/main/java/com/thatgravyboat/skyblockhud/core/GlScissorStack.java index 27e03b2..306565e 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/GlScissorStack.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/GlScissorStack.java @@ -7,93 +7,93 @@ import org.lwjgl.opengl.GL11; public class GlScissorStack { - private static class Bounds { + private static class Bounds { - int left; - int top; - int right; - int bottom; + int left; + int top; + int right; + int bottom; - public Bounds(int left, int top, int right, int bottom) { - this.left = left; - this.top = top; - this.right = right; - this.bottom = bottom; - } + public Bounds(int left, int top, int right, int bottom) { + this.left = left; + this.top = top; + this.right = right; + this.bottom = bottom; + } - public Bounds createSubBound(int left, int top, int right, int bottom) { - left = Math.max(left, this.left); - top = Math.max(top, this.top); - right = Math.min(right, this.right); - bottom = Math.min(bottom, this.bottom); + public Bounds createSubBound(int left, int top, int right, int bottom) { + left = Math.max(left, this.left); + top = Math.max(top, this.top); + right = Math.min(right, this.right); + bottom = Math.min(bottom, this.bottom); - if (top > bottom) { - top = bottom; - } - if (left > right) { - left = right; - } + if (top > bottom) { + top = bottom; + } + if (left > right) { + left = right; + } - return new Bounds(left, top, right, bottom); - } + return new Bounds(left, top, right, bottom); + } - public void set(ScaledResolution scaledResolution) { - int height = Minecraft.getMinecraft().displayHeight; - int scale = scaledResolution.getScaleFactor(); - GL11.glScissor( - left * scale, - height - bottom * scale, - (right - left) * scale, - (bottom - top) * scale - ); + public void set(ScaledResolution scaledResolution) { + int height = Minecraft.getMinecraft().displayHeight; + int scale = scaledResolution.getScaleFactor(); + GL11.glScissor( + left * scale, + height - bottom * scale, + (right - left) * scale, + (bottom - top) * scale + ); + } } - } - private static final LinkedList boundsStack = new LinkedList<>(); + private static final LinkedList boundsStack = new LinkedList<>(); - public static void push( - int left, - int top, - int right, - int bottom, - ScaledResolution scaledResolution - ) { - if (right < left) { - int temp = right; - right = left; - left = temp; - } - if (bottom < top) { - int temp = bottom; - bottom = top; - top = temp; - } - if (boundsStack.isEmpty()) { - boundsStack.push(new Bounds(left, top, right, bottom)); - } else { - boundsStack.push( - boundsStack.peek().createSubBound(left, top, right, bottom) - ); + public static void push( + int left, + int top, + int right, + int bottom, + ScaledResolution scaledResolution + ) { + if (right < left) { + int temp = right; + right = left; + left = temp; + } + if (bottom < top) { + int temp = bottom; + bottom = top; + top = temp; + } + if (boundsStack.isEmpty()) { + boundsStack.push(new Bounds(left, top, right, bottom)); + } else { + boundsStack.push( + boundsStack.peek().createSubBound(left, top, right, bottom) + ); + } + if (!boundsStack.isEmpty()) { + boundsStack.peek().set(scaledResolution); + } + GL11.glEnable(GL11.GL_SCISSOR_TEST); } - if (!boundsStack.isEmpty()) { - boundsStack.peek().set(scaledResolution); - } - GL11.glEnable(GL11.GL_SCISSOR_TEST); - } - public static void pop(ScaledResolution scaledResolution) { - if (!boundsStack.isEmpty()) { - boundsStack.pop(); - } - if (boundsStack.isEmpty()) { - GL11.glDisable(GL11.GL_SCISSOR_TEST); - } else { - boundsStack.peek().set(scaledResolution); + public static void pop(ScaledResolution scaledResolution) { + if (!boundsStack.isEmpty()) { + boundsStack.pop(); + } + if (boundsStack.isEmpty()) { + GL11.glDisable(GL11.GL_SCISSOR_TEST); + } else { + boundsStack.peek().set(scaledResolution); + } } - } - public static void clear() { - boundsStack.clear(); - GL11.glDisable(GL11.GL_SCISSOR_TEST); - } + public static void clear() { + boundsStack.clear(); + GL11.glDisable(GL11.GL_SCISSOR_TEST); + } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElement.java b/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElement.java index 67bf882..cb9b15a 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElement.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElement.java @@ -2,9 +2,9 @@ package com.thatgravyboat.skyblockhud.core; public abstract class GuiElement { - public abstract void render(); + public abstract void render(); - public abstract boolean mouseInput(int mouseX, int mouseY); + public abstract boolean mouseInput(int mouseX, int mouseY); - public abstract boolean keyboardInput(); + public abstract boolean keyboardInput(); } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElementBoolean.java b/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElementBoolean.java index 57ad267..a8ed7d5 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElementBoolean.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElementBoolean.java @@ -11,126 +11,132 @@ import org.lwjgl.input.Mouse; public class GuiElementBoolean extends GuiElement { - public int x; - public int y; - private boolean value; - private int clickRadius; - private Consumer toggleCallback; + public int x; + public int y; + private boolean value; + private int clickRadius; + private Consumer toggleCallback; - private boolean previewValue; - private int animation = 0; - private long lastMillis = 0; + private boolean previewValue; + private int animation = 0; + private long lastMillis = 0; - private static final int xSize = 48; - private static final int ySize = 14; + private static final int xSize = 48; + private static final int ySize = 14; - public GuiElementBoolean( - int x, - int y, - boolean value, - Consumer toggleCallback - ) { - this(x, y, value, 0, toggleCallback); - } + public GuiElementBoolean( + int x, + int y, + boolean value, + Consumer toggleCallback + ) { + this(x, y, value, 0, toggleCallback); + } - public GuiElementBoolean( - int x, - int y, - boolean value, - int clickRadius, - Consumer toggleCallback - ) { - this.x = x; - this.y = y; - this.value = value; - this.previewValue = value; - this.clickRadius = clickRadius; - this.toggleCallback = toggleCallback; - this.lastMillis = System.currentTimeMillis(); + public GuiElementBoolean( + int x, + int y, + boolean value, + int clickRadius, + Consumer toggleCallback + ) { + this.x = x; + this.y = y; + this.value = value; + this.previewValue = value; + this.clickRadius = clickRadius; + this.toggleCallback = toggleCallback; + this.lastMillis = System.currentTimeMillis(); - if (value) animation = 36; - } + if (value) animation = 36; + } - @Override - public void render() { - GlStateManager.color(1, 1, 1, 1); - Minecraft.getMinecraft().getTextureManager().bindTexture(GuiTextures.BAR); - RenderUtils.drawTexturedRect(x, y, xSize, ySize); + @Override + public void render() { + GlStateManager.color(1, 1, 1, 1); + Minecraft + .getMinecraft() + .getTextureManager() + .bindTexture(GuiTextures.BAR); + RenderUtils.drawTexturedRect(x, y, xSize, ySize); - ResourceLocation buttonLoc = GuiTextures.ON; - long currentMillis = System.currentTimeMillis(); - long deltaMillis = currentMillis - lastMillis; - lastMillis = currentMillis; - boolean passedLimit = false; - if (previewValue != value) { - if ( - (previewValue && animation > 12) || (!previewValue && animation < 24) - ) { - passedLimit = true; - } - } - if (previewValue != passedLimit) { - animation += deltaMillis / 10; - } else { - animation -= deltaMillis / 10; - } - lastMillis -= deltaMillis % 10; + ResourceLocation buttonLoc = GuiTextures.ON; + long currentMillis = System.currentTimeMillis(); + long deltaMillis = currentMillis - lastMillis; + lastMillis = currentMillis; + boolean passedLimit = false; + if (previewValue != value) { + if ( + (previewValue && animation > 12) || + (!previewValue && animation < 24) + ) { + passedLimit = true; + } + } + if (previewValue != passedLimit) { + animation += deltaMillis / 10; + } else { + animation -= deltaMillis / 10; + } + lastMillis -= deltaMillis % 10; - if (previewValue == value) { - animation = Math.max(0, Math.min(36, animation)); - } else if (!passedLimit) { - if (previewValue) { - animation = Math.max(0, Math.min(12, animation)); - } else { - animation = Math.max(24, Math.min(36, animation)); - } - } else { - if (previewValue) { - animation = Math.max(12, animation); - } else { - animation = Math.min(24, animation); - } - } + if (previewValue == value) { + animation = Math.max(0, Math.min(36, animation)); + } else if (!passedLimit) { + if (previewValue) { + animation = Math.max(0, Math.min(12, animation)); + } else { + animation = Math.max(24, Math.min(36, animation)); + } + } else { + if (previewValue) { + animation = Math.max(12, animation); + } else { + animation = Math.min(24, animation); + } + } - int animation = (int) (LerpUtils.sigmoidZeroOne(this.animation / 36f) * 36); - if (animation < 3) { - buttonLoc = GuiTextures.OFF; - } else if (animation < 13) { - buttonLoc = GuiTextures.ONE; - } else if (animation < 23) { - buttonLoc = GuiTextures.TWO; - } else if (animation < 33) { - buttonLoc = GuiTextures.THREE; - } + int animation = (int) ( + LerpUtils.sigmoidZeroOne(this.animation / 36f) * 36 + ); + if (animation < 3) { + buttonLoc = GuiTextures.OFF; + } else if (animation < 13) { + buttonLoc = GuiTextures.ONE; + } else if (animation < 23) { + buttonLoc = GuiTextures.TWO; + } else if (animation < 33) { + buttonLoc = GuiTextures.THREE; + } - Minecraft.getMinecraft().getTextureManager().bindTexture(buttonLoc); - RenderUtils.drawTexturedRect(x + animation, y, 12, 14); - } + Minecraft.getMinecraft().getTextureManager().bindTexture(buttonLoc); + RenderUtils.drawTexturedRect(x + animation, y, 12, 14); + } - @Override - public boolean mouseInput(int mouseX, int mouseY) { - if ( - mouseX > x - clickRadius && - mouseX < x + xSize + clickRadius && - mouseY > y - clickRadius && - mouseY < y + ySize + clickRadius - ) { - if (Mouse.getEventButton() == 0) { - if (Mouse.getEventButtonState()) { - previewValue = !value; - } else if (previewValue == !value) { - value = !value; - toggleCallback.accept(value); + @Override + public boolean mouseInput(int mouseX, int mouseY) { + if ( + mouseX > x - clickRadius && + mouseX < x + xSize + clickRadius && + mouseY > y - clickRadius && + mouseY < y + ySize + clickRadius + ) { + if (Mouse.getEventButton() == 0) { + if (Mouse.getEventButtonState()) { + previewValue = !value; + } else if (previewValue == !value) { + value = !value; + toggleCallback.accept(value); + } + } + } else { + previewValue = value; } - } - } else { - previewValue = value; + return false; } - return false; - } - @Override - public boolean keyboardInput() { - return false; - } + @Override + public boolean keyboardInput() { + return false; + } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElementColour.java b/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElementColour.java index 66a43da..8b5c2d6 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElementColour.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElementColour.java @@ -18,588 +18,651 @@ import org.lwjgl.opengl.GL11; public class GuiElementColour extends GuiElement { - public static final ResourceLocation colour_selector_dot = new ResourceLocation( - "skyblockhud:core/colour_selector_dot.png" - ); - public static final ResourceLocation colour_selector_bar = new ResourceLocation( - "skyblockhud:core/colour_selector_bar.png" - ); - public static final ResourceLocation colour_selector_bar_alpha = new ResourceLocation( - "skyblockhud:core/colour_selector_bar_alpha.png" - ); - public static final ResourceLocation colour_selector_chroma = new ResourceLocation( - "skyblockhud:core/colour_selector_chroma.png" - ); - - private static final ResourceLocation colourPickerLocation = new ResourceLocation( - "mbcore:dynamic/colourpicker" - ); - private static final ResourceLocation colourPickerBarValueLocation = new ResourceLocation( - "mbcore:dynamic/colourpickervalue" - ); - private static final ResourceLocation colourPickerBarOpacityLocation = new ResourceLocation( - "mbcore:dynamic/colourpickeropacity" - ); - private final GuiElementTextField hexField = new GuiElementTextField( - "", - GuiElementTextField.SCALE_TEXT | - GuiElementTextField.FORCE_CAPS | - GuiElementTextField.NO_SPACE - ); - - private int x; - private int y; - private final int xSize = 119; - private final int ySize = 89; - - private float wheelAngle = 0; - private float wheelRadius = 0; - - private int clickedComponent = -1; - - private Consumer colourChangedCallback; - private Runnable closeCallback; - private String colour; - - public GuiElementColour( - int x, - int y, - String initialColour, - Consumer colourChangedCallback, - Runnable closeCallback - ) { - final ScaledResolution scaledResolution = new ScaledResolution( - Minecraft.getMinecraft() + public static final ResourceLocation colour_selector_dot = new ResourceLocation( + "skyblockhud:core/colour_selector_dot.png" ); - - this.y = - Math.max( - 10, - Math.min(scaledResolution.getScaledHeight() - ySize - 10, y) - ); - this.x = - Math.max(10, Math.min(scaledResolution.getScaledWidth() - xSize - 10, x)); - - this.colour = initialColour; - this.colourChangedCallback = colourChangedCallback; - this.closeCallback = closeCallback; - - int colour = ChromaColour.specialToSimpleRGB(initialColour); - Color c = new Color(colour); - float[] hsv = Color.RGBtoHSB(c.getRed(), c.getGreen(), c.getBlue(), null); - updateAngleAndRadius(hsv); - } - - public void updateAngleAndRadius(float[] hsv) { - this.wheelRadius = hsv[1]; - this.wheelAngle = hsv[0] * 360; - } - - public void render() { - RenderUtils.drawFloatingRectDark(x, y, xSize, ySize); - - int currentColour = ChromaColour.specialToSimpleRGB(colour); - Color c = new Color(currentColour, true); - float[] hsv = Color.RGBtoHSB(c.getRed(), c.getGreen(), c.getBlue(), null); - - BufferedImage bufferedImage = new BufferedImage( - 288, - 288, - BufferedImage.TYPE_INT_ARGB + public static final ResourceLocation colour_selector_bar = new ResourceLocation( + "skyblockhud:core/colour_selector_bar.png" ); - float borderRadius = 0.05f; - if (Keyboard.isKeyDown(Keyboard.KEY_N)) borderRadius = 0; - for (int x = -16; x < 272; x++) { - for (int y = -16; y < 272; y++) { - float radius = (float) Math.sqrt( - ((x - 128) * (x - 128) + (y - 128) * (y - 128)) / 16384f - ); - float angle = (float) Math.toDegrees( - Math.atan((128 - x) / (y - 128 + 1E-5)) + Math.PI / 2 - ); - if (y < 128) angle += 180; - if (radius <= 1) { - int rgb = Color - .getHSBColor(angle / 360f, (float) Math.pow(radius, 1.5f), hsv[2]) - .getRGB(); - bufferedImage.setRGB(x + 16, y + 16, rgb); - } else if (radius <= 1 + borderRadius) { - float invBlackAlpha = - Math.abs(radius - 1 - borderRadius / 2) / borderRadius * 2; - float blackAlpha = 1 - invBlackAlpha; - - if (radius > 1 + borderRadius / 2) { - bufferedImage.setRGB( - x + 16, - y + 16, - (int) (blackAlpha * 255) << 24 - ); - } else { - Color col = Color.getHSBColor(angle / 360f, 1, hsv[2]); - int rgb = (int) (col.getRed() * invBlackAlpha) << 16 | - (int) (col.getGreen() * invBlackAlpha) << 8 | - (int) (col.getBlue() * invBlackAlpha); - bufferedImage.setRGB(x + 16, y + 16, 0xff000000 | rgb); - } - } - } - } - - BufferedImage bufferedImageValue = new BufferedImage( - 10, - 64, - BufferedImage.TYPE_INT_ARGB + public static final ResourceLocation colour_selector_bar_alpha = new ResourceLocation( + "skyblockhud:core/colour_selector_bar_alpha.png" ); - for (int x = 0; x < 10; x++) { - for (int y = 0; y < 64; y++) { - if ((x == 0 || x == 9) && (y == 0 || y == 63)) continue; - - int rgb = Color - .getHSBColor(wheelAngle / 360, wheelRadius, (64 - y) / 64f) - .getRGB(); - bufferedImageValue.setRGB(x, y, rgb); - } - } - - BufferedImage bufferedImageOpacity = new BufferedImage( - 10, - 64, - BufferedImage.TYPE_INT_ARGB + public static final ResourceLocation colour_selector_chroma = new ResourceLocation( + "skyblockhud:core/colour_selector_chroma.png" ); - for (int x = 0; x < 10; x++) { - for (int y = 0; y < 64; y++) { - if ((x == 0 || x == 9) && (y == 0 || y == 63)) continue; - - int rgb = - (currentColour & 0x00FFFFFF) | (Math.min(255, (64 - y) * 4) << 24); - bufferedImageOpacity.setRGB(x, y, rgb); - } - } - float selradius = (float) Math.pow(wheelRadius, 1 / 1.5f) * 32; - int selx = (int) (Math.cos(Math.toRadians(wheelAngle)) * selradius); - int sely = (int) (Math.sin(Math.toRadians(wheelAngle)) * selradius); - - Minecraft - .getMinecraft() - .getTextureManager() - .bindTexture(colour_selector_bar_alpha); - GlStateManager.color(1, 1, 1, 1); - RenderUtils.drawTexturedRect( - x + 5 + 64 + 5 + 10 + 5, - y + 5, - 10, - 64, - GL11.GL_NEAREST + private static final ResourceLocation colourPickerLocation = new ResourceLocation( + "mbcore:dynamic/colourpicker" ); - - Minecraft - .getMinecraft() - .getTextureManager() - .loadTexture( - colourPickerBarValueLocation, - new DynamicTexture(bufferedImageValue) - ); - Minecraft - .getMinecraft() - .getTextureManager() - .bindTexture(colourPickerBarValueLocation); - GlStateManager.color(1, 1, 1, 1); - RenderUtils.drawTexturedRect( - x + 5 + 64 + 5, - y + 5, - 10, - 64, - GL11.GL_NEAREST + private static final ResourceLocation colourPickerBarValueLocation = new ResourceLocation( + "mbcore:dynamic/colourpickervalue" ); - - Minecraft - .getMinecraft() - .getTextureManager() - .loadTexture( - colourPickerBarOpacityLocation, - new DynamicTexture(bufferedImageOpacity) - ); - Minecraft - .getMinecraft() - .getTextureManager() - .bindTexture(colourPickerBarOpacityLocation); - GlStateManager.color(1, 1, 1, 1); - RenderUtils.drawTexturedRect( - x + 5 + 64 + 5 + 10 + 5, - y + 5, - 10, - 64, - GL11.GL_NEAREST + private static final ResourceLocation colourPickerBarOpacityLocation = new ResourceLocation( + "mbcore:dynamic/colourpickeropacity" ); - - int chromaSpeed = ChromaColour.getSpeed(colour); - int currentColourChroma = ChromaColour.specialToChromaRGB(colour); - Color cChroma = new Color(currentColourChroma, true); - float hsvChroma[] = Color.RGBtoHSB( - cChroma.getRed(), - cChroma.getGreen(), - cChroma.getBlue(), - null + private final GuiElementTextField hexField = new GuiElementTextField( + "", + GuiElementTextField.SCALE_TEXT | + GuiElementTextField.FORCE_CAPS | + GuiElementTextField.NO_SPACE ); - if (chromaSpeed > 0) { - Gui.drawRect( - x + 5 + 64 + 5 + 10 + 5 + 10 + 5 + 1, - y + 5 + 1, - x + 5 + 64 + 5 + 10 + 5 + 10 + 5 + 10 - 1, - y + 5 + 64 - 1, - Color.HSBtoRGB(hsvChroma[0], 0.8f, 0.8f) - ); - } else { - Gui.drawRect( - x + 5 + 64 + 5 + 10 + 5 + 10 + 5 + 1, - y + 5 + 27 + 1, - x + 5 + 64 + 5 + 10 + 5 + 10 + 5 + 10 - 1, - y + 5 + 37 - 1, - Color.HSBtoRGB( - ( - hsvChroma[0] + - (System.currentTimeMillis() - ChromaColour.startTime) / - 1000f - ) % - 1, - 0.8f, - 0.8f - ) - ); - } + private int x; + private int y; + private final int xSize = 119; + private final int ySize = 89; - Minecraft - .getMinecraft() - .getTextureManager() - .bindTexture(colour_selector_bar); - GlStateManager.color(1, 1, 1, 1); - RenderUtils.drawTexturedRect( - x + 5 + 64 + 5, - y + 5, - 10, - 64, - GL11.GL_NEAREST - ); - RenderUtils.drawTexturedRect( - x + 5 + 64 + 5 + 10 + 5, - y + 5, - 10, - 64, - GL11.GL_NEAREST - ); + private float wheelAngle = 0; + private float wheelRadius = 0; + + private int clickedComponent = -1; + + private Consumer colourChangedCallback; + private Runnable closeCallback; + private String colour; + + public GuiElementColour( + int x, + int y, + String initialColour, + Consumer colourChangedCallback, + Runnable closeCallback + ) { + final ScaledResolution scaledResolution = new ScaledResolution( + Minecraft.getMinecraft() + ); - if (chromaSpeed > 0) { - RenderUtils.drawTexturedRect( - x + 5 + 64 + 5 + 10 + 5 + 10 + 5, - y + 5, - 10, - 64, - GL11.GL_NEAREST - ); - } else { - Minecraft - .getMinecraft() - .getTextureManager() - .bindTexture(colour_selector_chroma); - RenderUtils.drawTexturedRect( - x + 5 + 64 + 5 + 10 + 5 + 10 + 5, - y + 5 + 27, - 10, - 10, - GL11.GL_NEAREST - ); + this.y = + Math.max( + 10, + Math.min(scaledResolution.getScaledHeight() - ySize - 10, y) + ); + this.x = + Math.max( + 10, + Math.min(scaledResolution.getScaledWidth() - xSize - 10, x) + ); + + this.colour = initialColour; + this.colourChangedCallback = colourChangedCallback; + this.closeCallback = closeCallback; + + int colour = ChromaColour.specialToSimpleRGB(initialColour); + Color c = new Color(colour); + float[] hsv = Color.RGBtoHSB( + c.getRed(), + c.getGreen(), + c.getBlue(), + null + ); + updateAngleAndRadius(hsv); } - Gui.drawRect( - x + 5 + 64 + 5, - y + 5 + 64 - (int) (64 * hsv[2]), - x + 5 + 64 + 5 + 10, - y + 5 + 64 - (int) (64 * hsv[2]) + 1, - 0xFF000000 - ); - Gui.drawRect( - x + 5 + 64 + 5 + 10 + 5, - y + 5 + 64 - c.getAlpha() / 4, - x + 5 + 64 + 5 + 10 + 5 + 10, - y + 5 + 64 - c.getAlpha() / 4 - 1, - 0xFF000000 - ); - if (chromaSpeed > 0) { - Gui.drawRect( - x + 5 + 64 + 5 + 10 + 5 + 10 + 5, - y + 5 + 64 - (int) (chromaSpeed / 255f * 64), - x + 5 + 64 + 5 + 10 + 5 + 10 + 5 + 10, - y + 5 + 64 - (int) (chromaSpeed / 255f * 64) + 1, - 0xFF000000 - ); + public void updateAngleAndRadius(float[] hsv) { + this.wheelRadius = hsv[1]; + this.wheelAngle = hsv[0] * 360; } - Minecraft - .getMinecraft() - .getTextureManager() - .loadTexture(colourPickerLocation, new DynamicTexture(bufferedImage)); - Minecraft - .getMinecraft() - .getTextureManager() - .bindTexture(colourPickerLocation); - GlStateManager.color(1, 1, 1, 1); - RenderUtils.drawTexturedRect(x + 1, y + 1, 72, 72, GL11.GL_LINEAR); - - Minecraft - .getMinecraft() - .getTextureManager() - .bindTexture(colour_selector_dot); - GlStateManager.color(1, 1, 1, 1); - RenderUtils.drawTexturedRect( - x + 5 + 32 + selx - 4, - y + 5 + 32 + sely - 4, - 8, - 8, - GL11.GL_NEAREST - ); + public void render() { + RenderUtils.drawFloatingRectDark(x, y, xSize, ySize); - TextRenderUtils.drawStringCenteredScaledMaxWidth( - EnumChatFormatting.GRAY.toString() + Math.round(hsv[2] * 100) + "", - Minecraft.getMinecraft().fontRendererObj, - x + 5 + 64 + 5 + 5 - (Math.round(hsv[2] * 100) == 100 ? 1 : 0), - y + 5 + 64 + 5 + 5, - true, - 13, - -1 - ); - TextRenderUtils.drawStringCenteredScaledMaxWidth( - EnumChatFormatting.GRAY.toString() + - Math.round(c.getAlpha() / 255f * 100) + - "", - Minecraft.getMinecraft().fontRendererObj, - x + 5 + 64 + 5 + 15 + 5, - y + 5 + 64 + 5 + 5, - true, - 13, - -1 - ); - if (chromaSpeed > 0) { - TextRenderUtils.drawStringCenteredScaledMaxWidth( - EnumChatFormatting.GRAY.toString() + - (int) ChromaColour.getSecondsForSpeed(chromaSpeed) + - "s", - Minecraft.getMinecraft().fontRendererObj, - x + 5 + 64 + 5 + 30 + 6, - y + 5 + 64 + 5 + 5, - true, - 13, - -1 - ); - } + int currentColour = ChromaColour.specialToSimpleRGB(colour); + Color c = new Color(currentColour, true); + float[] hsv = Color.RGBtoHSB( + c.getRed(), + c.getGreen(), + c.getBlue(), + null + ); - hexField.setSize(48, 10); - if (!hexField.getFocus()) hexField.setText( - Integer.toHexString(c.getRGB() & 0xFFFFFF).toUpperCase() - ); + BufferedImage bufferedImage = new BufferedImage( + 288, + 288, + BufferedImage.TYPE_INT_ARGB + ); + float borderRadius = 0.05f; + if (Keyboard.isKeyDown(Keyboard.KEY_N)) borderRadius = 0; + for (int x = -16; x < 272; x++) { + for (int y = -16; y < 272; y++) { + float radius = (float) Math.sqrt( + ((x - 128) * (x - 128) + (y - 128) * (y - 128)) / 16384f + ); + float angle = (float) Math.toDegrees( + Math.atan((128 - x) / (y - 128 + 1E-5)) + Math.PI / 2 + ); + if (y < 128) angle += 180; + if (radius <= 1) { + int rgb = Color + .getHSBColor( + angle / 360f, + (float) Math.pow(radius, 1.5f), + hsv[2] + ) + .getRGB(); + bufferedImage.setRGB(x + 16, y + 16, rgb); + } else if (radius <= 1 + borderRadius) { + float invBlackAlpha = + Math.abs(radius - 1 - borderRadius / 2) / + borderRadius * + 2; + float blackAlpha = 1 - invBlackAlpha; + + if (radius > 1 + borderRadius / 2) { + bufferedImage.setRGB( + x + 16, + y + 16, + (int) (blackAlpha * 255) << 24 + ); + } else { + Color col = Color.getHSBColor(angle / 360f, 1, hsv[2]); + int rgb = (int) (col.getRed() * invBlackAlpha) << 16 | + (int) (col.getGreen() * invBlackAlpha) << 8 | + (int) (col.getBlue() * invBlackAlpha); + bufferedImage.setRGB(x + 16, y + 16, 0xff000000 | rgb); + } + } + } + } - StringBuilder sb = new StringBuilder(EnumChatFormatting.GRAY + "#"); - for (int i = 0; i < 6 - hexField.getText().length(); i++) { - sb.append("0"); - } - sb.append(EnumChatFormatting.WHITE); + BufferedImage bufferedImageValue = new BufferedImage( + 10, + 64, + BufferedImage.TYPE_INT_ARGB + ); + for (int x = 0; x < 10; x++) { + for (int y = 0; y < 64; y++) { + if ((x == 0 || x == 9) && (y == 0 || y == 63)) continue; + + int rgb = Color + .getHSBColor(wheelAngle / 360, wheelRadius, (64 - y) / 64f) + .getRGB(); + bufferedImageValue.setRGB(x, y, rgb); + } + } - hexField.setPrependText(sb.toString()); - hexField.render(x + 5 + 8, y + 5 + 64 + 5); - } + BufferedImage bufferedImageOpacity = new BufferedImage( + 10, + 64, + BufferedImage.TYPE_INT_ARGB + ); + for (int x = 0; x < 10; x++) { + for (int y = 0; y < 64; y++) { + if ((x == 0 || x == 9) && (y == 0 || y == 63)) continue; + + int rgb = + (currentColour & 0x00FFFFFF) | + (Math.min(255, (64 - y) * 4) << 24); + bufferedImageOpacity.setRGB(x, y, rgb); + } + } - public boolean mouseInput(int mouseX, int mouseY) { - ScaledResolution scaledResolution = new ScaledResolution( - Minecraft.getMinecraft() - ); - float mouseXF = (float) ( - Mouse.getX() * - scaledResolution.getScaledWidth_double() / - Minecraft.getMinecraft().displayWidth - ); - float mouseYF = (float) ( - scaledResolution.getScaledHeight_double() - - Mouse.getY() * - scaledResolution.getScaledHeight_double() / - Minecraft.getMinecraft().displayHeight - - 1 - ); + float selradius = (float) Math.pow(wheelRadius, 1 / 1.5f) * 32; + int selx = (int) (Math.cos(Math.toRadians(wheelAngle)) * selradius); + int sely = (int) (Math.sin(Math.toRadians(wheelAngle)) * selradius); + + Minecraft + .getMinecraft() + .getTextureManager() + .bindTexture(colour_selector_bar_alpha); + GlStateManager.color(1, 1, 1, 1); + RenderUtils.drawTexturedRect( + x + 5 + 64 + 5 + 10 + 5, + y + 5, + 10, + 64, + GL11.GL_NEAREST + ); - if ( - (Mouse.getEventButton() == 0 || Mouse.getEventButton() == 1) && - Mouse.getEventButtonState() - ) { - if (mouseX > x + 5 + 8 && mouseX < x + 5 + 8 + 48) { - if (mouseY > y + 5 + 64 + 5 && mouseY < y + 5 + 64 + 5 + 10) { - hexField.mouseClicked(mouseX, mouseY, Mouse.getEventButton()); - clickedComponent = -1; - return true; + Minecraft + .getMinecraft() + .getTextureManager() + .loadTexture( + colourPickerBarValueLocation, + new DynamicTexture(bufferedImageValue) + ); + Minecraft + .getMinecraft() + .getTextureManager() + .bindTexture(colourPickerBarValueLocation); + GlStateManager.color(1, 1, 1, 1); + RenderUtils.drawTexturedRect( + x + 5 + 64 + 5, + y + 5, + 10, + 64, + GL11.GL_NEAREST + ); + + Minecraft + .getMinecraft() + .getTextureManager() + .loadTexture( + colourPickerBarOpacityLocation, + new DynamicTexture(bufferedImageOpacity) + ); + Minecraft + .getMinecraft() + .getTextureManager() + .bindTexture(colourPickerBarOpacityLocation); + GlStateManager.color(1, 1, 1, 1); + RenderUtils.drawTexturedRect( + x + 5 + 64 + 5 + 10 + 5, + y + 5, + 10, + 64, + GL11.GL_NEAREST + ); + + int chromaSpeed = ChromaColour.getSpeed(colour); + int currentColourChroma = ChromaColour.specialToChromaRGB(colour); + Color cChroma = new Color(currentColourChroma, true); + float hsvChroma[] = Color.RGBtoHSB( + cChroma.getRed(), + cChroma.getGreen(), + cChroma.getBlue(), + null + ); + + if (chromaSpeed > 0) { + Gui.drawRect( + x + 5 + 64 + 5 + 10 + 5 + 10 + 5 + 1, + y + 5 + 1, + x + 5 + 64 + 5 + 10 + 5 + 10 + 5 + 10 - 1, + y + 5 + 64 - 1, + Color.HSBtoRGB(hsvChroma[0], 0.8f, 0.8f) + ); + } else { + Gui.drawRect( + x + 5 + 64 + 5 + 10 + 5 + 10 + 5 + 1, + y + 5 + 27 + 1, + x + 5 + 64 + 5 + 10 + 5 + 10 + 5 + 10 - 1, + y + 5 + 37 - 1, + Color.HSBtoRGB( + ( + hsvChroma[0] + + (System.currentTimeMillis() - ChromaColour.startTime) / + 1000f + ) % + 1, + 0.8f, + 0.8f + ) + ); } - } - } - if (!Mouse.getEventButtonState() && Mouse.getEventButton() == 0) { - clickedComponent = -1; - } - if (Mouse.getEventButtonState() && Mouse.getEventButton() == 0) { - if (mouseX >= x && mouseX <= x + 119 && mouseY >= y && mouseY <= y + 89) { - hexField.unfocus(); - int xWheel = mouseX - x - 5; - int yWheel = mouseY - y - 5; + Minecraft + .getMinecraft() + .getTextureManager() + .bindTexture(colour_selector_bar); + GlStateManager.color(1, 1, 1, 1); + RenderUtils.drawTexturedRect( + x + 5 + 64 + 5, + y + 5, + 10, + 64, + GL11.GL_NEAREST + ); + RenderUtils.drawTexturedRect( + x + 5 + 64 + 5 + 10 + 5, + y + 5, + 10, + 64, + GL11.GL_NEAREST + ); + + if (chromaSpeed > 0) { + RenderUtils.drawTexturedRect( + x + 5 + 64 + 5 + 10 + 5 + 10 + 5, + y + 5, + 10, + 64, + GL11.GL_NEAREST + ); + } else { + Minecraft + .getMinecraft() + .getTextureManager() + .bindTexture(colour_selector_chroma); + RenderUtils.drawTexturedRect( + x + 5 + 64 + 5 + 10 + 5 + 10 + 5, + y + 5 + 27, + 10, + 10, + GL11.GL_NEAREST + ); + } - if (xWheel > 0 && xWheel < 64) { - if (yWheel > 0 && yWheel < 64) { - clickedComponent = 0; - } + Gui.drawRect( + x + 5 + 64 + 5, + y + 5 + 64 - (int) (64 * hsv[2]), + x + 5 + 64 + 5 + 10, + y + 5 + 64 - (int) (64 * hsv[2]) + 1, + 0xFF000000 + ); + Gui.drawRect( + x + 5 + 64 + 5 + 10 + 5, + y + 5 + 64 - c.getAlpha() / 4, + x + 5 + 64 + 5 + 10 + 5 + 10, + y + 5 + 64 - c.getAlpha() / 4 - 1, + 0xFF000000 + ); + if (chromaSpeed > 0) { + Gui.drawRect( + x + 5 + 64 + 5 + 10 + 5 + 10 + 5, + y + 5 + 64 - (int) (chromaSpeed / 255f * 64), + x + 5 + 64 + 5 + 10 + 5 + 10 + 5 + 10, + y + 5 + 64 - (int) (chromaSpeed / 255f * 64) + 1, + 0xFF000000 + ); } - int xValue = mouseX - (x + 5 + 64 + 5); - int y = mouseY - this.y - 5; + Minecraft + .getMinecraft() + .getTextureManager() + .loadTexture( + colourPickerLocation, + new DynamicTexture(bufferedImage) + ); + Minecraft + .getMinecraft() + .getTextureManager() + .bindTexture(colourPickerLocation); + GlStateManager.color(1, 1, 1, 1); + RenderUtils.drawTexturedRect(x + 1, y + 1, 72, 72, GL11.GL_LINEAR); + + Minecraft + .getMinecraft() + .getTextureManager() + .bindTexture(colour_selector_dot); + GlStateManager.color(1, 1, 1, 1); + RenderUtils.drawTexturedRect( + x + 5 + 32 + selx - 4, + y + 5 + 32 + sely - 4, + 8, + 8, + GL11.GL_NEAREST + ); - if (y > -5 && y <= 69) { - if (xValue > 0 && xValue < 10) { - clickedComponent = 1; - } + TextRenderUtils.drawStringCenteredScaledMaxWidth( + EnumChatFormatting.GRAY.toString() + Math.round(hsv[2] * 100) + "", + Minecraft.getMinecraft().fontRendererObj, + x + 5 + 64 + 5 + 5 - (Math.round(hsv[2] * 100) == 100 ? 1 : 0), + y + 5 + 64 + 5 + 5, + true, + 13, + -1 + ); + TextRenderUtils.drawStringCenteredScaledMaxWidth( + EnumChatFormatting.GRAY.toString() + + Math.round(c.getAlpha() / 255f * 100) + + "", + Minecraft.getMinecraft().fontRendererObj, + x + 5 + 64 + 5 + 15 + 5, + y + 5 + 64 + 5 + 5, + true, + 13, + -1 + ); + if (chromaSpeed > 0) { + TextRenderUtils.drawStringCenteredScaledMaxWidth( + EnumChatFormatting.GRAY.toString() + + (int) ChromaColour.getSecondsForSpeed(chromaSpeed) + + "s", + Minecraft.getMinecraft().fontRendererObj, + x + 5 + 64 + 5 + 30 + 6, + y + 5 + 64 + 5 + 5, + true, + 13, + -1 + ); + } - int xOpacity = mouseX - (x + 5 + 64 + 5 + 10 + 5); + hexField.setSize(48, 10); + if (!hexField.getFocus()) hexField.setText( + Integer.toHexString(c.getRGB() & 0xFFFFFF).toUpperCase() + ); - if (xOpacity > 0 && xOpacity < 10) { - clickedComponent = 2; - } + StringBuilder sb = new StringBuilder(EnumChatFormatting.GRAY + "#"); + for (int i = 0; i < 6 - hexField.getText().length(); i++) { + sb.append("0"); } + sb.append(EnumChatFormatting.WHITE); - int chromaSpeed = ChromaColour.getSpeed(colour); - int xChroma = mouseX - (x + 5 + 64 + 5 + 10 + 5 + 10 + 5); - if (xChroma > 0 && xChroma < 10) { - if (chromaSpeed > 0) { - if (y > -5 && y <= 69) { - clickedComponent = 3; + hexField.setPrependText(sb.toString()); + hexField.render(x + 5 + 8, y + 5 + 64 + 5); + } + + public boolean mouseInput(int mouseX, int mouseY) { + ScaledResolution scaledResolution = new ScaledResolution( + Minecraft.getMinecraft() + ); + float mouseXF = (float) ( + Mouse.getX() * + scaledResolution.getScaledWidth_double() / + Minecraft.getMinecraft().displayWidth + ); + float mouseYF = (float) ( + scaledResolution.getScaledHeight_double() - + Mouse.getY() * + scaledResolution.getScaledHeight_double() / + Minecraft.getMinecraft().displayHeight - + 1 + ); + + if ( + (Mouse.getEventButton() == 0 || Mouse.getEventButton() == 1) && + Mouse.getEventButtonState() + ) { + if (mouseX > x + 5 + 8 && mouseX < x + 5 + 8 + 48) { + if (mouseY > y + 5 + 64 + 5 && mouseY < y + 5 + 64 + 5 + 10) { + hexField.mouseClicked( + mouseX, + mouseY, + Mouse.getEventButton() + ); + clickedComponent = -1; + return true; + } } - } else if (mouseY > this.y + 5 + 27 && mouseY < this.y + 5 + 37) { + } + if (!Mouse.getEventButtonState() && Mouse.getEventButton() == 0) { + clickedComponent = -1; + } + if (Mouse.getEventButtonState() && Mouse.getEventButton() == 0) { + if ( + mouseX >= x && + mouseX <= x + 119 && + mouseY >= y && + mouseY <= y + 89 + ) { + hexField.unfocus(); + + int xWheel = mouseX - x - 5; + int yWheel = mouseY - y - 5; + + if (xWheel > 0 && xWheel < 64) { + if (yWheel > 0 && yWheel < 64) { + clickedComponent = 0; + } + } + + int xValue = mouseX - (x + 5 + 64 + 5); + int y = mouseY - this.y - 5; + + if (y > -5 && y <= 69) { + if (xValue > 0 && xValue < 10) { + clickedComponent = 1; + } + + int xOpacity = mouseX - (x + 5 + 64 + 5 + 10 + 5); + + if (xOpacity > 0 && xOpacity < 10) { + clickedComponent = 2; + } + } + + int chromaSpeed = ChromaColour.getSpeed(colour); + int xChroma = mouseX - (x + 5 + 64 + 5 + 10 + 5 + 10 + 5); + if (xChroma > 0 && xChroma < 10) { + if (chromaSpeed > 0) { + if (y > -5 && y <= 69) { + clickedComponent = 3; + } + } else if ( + mouseY > this.y + 5 + 27 && mouseY < this.y + 5 + 37 + ) { + int currentColour = ChromaColour.specialToSimpleRGB( + colour + ); + Color c = new Color(currentColour, true); + colour = + ChromaColour.special( + 200, + c.getAlpha(), + currentColour + ); + colourChangedCallback.accept(colour); + } + } + } else { + hexField.unfocus(); + closeCallback.run(); + return false; + } + } + if (Mouse.isButtonDown(0) && clickedComponent >= 0) { int currentColour = ChromaColour.specialToSimpleRGB(colour); Color c = new Color(currentColour, true); - colour = ChromaColour.special(200, c.getAlpha(), currentColour); - colourChangedCallback.accept(colour); - } + float[] hsv = Color.RGBtoHSB( + c.getRed(), + c.getGreen(), + c.getBlue(), + null + ); + + float xWheel = mouseXF - x - 5; + float yWheel = mouseYF - y - 5; + + if (clickedComponent == 0) { + float angle = (float) Math.toDegrees( + Math.atan((32 - xWheel) / (yWheel - 32 + 1E-5)) + + Math.PI / + 2 + ); + xWheel = Math.max(0, Math.min(64, xWheel)); + yWheel = Math.max(0, Math.min(64, yWheel)); + float radius = (float) Math.sqrt( + ( + (xWheel - 32) * + (xWheel - 32) + + (yWheel - 32) * + (yWheel - 32) + ) / + 1024f + ); + if (yWheel < 32) angle += 180; + + this.wheelAngle = angle; + this.wheelRadius = (float) Math.pow(Math.min(1, radius), 1.5f); + int rgb = Color + .getHSBColor(angle / 360f, wheelRadius, hsv[2]) + .getRGB(); + colour = + ChromaColour.special( + ChromaColour.getSpeed(colour), + c.getAlpha(), + rgb + ); + colourChangedCallback.accept(colour); + return true; + } + + float y = mouseYF - this.y - 5; + y = Math.max(0, Math.min(64, y)); + System.out.println(y); + + if (clickedComponent == 1) { + int rgb = Color + .getHSBColor(wheelAngle / 360, wheelRadius, 1 - y / 64f) + .getRGB(); + colour = + ChromaColour.special( + ChromaColour.getSpeed(colour), + c.getAlpha(), + rgb + ); + colourChangedCallback.accept(colour); + return true; + } + + if (clickedComponent == 2) { + colour = + ChromaColour.special( + ChromaColour.getSpeed(colour), + 255 - Math.round(y / 64f * 255), + currentColour + ); + colourChangedCallback.accept(colour); + return true; + } + + if (clickedComponent == 3) { + colour = + ChromaColour.special( + 255 - Math.round(y / 64f * 255), + c.getAlpha(), + currentColour + ); + colourChangedCallback.accept(colour); + } + return true; } - } else { - hexField.unfocus(); - closeCallback.run(); return false; - } } - if (Mouse.isButtonDown(0) && clickedComponent >= 0) { - int currentColour = ChromaColour.specialToSimpleRGB(colour); - Color c = new Color(currentColour, true); - float[] hsv = Color.RGBtoHSB(c.getRed(), c.getGreen(), c.getBlue(), null); - float xWheel = mouseXF - x - 5; - float yWheel = mouseYF - y - 5; + public boolean keyboardInput() { + if (Keyboard.getEventKeyState() && hexField.getFocus()) { + if (Keyboard.getEventKey() == Keyboard.KEY_ESCAPE) { + hexField.unfocus(); + return true; + } + String old = hexField.getText(); - if (clickedComponent == 0) { - float angle = (float) Math.toDegrees( - Math.atan((32 - xWheel) / (yWheel - 32 + 1E-5)) + Math.PI / 2 - ); - xWheel = Math.max(0, Math.min(64, xWheel)); - yWheel = Math.max(0, Math.min(64, yWheel)); - float radius = (float) Math.sqrt( - ((xWheel - 32) * (xWheel - 32) + (yWheel - 32) * (yWheel - 32)) / - 1024f - ); - if (yWheel < 32) angle += 180; - - this.wheelAngle = angle; - this.wheelRadius = (float) Math.pow(Math.min(1, radius), 1.5f); - int rgb = Color.getHSBColor(angle / 360f, wheelRadius, hsv[2]).getRGB(); - colour = - ChromaColour.special( - ChromaColour.getSpeed(colour), - c.getAlpha(), - rgb - ); - colourChangedCallback.accept(colour); - return true; - } - - float y = mouseYF - this.y - 5; - y = Math.max(0, Math.min(64, y)); - System.out.println(y); - - if (clickedComponent == 1) { - int rgb = Color - .getHSBColor(wheelAngle / 360, wheelRadius, 1 - y / 64f) - .getRGB(); - colour = - ChromaColour.special( - ChromaColour.getSpeed(colour), - c.getAlpha(), - rgb - ); - colourChangedCallback.accept(colour); - return true; - } - - if (clickedComponent == 2) { - colour = - ChromaColour.special( - ChromaColour.getSpeed(colour), - 255 - Math.round(y / 64f * 255), - currentColour - ); - colourChangedCallback.accept(colour); - return true; - } - - if (clickedComponent == 3) { - colour = - ChromaColour.special( - 255 - Math.round(y / 64f * 255), - c.getAlpha(), - currentColour - ); - colourChangedCallback.accept(colour); - } - return true; - } - return false; - } - - public boolean keyboardInput() { - if (Keyboard.getEventKeyState() && hexField.getFocus()) { - if (Keyboard.getEventKey() == Keyboard.KEY_ESCAPE) { - hexField.unfocus(); - return true; - } - String old = hexField.getText(); - - hexField.keyTyped(Keyboard.getEventCharacter(), Keyboard.getEventKey()); - - if (hexField.getText().length() > 6) { - hexField.setText(old); - } else { - try { - String text = hexField.getText().toLowerCase(); - - int rgb = Integer.parseInt(text, 16); - int alpha = (ChromaColour.specialToSimpleRGB(colour) >> 24) & 0xFF; - colour = - ChromaColour.special(ChromaColour.getSpeed(colour), alpha, rgb); - colourChangedCallback.accept(colour); - - Color c = new Color(rgb); - float[] hsv = Color.RGBtoHSB( - c.getRed(), - c.getGreen(), - c.getBlue(), - null - ); - updateAngleAndRadius(hsv); - } catch (Exception e) {} - } + hexField.keyTyped( + Keyboard.getEventCharacter(), + Keyboard.getEventKey() + ); - return true; + if (hexField.getText().length() > 6) { + hexField.setText(old); + } else { + try { + String text = hexField.getText().toLowerCase(); + + int rgb = Integer.parseInt(text, 16); + int alpha = + (ChromaColour.specialToSimpleRGB(colour) >> 24) & 0xFF; + colour = + ChromaColour.special( + ChromaColour.getSpeed(colour), + alpha, + rgb + ); + colourChangedCallback.accept(colour); + + Color c = new Color(rgb); + float[] hsv = Color.RGBtoHSB( + c.getRed(), + c.getGreen(), + c.getBlue(), + null + ); + updateAngleAndRadius(hsv); + } catch (Exception e) {} + } + + return true; + } + return false; } - return false; - } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElementTextField.java b/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElementTextField.java index abb5a51..a3d01b5 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElementTextField.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElementTextField.java @@ -14,730 +14,771 @@ import net.minecraft.client.renderer.GlStateManager; public class GuiElementTextField { - public static final int SCALE_TEXT = 0b100000; - public static final int NUM_ONLY = 0b10000; - public static final int NO_SPACE = 0b01000; - public static final int FORCE_CAPS = 0b00100; - public static final int COLOUR = 0b00010; - public static final int MULTILINE = 0b00001; - - private int searchBarYSize; - private int searchBarXSize; - private static final int searchBarPadding = 2; - - private int options; - - private boolean focus = false; - - private int x; - private int y; - - private String prependText = ""; - - private final GuiTextField textField = new GuiTextField( - 0, - Minecraft.getMinecraft().fontRendererObj, - 0, - 0, - 0, - 0 - ); - - private int customBorderColour = -1; - - public GuiElementTextField(String initialText, int options) { - this(initialText, 100, 20, options); - } - - public GuiElementTextField( - String initialText, - int sizeX, - int sizeY, - int options - ) { - textField.setFocused(true); - textField.setCanLoseFocus(false); - textField.setMaxStringLength(999); - textField.setText(initialText); - this.searchBarXSize = sizeX; - this.searchBarYSize = sizeY; - this.options = options; - } - - public void setMaxStringLength(int len) { - textField.setMaxStringLength(len); - } - - public void setCustomBorderColour(int colour) { - this.customBorderColour = colour; - } - - public String getText() { - return textField.getText(); - } - - public void setPrependText(String text) { - this.prependText = text; - } - - public void setText(String text) { - if (textField.getText() == null || !textField.getText().equals(text)) { - textField.setText(text); - } - } + public static final int SCALE_TEXT = 0b100000; + public static final int NUM_ONLY = 0b10000; + public static final int NO_SPACE = 0b01000; + public static final int FORCE_CAPS = 0b00100; + public static final int COLOUR = 0b00010; + public static final int MULTILINE = 0b00001; - public void setSize(int searchBarXSize, int searchBarYSize) { - this.searchBarXSize = searchBarXSize; - this.searchBarYSize = searchBarYSize; - } + private int searchBarYSize; + private int searchBarXSize; + private static final int searchBarPadding = 2; - public void setOptions(int options) { - this.options = options; - } + private int options; - @Override - public String toString() { - return textField.getText(); - } + private boolean focus = false; - public void setFocus(boolean focus) { - this.focus = focus; - } + private int x; + private int y; - public boolean getFocus() { - return focus; - } + private String prependText = ""; - public int getHeight() { - ScaledResolution scaledresolution = new ScaledResolution( - Minecraft.getMinecraft() - ); - int paddingUnscaled = searchBarPadding / scaledresolution.getScaleFactor(); - - int numLines = - org.apache.commons.lang3.StringUtils.countMatches( - textField.getText(), - "\n" - ) + - 1; - int extraSize = (searchBarYSize - 8) / 2 + 8; - int bottomTextBox = searchBarYSize + extraSize * (numLines - 1); - - return bottomTextBox + paddingUnscaled * 2; - } - - public int getWidth() { - ScaledResolution scaledresolution = new ScaledResolution( - Minecraft.getMinecraft() + private final GuiTextField textField = new GuiTextField( + 0, + Minecraft.getMinecraft().fontRendererObj, + 0, + 0, + 0, + 0 ); - int paddingUnscaled = searchBarPadding / scaledresolution.getScaleFactor(); - return searchBarXSize + paddingUnscaled * 2; - } + private int customBorderColour = -1; - private float getScaleFactor(String str) { - return Math.min( - 1, - (searchBarXSize - 2) / - (float) Minecraft.getMinecraft().fontRendererObj.getStringWidth(str) - ); - } - - private boolean isScaling() { - return (options & SCALE_TEXT) != 0; - } - - private float getStringWidth(String str) { - if (isScaling()) { - return ( - Minecraft.getMinecraft().fontRendererObj.getStringWidth(str) * - getScaleFactor(str) - ); - } else { - return Minecraft.getMinecraft().fontRendererObj.getStringWidth(str); + public GuiElementTextField(String initialText, int options) { + this(initialText, 100, 20, options); } - } - public int getCursorPos(int mouseX, int mouseY) { - int xComp = mouseX - x; - int yComp = mouseY - y; + public GuiElementTextField( + String initialText, + int sizeX, + int sizeY, + int options + ) { + textField.setFocused(true); + textField.setCanLoseFocus(false); + textField.setMaxStringLength(999); + textField.setText(initialText); + this.searchBarXSize = sizeX; + this.searchBarYSize = sizeY; + this.options = options; + } - int extraSize = (searchBarYSize - 8) / 2 + 8; + public void setMaxStringLength(int len) { + textField.setMaxStringLength(len); + } - String renderText = prependText + textField.getText(); + public void setCustomBorderColour(int colour) { + this.customBorderColour = colour; + } - int lineNum = Math.round(((yComp - (searchBarYSize - 8) / 2)) / extraSize); + public String getText() { + return textField.getText(); + } - Pattern patternControlCode = Pattern.compile( - "(?i)\\u00A7([^\\u00B6])(?!\\u00B6)" - ); - String text = renderText; - String textNoColour = renderText; - if ((options & COLOUR) != 0) { - while (true) { - Matcher matcher = patternControlCode.matcher(text); - if (!matcher.find() || matcher.groupCount() < 1) break; - String code = matcher.group(1); - text = matcher.replaceFirst("\u00A7" + code + "\u00B6" + code); - } + public void setPrependText(String text) { + this.prependText = text; + } + + public void setText(String text) { + if (textField.getText() == null || !textField.getText().equals(text)) { + textField.setText(text); + } } - while (true) { - Matcher matcher = patternControlCode.matcher(textNoColour); - if (!matcher.find() || matcher.groupCount() < 1) break; - String code = matcher.group(1); - textNoColour = matcher.replaceFirst("\u00B6" + code); + + public void setSize(int searchBarXSize, int searchBarYSize) { + this.searchBarXSize = searchBarXSize; + this.searchBarYSize = searchBarYSize; } - int currentLine = 0; - int cursorIndex = 0; - for (; cursorIndex < textNoColour.length(); cursorIndex++) { - if (currentLine == lineNum) break; - if (textNoColour.charAt(cursorIndex) == '\n') { - currentLine++; - } + public void setOptions(int options) { + this.options = options; } - String textNC = textNoColour.substring(0, cursorIndex); - int colorCodes = org.apache.commons.lang3.StringUtils.countMatches( - textNC, - "\u00B6" - ); - String line = text - .substring(cursorIndex + (((options & COLOUR) != 0) ? colorCodes * 2 : 0)) - .split("\n")[0]; - int padding = Math.min(5, searchBarXSize - strLenNoColor(line)) / 2; - String trimmed = Minecraft - .getMinecraft() - .fontRendererObj.trimStringToWidth(line, xComp - padding); - int linePos = strLenNoColor(trimmed); - if (linePos != strLenNoColor(line)) { - char after = line.charAt(linePos); - int trimmedWidth = Minecraft - .getMinecraft() - .fontRendererObj.getStringWidth(trimmed); - int charWidth = Minecraft - .getMinecraft() - .fontRendererObj.getCharWidth(after); - if (trimmedWidth + charWidth / 2 < xComp - padding) { - linePos++; - } + @Override + public String toString() { + return textField.getText(); } - cursorIndex += linePos; - int pre = StringUtils.cleanColour(prependText).length(); - if (cursorIndex < pre) { - cursorIndex = 0; - } else { - cursorIndex -= pre; + public void setFocus(boolean focus) { + this.focus = focus; } - return cursorIndex; - } + public boolean getFocus() { + return focus; + } - public void mouseClicked(int mouseX, int mouseY, int mouseButton) { - if (mouseButton == 1) { - textField.setText(""); - } else { - textField.setCursorPosition(getCursorPos(mouseX, mouseY)); + public int getHeight() { + ScaledResolution scaledresolution = new ScaledResolution( + Minecraft.getMinecraft() + ); + int paddingUnscaled = + searchBarPadding / scaledresolution.getScaleFactor(); + + int numLines = + org.apache.commons.lang3.StringUtils.countMatches( + textField.getText(), + "\n" + ) + + 1; + int extraSize = (searchBarYSize - 8) / 2 + 8; + int bottomTextBox = searchBarYSize + extraSize * (numLines - 1); + + return bottomTextBox + paddingUnscaled * 2; } - focus = true; - } - - public void unfocus() { - focus = false; - textField.setSelectionPos(textField.getCursorPosition()); - } - - public int strLenNoColor(String str) { - return str.replaceAll("(?i)\\u00A7.", "").length(); - } - - public void mouseClickMove( - int mouseX, - int mouseY, - int clickedMouseButton, - long timeSinceLastClick - ) { - if (focus) { - textField.setSelectionPos(getCursorPos(mouseX, mouseY)); + + public int getWidth() { + ScaledResolution scaledresolution = new ScaledResolution( + Minecraft.getMinecraft() + ); + int paddingUnscaled = + searchBarPadding / scaledresolution.getScaleFactor(); + + return searchBarXSize + paddingUnscaled * 2; } - } - public void keyTyped(char typedChar, int keyCode) { - if (focus) { - if ((options & MULTILINE) != 0) { //Carriage return - Pattern patternControlCode = Pattern.compile( - "(?i)\\u00A7([^\\u00B6\n])(?!\\u00B6)" + private float getScaleFactor(String str) { + return Math.min( + 1, + (searchBarXSize - 2) / + (float) Minecraft.getMinecraft().fontRendererObj.getStringWidth(str) ); + } - String text = textField.getText(); - String textNoColour = textField.getText(); - while (true) { - Matcher matcher = patternControlCode.matcher(text); - if (!matcher.find() || matcher.groupCount() < 1) break; - String code = matcher.group(1); - text = matcher.replaceFirst("\u00A7" + code + "\u00B6" + code); + private boolean isScaling() { + return (options & SCALE_TEXT) != 0; + } + + private float getStringWidth(String str) { + if (isScaling()) { + return ( + Minecraft.getMinecraft().fontRendererObj.getStringWidth(str) * + getScaleFactor(str) + ); + } else { + return Minecraft.getMinecraft().fontRendererObj.getStringWidth(str); + } + } + + public int getCursorPos(int mouseX, int mouseY) { + int xComp = mouseX - x; + int yComp = mouseY - y; + + int extraSize = (searchBarYSize - 8) / 2 + 8; + + String renderText = prependText + textField.getText(); + + int lineNum = Math.round( + ((yComp - (searchBarYSize - 8) / 2)) / extraSize + ); + + Pattern patternControlCode = Pattern.compile( + "(?i)\\u00A7([^\\u00B6])(?!\\u00B6)" + ); + String text = renderText; + String textNoColour = renderText; + if ((options & COLOUR) != 0) { + while (true) { + Matcher matcher = patternControlCode.matcher(text); + if (!matcher.find() || matcher.groupCount() < 1) break; + String code = matcher.group(1); + text = matcher.replaceFirst("\u00A7" + code + "\u00B6" + code); + } } while (true) { - Matcher matcher = patternControlCode.matcher(textNoColour); - if (!matcher.find() || matcher.groupCount() < 1) break; - String code = matcher.group(1); - textNoColour = matcher.replaceFirst("\u00B6" + code); + Matcher matcher = patternControlCode.matcher(textNoColour); + if (!matcher.find() || matcher.groupCount() < 1) break; + String code = matcher.group(1); + textNoColour = matcher.replaceFirst("\u00B6" + code); } - if (keyCode == 28) { - String before = textField - .getText() - .substring(0, textField.getCursorPosition()); - String after = textField - .getText() - .substring(textField.getCursorPosition()); - int pos = textField.getCursorPosition(); - textField.setText(before + "\n" + after); - textField.setCursorPosition(pos + 1); - return; - } else if (keyCode == 200) { //Up - String textNCBeforeCursor = textNoColour.substring( - 0, - textField.getSelectionEnd() - ); - int colorCodes = org.apache.commons.lang3.StringUtils.countMatches( - textNCBeforeCursor, + int currentLine = 0; + int cursorIndex = 0; + for (; cursorIndex < textNoColour.length(); cursorIndex++) { + if (currentLine == lineNum) break; + if (textNoColour.charAt(cursorIndex) == '\n') { + currentLine++; + } + } + + String textNC = textNoColour.substring(0, cursorIndex); + int colorCodes = org.apache.commons.lang3.StringUtils.countMatches( + textNC, "\u00B6" - ); - String textBeforeCursor = text.substring( - 0, - textField.getSelectionEnd() + colorCodes * 2 - ); - - int numLinesBeforeCursor = org.apache.commons.lang3.StringUtils.countMatches( - textBeforeCursor, - "\n" - ); - - String[] split = textBeforeCursor.split("\n"); - int textBeforeCursorWidth; - String lineBefore; - String thisLineBeforeCursor; - if (split.length == numLinesBeforeCursor && split.length > 0) { - textBeforeCursorWidth = 0; - lineBefore = split[split.length - 1]; - thisLineBeforeCursor = ""; - } else if (split.length > 1) { - thisLineBeforeCursor = split[split.length - 1]; - lineBefore = split[split.length - 2]; - textBeforeCursorWidth = - Minecraft - .getMinecraft() - .fontRendererObj.getStringWidth(thisLineBeforeCursor); - } else { - return; - } - String trimmed = Minecraft + ); + String line = text + .substring( + cursorIndex + (((options & COLOUR) != 0) ? colorCodes * 2 : 0) + ) + .split("\n")[0]; + int padding = Math.min(5, searchBarXSize - strLenNoColor(line)) / 2; + String trimmed = Minecraft .getMinecraft() - .fontRendererObj.trimStringToWidth( - lineBefore, - textBeforeCursorWidth - ); - int linePos = strLenNoColor(trimmed); - if (linePos != strLenNoColor(lineBefore)) { - char after = lineBefore.charAt(linePos); + .fontRendererObj.trimStringToWidth(line, xComp - padding); + int linePos = strLenNoColor(trimmed); + if (linePos != strLenNoColor(line)) { + char after = line.charAt(linePos); int trimmedWidth = Minecraft - .getMinecraft() - .fontRendererObj.getStringWidth(trimmed); - int charWidth = Minecraft - .getMinecraft() - .fontRendererObj.getCharWidth(after); - if (trimmedWidth + charWidth / 2 < textBeforeCursorWidth) { - linePos++; - } - } - int newPos = - textField.getSelectionEnd() - - strLenNoColor(thisLineBeforeCursor) - - strLenNoColor(lineBefore) - - 1 + - linePos; - - if (GuiScreen.isShiftKeyDown()) { - textField.setSelectionPos(newPos); - } else { - textField.setCursorPosition(newPos); - } - } else if (keyCode == 208) { //Down - String textNCBeforeCursor = textNoColour.substring( - 0, - textField.getSelectionEnd() - ); - int colorCodes = org.apache.commons.lang3.StringUtils.countMatches( - textNCBeforeCursor, - "\u00B6" - ); - String textBeforeCursor = text.substring( - 0, - textField.getSelectionEnd() + colorCodes * 2 - ); - - int numLinesBeforeCursor = org.apache.commons.lang3.StringUtils.countMatches( - textBeforeCursor, - "\n" - ); - - String[] split = textBeforeCursor.split("\n"); - String thisLineBeforeCursor; - int textBeforeCursorWidth; - if (split.length == numLinesBeforeCursor) { - thisLineBeforeCursor = ""; - textBeforeCursorWidth = 0; - } else if (split.length > 0) { - thisLineBeforeCursor = split[split.length - 1]; - textBeforeCursorWidth = - Minecraft - .getMinecraft() - .fontRendererObj.getStringWidth(thisLineBeforeCursor); - } else { - return; - } - - String[] split2 = textNoColour.split("\n"); - if (split2.length > numLinesBeforeCursor + 1) { - String lineAfter = split2[numLinesBeforeCursor + 1]; - String trimmed = Minecraft - .getMinecraft() - .fontRendererObj.trimStringToWidth( - lineAfter, - textBeforeCursorWidth - ); - int linePos = strLenNoColor(trimmed); - if (linePos != strLenNoColor(lineAfter)) { - char after = lineAfter.charAt(linePos); - int trimmedWidth = Minecraft .getMinecraft() .fontRendererObj.getStringWidth(trimmed); - int charWidth = Minecraft + int charWidth = Minecraft .getMinecraft() .fontRendererObj.getCharWidth(after); - if (trimmedWidth + charWidth / 2 < textBeforeCursorWidth) { + if (trimmedWidth + charWidth / 2 < xComp - padding) { linePos++; - } } - int newPos = - textField.getSelectionEnd() - - strLenNoColor(thisLineBeforeCursor) + - strLenNoColor(split2[numLinesBeforeCursor]) + - 1 + - linePos; - - if (GuiScreen.isShiftKeyDown()) { - textField.setSelectionPos(newPos); - } else { - textField.setCursorPosition(newPos); - } - } } - } - - String old = textField.getText(); - if ((options & FORCE_CAPS) != 0) typedChar = - Character.toUpperCase(typedChar); - if ((options & NO_SPACE) != 0 && typedChar == ' ') return; - - textField.setFocused(true); - textField.textboxKeyTyped(typedChar, keyCode); - - if ((options & COLOUR) != 0) { - if (typedChar == '&') { - int pos = textField.getCursorPosition() - 2; - if (pos >= 0 && pos < textField.getText().length()) { - if (textField.getText().charAt(pos) == '&') { - String before = textField.getText().substring(0, pos); - String after = ""; - if (pos + 2 < textField.getText().length()) { - after = textField.getText().substring(pos + 2); - } - textField.setText(before + "\u00A7" + after); - textField.setCursorPosition(pos + 1); - } - } + cursorIndex += linePos; + + int pre = StringUtils.cleanColour(prependText).length(); + if (cursorIndex < pre) { + cursorIndex = 0; + } else { + cursorIndex -= pre; } - } - if ( - (options & NUM_ONLY) != 0 && textField.getText().matches("[^0-9.]") - ) textField.setText(old); + return cursorIndex; } - } - - public void render(int x, int y) { - this.x = x; - this.y = y; - drawTextbox( - x, - y, - searchBarXSize, - searchBarYSize, - searchBarPadding, - textField, - focus - ); - } - - private void drawTextbox( - int x, - int y, - int searchBarXSize, - int searchBarYSize, - int searchBarPadding, - GuiTextField textField, - boolean focus - ) { - ScaledResolution scaledresolution = new ScaledResolution( - Minecraft.getMinecraft() - ); - String renderText = prependText + textField.getText(); - GlStateManager.disableLighting(); + public void mouseClicked(int mouseX, int mouseY, int mouseButton) { + if (mouseButton == 1) { + textField.setText(""); + } else { + textField.setCursorPosition(getCursorPos(mouseX, mouseY)); + } + focus = true; + } - /** - * Search bar - */ - int paddingUnscaled = searchBarPadding / scaledresolution.getScaleFactor(); - if (paddingUnscaled < 1) paddingUnscaled = 1; + public void unfocus() { + focus = false; + textField.setSelectionPos(textField.getCursorPosition()); + } - int numLines = - org.apache.commons.lang3.StringUtils.countMatches(renderText, "\n") + 1; - int extraSize = (searchBarYSize - 8) / 2 + 8; - int bottomTextBox = y + searchBarYSize + extraSize * (numLines - 1); + public int strLenNoColor(String str) { + return str.replaceAll("(?i)\\u00A7.", "").length(); + } - int borderColour = focus ? Color.GREEN.getRGB() : Color.WHITE.getRGB(); - if (customBorderColour != -1) { - borderColour = customBorderColour; + public void mouseClickMove( + int mouseX, + int mouseY, + int clickedMouseButton, + long timeSinceLastClick + ) { + if (focus) { + textField.setSelectionPos(getCursorPos(mouseX, mouseY)); + } } - //bar background - Gui.drawRect( - x - paddingUnscaled, - y - paddingUnscaled, - x + searchBarXSize + paddingUnscaled, - bottomTextBox + paddingUnscaled, - borderColour - ); - Gui.drawRect(x, y, x + searchBarXSize, bottomTextBox, Color.BLACK.getRGB()); - //bar text - Pattern patternControlCode = Pattern.compile( - "(?i)\\u00A7([^\\u00B6\n])(?!\\u00B6)" - ); + public void keyTyped(char typedChar, int keyCode) { + if (focus) { + if ((options & MULTILINE) != 0) { //Carriage return + Pattern patternControlCode = Pattern.compile( + "(?i)\\u00A7([^\\u00B6\n])(?!\\u00B6)" + ); + + String text = textField.getText(); + String textNoColour = textField.getText(); + while (true) { + Matcher matcher = patternControlCode.matcher(text); + if (!matcher.find() || matcher.groupCount() < 1) break; + String code = matcher.group(1); + text = + matcher.replaceFirst("\u00A7" + code + "\u00B6" + code); + } + while (true) { + Matcher matcher = patternControlCode.matcher(textNoColour); + if (!matcher.find() || matcher.groupCount() < 1) break; + String code = matcher.group(1); + textNoColour = matcher.replaceFirst("\u00B6" + code); + } + + if (keyCode == 28) { + String before = textField + .getText() + .substring(0, textField.getCursorPosition()); + String after = textField + .getText() + .substring(textField.getCursorPosition()); + int pos = textField.getCursorPosition(); + textField.setText(before + "\n" + after); + textField.setCursorPosition(pos + 1); + return; + } else if (keyCode == 200) { //Up + String textNCBeforeCursor = textNoColour.substring( + 0, + textField.getSelectionEnd() + ); + int colorCodes = org.apache.commons.lang3.StringUtils.countMatches( + textNCBeforeCursor, + "\u00B6" + ); + String textBeforeCursor = text.substring( + 0, + textField.getSelectionEnd() + colorCodes * 2 + ); + + int numLinesBeforeCursor = org.apache.commons.lang3.StringUtils.countMatches( + textBeforeCursor, + "\n" + ); + + String[] split = textBeforeCursor.split("\n"); + int textBeforeCursorWidth; + String lineBefore; + String thisLineBeforeCursor; + if ( + split.length == numLinesBeforeCursor && split.length > 0 + ) { + textBeforeCursorWidth = 0; + lineBefore = split[split.length - 1]; + thisLineBeforeCursor = ""; + } else if (split.length > 1) { + thisLineBeforeCursor = split[split.length - 1]; + lineBefore = split[split.length - 2]; + textBeforeCursorWidth = + Minecraft + .getMinecraft() + .fontRendererObj.getStringWidth( + thisLineBeforeCursor + ); + } else { + return; + } + String trimmed = Minecraft + .getMinecraft() + .fontRendererObj.trimStringToWidth( + lineBefore, + textBeforeCursorWidth + ); + int linePos = strLenNoColor(trimmed); + if (linePos != strLenNoColor(lineBefore)) { + char after = lineBefore.charAt(linePos); + int trimmedWidth = Minecraft + .getMinecraft() + .fontRendererObj.getStringWidth(trimmed); + int charWidth = Minecraft + .getMinecraft() + .fontRendererObj.getCharWidth(after); + if ( + trimmedWidth + charWidth / 2 < textBeforeCursorWidth + ) { + linePos++; + } + } + int newPos = + textField.getSelectionEnd() - + strLenNoColor(thisLineBeforeCursor) - + strLenNoColor(lineBefore) - + 1 + + linePos; + + if (GuiScreen.isShiftKeyDown()) { + textField.setSelectionPos(newPos); + } else { + textField.setCursorPosition(newPos); + } + } else if (keyCode == 208) { //Down + String textNCBeforeCursor = textNoColour.substring( + 0, + textField.getSelectionEnd() + ); + int colorCodes = org.apache.commons.lang3.StringUtils.countMatches( + textNCBeforeCursor, + "\u00B6" + ); + String textBeforeCursor = text.substring( + 0, + textField.getSelectionEnd() + colorCodes * 2 + ); + + int numLinesBeforeCursor = org.apache.commons.lang3.StringUtils.countMatches( + textBeforeCursor, + "\n" + ); + + String[] split = textBeforeCursor.split("\n"); + String thisLineBeforeCursor; + int textBeforeCursorWidth; + if (split.length == numLinesBeforeCursor) { + thisLineBeforeCursor = ""; + textBeforeCursorWidth = 0; + } else if (split.length > 0) { + thisLineBeforeCursor = split[split.length - 1]; + textBeforeCursorWidth = + Minecraft + .getMinecraft() + .fontRendererObj.getStringWidth( + thisLineBeforeCursor + ); + } else { + return; + } + + String[] split2 = textNoColour.split("\n"); + if (split2.length > numLinesBeforeCursor + 1) { + String lineAfter = split2[numLinesBeforeCursor + 1]; + String trimmed = Minecraft + .getMinecraft() + .fontRendererObj.trimStringToWidth( + lineAfter, + textBeforeCursorWidth + ); + int linePos = strLenNoColor(trimmed); + if (linePos != strLenNoColor(lineAfter)) { + char after = lineAfter.charAt(linePos); + int trimmedWidth = Minecraft + .getMinecraft() + .fontRendererObj.getStringWidth(trimmed); + int charWidth = Minecraft + .getMinecraft() + .fontRendererObj.getCharWidth(after); + if ( + trimmedWidth + + charWidth / + 2 < + textBeforeCursorWidth + ) { + linePos++; + } + } + int newPos = + textField.getSelectionEnd() - + strLenNoColor(thisLineBeforeCursor) + + strLenNoColor(split2[numLinesBeforeCursor]) + + 1 + + linePos; + + if (GuiScreen.isShiftKeyDown()) { + textField.setSelectionPos(newPos); + } else { + textField.setCursorPosition(newPos); + } + } + } + } - String text = renderText; - String textNoColor = renderText; - if ((options & COLOUR) != 0) { - while (true) { - Matcher matcher = patternControlCode.matcher(text); - if (!matcher.find() || matcher.groupCount() < 1) break; - String code = matcher.group(1); - text = matcher.replaceFirst("\u00A7" + code + "\u00B6" + code); - } - } - while (true) { - Matcher matcher = patternControlCode.matcher(textNoColor); - if (!matcher.find() || matcher.groupCount() < 1) break; - String code = matcher.group(1); - textNoColor = matcher.replaceFirst("\u00B6" + code); - } + String old = textField.getText(); + if ((options & FORCE_CAPS) != 0) typedChar = + Character.toUpperCase(typedChar); + if ((options & NO_SPACE) != 0 && typedChar == ' ') return; + + textField.setFocused(true); + textField.textboxKeyTyped(typedChar, keyCode); + + if ((options & COLOUR) != 0) { + if (typedChar == '&') { + int pos = textField.getCursorPosition() - 2; + if (pos >= 0 && pos < textField.getText().length()) { + if (textField.getText().charAt(pos) == '&') { + String before = textField + .getText() + .substring(0, pos); + String after = ""; + if (pos + 2 < textField.getText().length()) { + after = textField.getText().substring(pos + 2); + } + textField.setText(before + "\u00A7" + after); + textField.setCursorPosition(pos + 1); + } + } + } + } - int xStartOffset = 5; - float scale = 1; - String[] texts = text.split("\n"); - for (int yOffI = 0; yOffI < texts.length; yOffI++) { - int yOff = yOffI * extraSize; - - if ( - isScaling() && - Minecraft.getMinecraft().fontRendererObj.getStringWidth(texts[yOffI]) > - searchBarXSize - - 10 - ) { - scale = - (searchBarXSize - 2) / - (float) Minecraft - .getMinecraft() - .fontRendererObj.getStringWidth(texts[yOffI]); - if (scale > 1) scale = 1; - float newLen = - Minecraft - .getMinecraft() - .fontRendererObj.getStringWidth(texts[yOffI]) * - scale; - xStartOffset = (int) ((searchBarXSize - newLen) / 2f); - - TextRenderUtils.drawStringCenteredScaledMaxWidth( - texts[yOffI], - Minecraft.getMinecraft().fontRendererObj, - x + searchBarXSize / 2f, - y + searchBarYSize / 2f + yOff, - false, - searchBarXSize - 2, - Color.WHITE.getRGB() - ); - } else { - Minecraft - .getMinecraft() - .fontRendererObj.drawString( - StringUtils.trimToWidth(texts[yOffI], searchBarXSize - 10), - x + 5, - y + (searchBarYSize - 8) / 2 + yOff, - Color.WHITE.getRGB() - ); - } + if ( + (options & NUM_ONLY) != 0 && + textField.getText().matches("[^0-9.]") + ) textField.setText(old); + } } - if (focus && System.currentTimeMillis() % 1000 > 500) { - String textNCBeforeCursor = textNoColor.substring( - 0, - textField.getCursorPosition() + prependText.length() - ); - int colorCodes = org.apache.commons.lang3.StringUtils.countMatches( - textNCBeforeCursor, - "\u00B6" - ); - String textBeforeCursor = text.substring( - 0, - textField.getCursorPosition() + - prependText.length() + - (((options & COLOUR) != 0) ? colorCodes * 2 : 0) - ); - - int numLinesBeforeCursor = org.apache.commons.lang3.StringUtils.countMatches( - textBeforeCursor, - "\n" - ); - int yOff = numLinesBeforeCursor * extraSize; - - String[] split = textBeforeCursor.split("\n"); - int textBeforeCursorWidth; - if (split.length <= numLinesBeforeCursor || split.length == 0) { - textBeforeCursorWidth = 0; - } else { - textBeforeCursorWidth = - (int) ( - Minecraft - .getMinecraft() - .fontRendererObj.getStringWidth(split[split.length - 1]) * - scale - ); - } - Gui.drawRect( - x + xStartOffset + textBeforeCursorWidth, - y + (searchBarYSize - 8) / 2 - 1 + yOff, - x + xStartOffset + textBeforeCursorWidth + 1, - y + (searchBarYSize - 8) / 2 + 9 + yOff, - Color.WHITE.getRGB() - ); + public void render(int x, int y) { + this.x = x; + this.y = y; + drawTextbox( + x, + y, + searchBarXSize, + searchBarYSize, + searchBarPadding, + textField, + focus + ); } - String selectedText = textField.getSelectedText(); - if (!selectedText.isEmpty()) { - System.out.println("Start"); - int leftIndex = Math.min( - textField.getCursorPosition() + prependText.length(), - textField.getSelectionEnd() + prependText.length() - ); - int rightIndex = Math.max( - textField.getCursorPosition() + prependText.length(), - textField.getSelectionEnd() + prependText.length() - ); - - float texX = 0; - int texY = 0; - boolean sectionSignPrev = false; - boolean ignoreNext = false; - boolean bold = false; - for (int i = 0; i < textNoColor.length(); i++) { - if (ignoreNext) { - ignoreNext = false; - continue; + private void drawTextbox( + int x, + int y, + int searchBarXSize, + int searchBarYSize, + int searchBarPadding, + GuiTextField textField, + boolean focus + ) { + ScaledResolution scaledresolution = new ScaledResolution( + Minecraft.getMinecraft() + ); + String renderText = prependText + textField.getText(); + + GlStateManager.disableLighting(); + + /** + * Search bar + */ + int paddingUnscaled = + searchBarPadding / scaledresolution.getScaleFactor(); + if (paddingUnscaled < 1) paddingUnscaled = 1; + + int numLines = + org.apache.commons.lang3.StringUtils.countMatches( + renderText, + "\n" + ) + + 1; + int extraSize = (searchBarYSize - 8) / 2 + 8; + int bottomTextBox = y + searchBarYSize + extraSize * (numLines - 1); + + int borderColour = focus ? Color.GREEN.getRGB() : Color.WHITE.getRGB(); + if (customBorderColour != -1) { + borderColour = customBorderColour; } + //bar background + Gui.drawRect( + x - paddingUnscaled, + y - paddingUnscaled, + x + searchBarXSize + paddingUnscaled, + bottomTextBox + paddingUnscaled, + borderColour + ); + Gui.drawRect( + x, + y, + x + searchBarXSize, + bottomTextBox, + Color.BLACK.getRGB() + ); + + //bar text + Pattern patternControlCode = Pattern.compile( + "(?i)\\u00A7([^\\u00B6\n])(?!\\u00B6)" + ); - char c = textNoColor.charAt(i); - if (sectionSignPrev) { - if ( - c != 'k' && - c != 'K' && - c != 'm' && - c != 'M' && - c != 'n' && - c != 'N' && - c != 'o' && - c != 'O' - ) { - bold = c == 'l' || c == 'L'; - } - sectionSignPrev = false; - if (i < prependText.length()) continue; + String text = renderText; + String textNoColor = renderText; + if ((options & COLOUR) != 0) { + while (true) { + Matcher matcher = patternControlCode.matcher(text); + if (!matcher.find() || matcher.groupCount() < 1) break; + String code = matcher.group(1); + text = matcher.replaceFirst("\u00A7" + code + "\u00B6" + code); + } } - if (c == '\u00B6') { - sectionSignPrev = true; - if (i < prependText.length()) continue; + while (true) { + Matcher matcher = patternControlCode.matcher(textNoColor); + if (!matcher.find() || matcher.groupCount() < 1) break; + String code = matcher.group(1); + textNoColor = matcher.replaceFirst("\u00B6" + code); } - if (c == '\n') { - if (i >= leftIndex && i < rightIndex) { - Gui.drawRect( - x + xStartOffset + (int) texX, - y + (searchBarYSize - 8) / 2 - 1 + texY, - x + xStartOffset + (int) texX + 3, - y + (searchBarYSize - 8) / 2 + 9 + texY, - Color.LIGHT_GRAY.getRGB() - ); - } - - texX = 0; - texY += extraSize; - continue; + int xStartOffset = 5; + float scale = 1; + String[] texts = text.split("\n"); + for (int yOffI = 0; yOffI < texts.length; yOffI++) { + int yOff = yOffI * extraSize; + + if ( + isScaling() && + Minecraft + .getMinecraft() + .fontRendererObj.getStringWidth(texts[yOffI]) > + searchBarXSize - + 10 + ) { + scale = + (searchBarXSize - 2) / + (float) Minecraft + .getMinecraft() + .fontRendererObj.getStringWidth(texts[yOffI]); + if (scale > 1) scale = 1; + float newLen = + Minecraft + .getMinecraft() + .fontRendererObj.getStringWidth(texts[yOffI]) * + scale; + xStartOffset = (int) ((searchBarXSize - newLen) / 2f); + + TextRenderUtils.drawStringCenteredScaledMaxWidth( + texts[yOffI], + Minecraft.getMinecraft().fontRendererObj, + x + searchBarXSize / 2f, + y + searchBarYSize / 2f + yOff, + false, + searchBarXSize - 2, + Color.WHITE.getRGB() + ); + } else { + Minecraft + .getMinecraft() + .fontRendererObj.drawString( + StringUtils.trimToWidth( + texts[yOffI], + searchBarXSize - 10 + ), + x + 5, + y + (searchBarYSize - 8) / 2 + yOff, + Color.WHITE.getRGB() + ); + } } - //String c2 = bold ? EnumChatFormatting.BOLD.toString() : "" + c; + if (focus && System.currentTimeMillis() % 1000 > 500) { + String textNCBeforeCursor = textNoColor.substring( + 0, + textField.getCursorPosition() + prependText.length() + ); + int colorCodes = org.apache.commons.lang3.StringUtils.countMatches( + textNCBeforeCursor, + "\u00B6" + ); + String textBeforeCursor = text.substring( + 0, + textField.getCursorPosition() + + prependText.length() + + (((options & COLOUR) != 0) ? colorCodes * 2 : 0) + ); - System.out.println( - "Adding len for char:" + c + ":" + Integer.toHexString(c) - ); - int len = Minecraft - .getMinecraft() - .fontRendererObj.getStringWidth(String.valueOf(c)); - if (bold) len++; - if (i >= leftIndex && i < rightIndex) { - Gui.drawRect( - x + xStartOffset + (int) texX, - y + (searchBarYSize - 8) / 2 - 1 + texY, - x + xStartOffset + (int) (texX + len * scale), - y + (searchBarYSize - 8) / 2 + 9 + texY, - Color.LIGHT_GRAY.getRGB() - ); - - TextRenderUtils.drawStringScaled( - String.valueOf(c), - Minecraft.getMinecraft().fontRendererObj, - x + xStartOffset + texX, - y + searchBarYSize / 2f - scale * 8 / 2f + texY, - false, - Color.BLACK.getRGB(), - scale - ); - if (bold) { - TextRenderUtils.drawStringScaled( - String.valueOf(c), - Minecraft.getMinecraft().fontRendererObj, - x + xStartOffset + texX + 1, - y + searchBarYSize / 2f - scale * 8 / 2f + texY, - false, - Color.BLACK.getRGB(), - scale + int numLinesBeforeCursor = org.apache.commons.lang3.StringUtils.countMatches( + textBeforeCursor, + "\n" + ); + int yOff = numLinesBeforeCursor * extraSize; + + String[] split = textBeforeCursor.split("\n"); + int textBeforeCursorWidth; + if (split.length <= numLinesBeforeCursor || split.length == 0) { + textBeforeCursorWidth = 0; + } else { + textBeforeCursorWidth = + (int) ( + Minecraft + .getMinecraft() + .fontRendererObj.getStringWidth( + split[split.length - 1] + ) * + scale + ); + } + Gui.drawRect( + x + xStartOffset + textBeforeCursorWidth, + y + (searchBarYSize - 8) / 2 - 1 + yOff, + x + xStartOffset + textBeforeCursorWidth + 1, + y + (searchBarYSize - 8) / 2 + 9 + yOff, + Color.WHITE.getRGB() ); - } } - texX += len * scale; - } + String selectedText = textField.getSelectedText(); + if (!selectedText.isEmpty()) { + System.out.println("Start"); + int leftIndex = Math.min( + textField.getCursorPosition() + prependText.length(), + textField.getSelectionEnd() + prependText.length() + ); + int rightIndex = Math.max( + textField.getCursorPosition() + prependText.length(), + textField.getSelectionEnd() + prependText.length() + ); + + float texX = 0; + int texY = 0; + boolean sectionSignPrev = false; + boolean ignoreNext = false; + boolean bold = false; + for (int i = 0; i < textNoColor.length(); i++) { + if (ignoreNext) { + ignoreNext = false; + continue; + } + + char c = textNoColor.charAt(i); + if (sectionSignPrev) { + if ( + c != 'k' && + c != 'K' && + c != 'm' && + c != 'M' && + c != 'n' && + c != 'N' && + c != 'o' && + c != 'O' + ) { + bold = c == 'l' || c == 'L'; + } + sectionSignPrev = false; + if (i < prependText.length()) continue; + } + if (c == '\u00B6') { + sectionSignPrev = true; + if (i < prependText.length()) continue; + } + + if (c == '\n') { + if (i >= leftIndex && i < rightIndex) { + Gui.drawRect( + x + xStartOffset + (int) texX, + y + (searchBarYSize - 8) / 2 - 1 + texY, + x + xStartOffset + (int) texX + 3, + y + (searchBarYSize - 8) / 2 + 9 + texY, + Color.LIGHT_GRAY.getRGB() + ); + } + + texX = 0; + texY += extraSize; + continue; + } + + //String c2 = bold ? EnumChatFormatting.BOLD.toString() : "" + c; + + System.out.println( + "Adding len for char:" + c + ":" + Integer.toHexString(c) + ); + int len = Minecraft + .getMinecraft() + .fontRendererObj.getStringWidth(String.valueOf(c)); + if (bold) len++; + if (i >= leftIndex && i < rightIndex) { + Gui.drawRect( + x + xStartOffset + (int) texX, + y + (searchBarYSize - 8) / 2 - 1 + texY, + x + xStartOffset + (int) (texX + len * scale), + y + (searchBarYSize - 8) / 2 + 9 + texY, + Color.LIGHT_GRAY.getRGB() + ); + + TextRenderUtils.drawStringScaled( + String.valueOf(c), + Minecraft.getMinecraft().fontRendererObj, + x + xStartOffset + texX, + y + searchBarYSize / 2f - scale * 8 / 2f + texY, + false, + Color.BLACK.getRGB(), + scale + ); + if (bold) { + TextRenderUtils.drawStringScaled( + String.valueOf(c), + Minecraft.getMinecraft().fontRendererObj, + x + xStartOffset + texX + 1, + y + searchBarYSize / 2f - scale * 8 / 2f + texY, + false, + Color.BLACK.getRGB(), + scale + ); + } + } + + texX += len * scale; + } + } } - } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/GuiScreenElementWrapper.java b/src/main/java/com/thatgravyboat/skyblockhud/core/GuiScreenElementWrapper.java index e1ee6ed..747d7c5 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/GuiScreenElementWrapper.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/GuiScreenElementWrapper.java @@ -6,30 +6,34 @@ import org.lwjgl.input.Mouse; public class GuiScreenElementWrapper extends GuiScreen { - public final GuiElement element; + public final GuiElement element; - public GuiScreenElementWrapper(GuiElement element) { - this.element = element; - } + public GuiScreenElementWrapper(GuiElement element) { + this.element = element; + } - @Override - public void drawScreen(int mouseX, int mouseY, float partialTicks) { - super.drawScreen(mouseX, mouseY, partialTicks); - element.render(); - } + @Override + public void drawScreen(int mouseX, int mouseY, float partialTicks) { + super.drawScreen(mouseX, mouseY, partialTicks); + element.render(); + } - @Override - public void handleMouseInput() throws IOException { - super.handleMouseInput(); - int i = Mouse.getEventX() * this.width / this.mc.displayWidth; - int j = - this.height - Mouse.getEventY() * this.height / this.mc.displayHeight - 1; - element.mouseInput(i, j); - } + @Override + public void handleMouseInput() throws IOException { + super.handleMouseInput(); + int i = Mouse.getEventX() * this.width / this.mc.displayWidth; + int j = + this.height - + Mouse.getEventY() * + this.height / + this.mc.displayHeight - + 1; + element.mouseInput(i, j); + } - @Override - public void handleKeyboardInput() throws IOException { - super.handleKeyboardInput(); - element.keyboardInput(); - } + @Override + public void handleKeyboardInput() throws IOException { + super.handleKeyboardInput(); + element.keyboardInput(); + } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/config/Config.java b/src/main/java/com/thatgravyboat/skyblockhud/core/config/Config.java index 08984e7..dbbca74 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/config/Config.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/config/Config.java @@ -2,5 +2,5 @@ package com.thatgravyboat.skyblockhud.core.config; public class Config { - public void executeRunnable(String runnableId) {} + public void executeRunnable(String runnableId) {} } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/config/Position.java b/src/main/java/com/thatgravyboat/skyblockhud/core/config/Position.java index 4d4bef0..0151e76 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/config/Position.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/config/Position.java @@ -5,204 +5,207 @@ import net.minecraft.client.gui.ScaledResolution; public class Position { - @Expose - private int x; + @Expose + private int x; - @Expose - private int y; + @Expose + private int y; - @Expose - private boolean centerX; + @Expose + private boolean centerX; - @Expose - private boolean centerY; + @Expose + private boolean centerY; - private static final int EDGE_OFFSET = 0; + private static final int EDGE_OFFSET = 0; - public Position(int x, int y) { - this(x, y, false, false); - } + public Position(int x, int y) { + this(x, y, false, false); + } + + public Position(int x, int y, boolean centerX, boolean centerY) { + this.x = x; + this.y = y; + this.centerX = centerX; + this.centerY = centerY; + } - public Position(int x, int y, boolean centerX, boolean centerY) { - this.x = x; - this.y = y; - this.centerX = centerX; - this.centerY = centerY; - } + public void set(Position other) { + this.x = other.x; + this.y = other.y; + this.centerX = other.centerX; + this.centerY = other.centerY; + } - public void set(Position other) { - this.x = other.x; - this.y = other.y; - this.centerX = other.centerX; - this.centerY = other.centerY; - } + public Position clone() { + return new Position(x, y, centerX, centerY); + } + + public boolean isCenterX() { + return centerX; + } - public Position clone() { - return new Position(x, y, centerX, centerY); - } + public boolean isCenterY() { + return centerY; + } - public boolean isCenterX() { - return centerX; - } + public int getRawX() { + return x; + } - public boolean isCenterY() { - return centerY; - } + public int getRawY() { + return y; + } - public int getRawX() { - return x; - } + public int getAbsX(ScaledResolution scaledResolution, int objWidth) { + int width = scaledResolution.getScaledWidth(); - public int getRawY() { - return y; - } + if (centerX) { + return width / 2 + x; + } - public int getAbsX(ScaledResolution scaledResolution, int objWidth) { - int width = scaledResolution.getScaledWidth(); + int ret = x; + if (x < 0) { + ret = width + x - objWidth; + } - if (centerX) { - return width / 2 + x; - } + if (ret < 0) ret = 0; + if (ret > width - objWidth) ret = width - objWidth; - int ret = x; - if (x < 0) { - ret = width + x - objWidth; + return ret; } - if (ret < 0) ret = 0; - if (ret > width - objWidth) ret = width - objWidth; + public int getAbsY(ScaledResolution scaledResolution, int objHeight) { + int height = scaledResolution.getScaledHeight(); - return ret; - } + if (centerY) { + return height / 2 + y; + } - public int getAbsY(ScaledResolution scaledResolution, int objHeight) { - int height = scaledResolution.getScaledHeight(); + int ret = y; + if (y < 0) { + ret = height + y - objHeight; + } - if (centerY) { - return height / 2 + y; - } + if (ret < 0) ret = 0; + if (ret > height - objHeight) ret = height - objHeight; - int ret = y; - if (y < 0) { - ret = height + y - objHeight; + return ret; } - if (ret < 0) ret = 0; - if (ret > height - objHeight) ret = height - objHeight; - - return ret; - } - - public int moveX( - int deltaX, - int objWidth, - ScaledResolution scaledResolution - ) { - int screenWidth = scaledResolution.getScaledWidth(); - boolean wasPositiveX = this.x >= 0; - this.x += deltaX; - - if (centerX) { - if (wasPositiveX) { - if (this.x > screenWidth / 2 - objWidth / 2) { - deltaX += screenWidth / 2 - objWidth / 2 - this.x; - this.x = screenWidth / 2 - objWidth / 2; + public int moveX( + int deltaX, + int objWidth, + ScaledResolution scaledResolution + ) { + int screenWidth = scaledResolution.getScaledWidth(); + boolean wasPositiveX = this.x >= 0; + this.x += deltaX; + + if (centerX) { + if (wasPositiveX) { + if (this.x > screenWidth / 2 - objWidth / 2) { + deltaX += screenWidth / 2 - objWidth / 2 - this.x; + this.x = screenWidth / 2 - objWidth / 2; + } + } else { + if (this.x < -screenWidth / 2 + objWidth / 2) { + deltaX += -screenWidth / 2 + objWidth / 2 - this.x; + this.x = -screenWidth / 2 + objWidth / 2; + } + } + return deltaX; } - } else { - if (this.x < -screenWidth / 2 + objWidth / 2) { - deltaX += -screenWidth / 2 + objWidth / 2 - this.x; - this.x = -screenWidth / 2 + objWidth / 2; + + if (wasPositiveX) { + if (this.x < EDGE_OFFSET) { + deltaX += EDGE_OFFSET - this.x; + this.x = EDGE_OFFSET; + } + if (this.x > screenWidth - EDGE_OFFSET) { + deltaX += screenWidth - EDGE_OFFSET - this.x; + this.x = screenWidth - EDGE_OFFSET; + } + } else { + if (this.x + 1 > -EDGE_OFFSET) { + deltaX += -EDGE_OFFSET - 1 - this.x; + this.x = -EDGE_OFFSET - 1; + } + if (this.x + screenWidth < EDGE_OFFSET) { + deltaX += EDGE_OFFSET - screenWidth - this.x; + this.x = EDGE_OFFSET - screenWidth; + } } - } - return deltaX; - } - if (wasPositiveX) { - if (this.x < EDGE_OFFSET) { - deltaX += EDGE_OFFSET - this.x; - this.x = EDGE_OFFSET; - } - if (this.x > screenWidth - EDGE_OFFSET) { - deltaX += screenWidth - EDGE_OFFSET - this.x; - this.x = screenWidth - EDGE_OFFSET; - } - } else { - if (this.x + 1 > -EDGE_OFFSET) { - deltaX += -EDGE_OFFSET - 1 - this.x; - this.x = -EDGE_OFFSET - 1; - } - if (this.x + screenWidth < EDGE_OFFSET) { - deltaX += EDGE_OFFSET - screenWidth - this.x; - this.x = EDGE_OFFSET - screenWidth; - } + if (this.x >= 0 && this.x + objWidth / 2 > screenWidth / 2) { + this.x -= screenWidth - objWidth; + } + if (this.x < 0 && this.x + objWidth / 2 <= -screenWidth / 2) { + this.x += screenWidth - objWidth; + } + return deltaX; } - if (this.x >= 0 && this.x + objWidth / 2 > screenWidth / 2) { - this.x -= screenWidth - objWidth; - } - if (this.x < 0 && this.x + objWidth / 2 <= -screenWidth / 2) { - this.x += screenWidth - objWidth; - } - return deltaX; - } - - public int moveY( - int deltaY, - int objHeight, - ScaledResolution scaledResolution - ) { - int screenHeight = scaledResolution.getScaledHeight(); - boolean wasPositiveY = this.y >= 0; - this.y += deltaY; - - if (centerY) { - if (wasPositiveY) { - if (this.y > screenHeight / 2 - objHeight / 2) { - deltaY += screenHeight / 2 - objHeight / 2 - this.y; - this.y = screenHeight / 2 - objHeight / 2; + public int moveY( + int deltaY, + int objHeight, + ScaledResolution scaledResolution + ) { + int screenHeight = scaledResolution.getScaledHeight(); + boolean wasPositiveY = this.y >= 0; + this.y += deltaY; + + if (centerY) { + if (wasPositiveY) { + if (this.y > screenHeight / 2 - objHeight / 2) { + deltaY += screenHeight / 2 - objHeight / 2 - this.y; + this.y = screenHeight / 2 - objHeight / 2; + } + } else { + if (this.y < -screenHeight / 2 + objHeight / 2) { + deltaY += -screenHeight / 2 + objHeight / 2 - this.y; + this.y = -screenHeight / 2 + objHeight / 2; + } + } + return deltaY; } - } else { - if (this.y < -screenHeight / 2 + objHeight / 2) { - deltaY += -screenHeight / 2 + objHeight / 2 - this.y; - this.y = -screenHeight / 2 + objHeight / 2; + + if (wasPositiveY) { + if (this.y < EDGE_OFFSET) { + deltaY += EDGE_OFFSET - this.y; + this.y = EDGE_OFFSET; + } + if (this.y > screenHeight - EDGE_OFFSET) { + deltaY += screenHeight - EDGE_OFFSET - this.y; + this.y = screenHeight - EDGE_OFFSET; + } + } else { + if (this.y + 1 > -EDGE_OFFSET) { + deltaY += -EDGE_OFFSET - 1 - this.y; + this.y = -EDGE_OFFSET - 1; + } + if (this.y + screenHeight < EDGE_OFFSET) { + deltaY += EDGE_OFFSET - screenHeight - this.y; + this.y = EDGE_OFFSET - screenHeight; + } } - } - return deltaY; - } - if (wasPositiveY) { - if (this.y < EDGE_OFFSET) { - deltaY += EDGE_OFFSET - this.y; - this.y = EDGE_OFFSET; - } - if (this.y > screenHeight - EDGE_OFFSET) { - deltaY += screenHeight - EDGE_OFFSET - this.y; - this.y = screenHeight - EDGE_OFFSET; - } - } else { - if (this.y + 1 > -EDGE_OFFSET) { - deltaY += -EDGE_OFFSET - 1 - this.y; - this.y = -EDGE_OFFSET - 1; - } - if (this.y + screenHeight < EDGE_OFFSET) { - deltaY += EDGE_OFFSET - screenHeight - this.y; - this.y = EDGE_OFFSET - screenHeight; - } + if (this.y >= 0 && this.y - objHeight / 2 > screenHeight / 2) { + this.y -= screenHeight - objHeight; + } + if (this.y < 0 && this.y - objHeight / 2 <= -screenHeight / 2) { + this.y += screenHeight - objHeight; + } + return deltaY; } - if (this.y >= 0 && this.y - objHeight / 2 > screenHeight / 2) { - this.y -= screenHeight - objHeight; - } - if (this.y < 0 && this.y - objHeight / 2 <= -screenHeight / 2) { - this.y += screenHeight - objHeight; + public boolean rightAligned( + ScaledResolution scaledResolution, + int objWidth + ) { + return ( + this.getAbsX(scaledResolution, objWidth) > + (scaledResolution.getScaledWidth() / 2) + ); } - return deltaY; - } - - public boolean rightAligned(ScaledResolution scaledResolution, int objWidth) { - return ( - this.getAbsX(scaledResolution, objWidth) > - (scaledResolution.getScaledWidth() / 2) - ); - } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/config/annotations/Category.java b/src/main/java/com/thatgravyboat/skyblockhud/core/config/annotations/Category.java index a7355b0..05ae6ad 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/config/annotations/Category.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/config/annotations/Category.java @@ -8,7 +8,7 @@ import java.lang.annotation.Target; @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.FIELD) public @interface Category { - String name(); + String name(); - String desc(); + String desc(); } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/config/annotations/ConfigAccordionId.java b/src/main/java/com/thatgravyboat/skyblockhud/core/config/annotations/ConfigAccordionId.java index b494137..44b82be 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/config/annotations/ConfigAccordionId.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/config/annotations/ConfigAccordionId.java @@ -8,5 +8,5 @@ import java.lang.annotation.Target; @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.FIELD) public @interface ConfigAccordionId { - int id(); + int id(); } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/config/annotations/ConfigEditorAccordion.java b/src/main/java/com/thatgravyboat/skyblockhud/core/config/annotations/ConfigEditorAccordion.java index 7ee271c..9712148 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/config/annotations/ConfigEditorAccordion.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/config/annotations/ConfigEditorAccordion.java @@ -8,5 +8,5 @@ import java.lang.annotation.Target; @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.FIELD) public @interface ConfigEditorAccordion { - int id(); + int id(); } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/config/annotations/ConfigEditorButton.java b/src/main/java/com/thatgravyboat/skyblockhud/core/config/annotations/ConfigEditorButton.java index fb8cbc7..5e4bab8 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/config/annotations/ConfigEditorButton.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/config/annotations/ConfigEditorButton.java @@ -8,7 +8,7 @@ import java.lang.annotation.Target; @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.FIELD) public @interface ConfigEditorButton { - String runnableId(); + String runnableId(); - String buttonText() default ""; + String buttonText() default ""; } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/config/annotations/ConfigEditorDraggableList.java b/src/main/java/com/thatgravyboat/skyblockhud/core/config/annotations/ConfigEditorDraggableList.java index 5a82b9e..6bbeb27 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/config/annotations/ConfigEditorDraggableList.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/config/annotations/ConfigEditorDraggableList.java @@ -8,5 +8,5 @@ import java.lang.annotation.Target; @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.FIELD) public @interface ConfigEditorDraggableList { - String[] exampleText(); + String[] exampleText(); } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/config/annotations/ConfigEditorDropdown.java b/src/main/java/com/thatgravyboat/skyblockhud/core/config/annotations/ConfigEditorDropdown.java index 66cc6a2..cc8bbf4 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/config/annotations/ConfigEditorDropdown.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/config/annotations/ConfigEditorDropdown.java @@ -8,7 +8,7 @@ import java.lang.annotation.Target; @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.FIELD) public @interface ConfigEditorDropdown { - String[] values(); + String[] values(); - int initialIndex() default 0; + int initialIndex() default 0; } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/config/annotations/ConfigEditorSlider.java b/src/main/java/com/thatgravyboat/skyblockhud/core/config/annotations/ConfigEditorSlider.java index 9bcbefa..dcdf0b1 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/config/annotations/ConfigEditorSlider.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/config/annotations/ConfigEditorSlider.java @@ -8,9 +8,9 @@ import java.lang.annotation.Target; @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.FIELD) public @interface ConfigEditorSlider { - float minValue(); + float minValue(); - float maxValue(); + float maxValue(); - float minStep(); + float minStep(); } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/config/annotations/ConfigOption.java b/src/main/java/com/thatgravyboat/skyblockhud/core/config/annotations/ConfigOption.java index 47471fd..4574758 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/config/annotations/ConfigOption.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/config/annotations/ConfigOption.java @@ -8,9 +8,9 @@ import java.lang.annotation.Target; @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.FIELD) public @interface ConfigOption { - String name(); + String name(); - String desc(); + String desc(); - int subcategoryId() default -1; + int subcategoryId() default -1; } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditor.java b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditor.java index fedecd1..5dfcecc 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditor.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditor.java @@ -9,92 +9,92 @@ import net.minecraft.client.renderer.GlStateManager; public abstract class GuiOptionEditor { - protected final ConfigProcessor.ProcessedOption option; - private static final int HEIGHT = 45; - - public GuiOptionEditor(ConfigProcessor.ProcessedOption option) { - this.option = option; - } - - public void render(int x, int y, int width) { - int height = getHeight(); - - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - RenderUtils.drawFloatingRectDark(x, y, width, height, true); - TextRenderUtils.drawStringCenteredScaledMaxWidth( - option.name, - fr, - x + width / 6f, - y + 13, - true, - width / 3 - 10, - 0xc0c0c0 - ); + protected final ConfigProcessor.ProcessedOption option; + private static final int HEIGHT = 45; - int maxLines = 5; - float scale = 1; - int lineCount = fr - .listFormattedStringToWidth(option.desc, width * 2 / 3 - 10) - .size(); + public GuiOptionEditor(ConfigProcessor.ProcessedOption option) { + this.option = option; + } - if (lineCount <= 0) return; + public void render(int x, int y, int width) { + int height = getHeight(); + + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + RenderUtils.drawFloatingRectDark(x, y, width, height, true); + TextRenderUtils.drawStringCenteredScaledMaxWidth( + option.name, + fr, + x + width / 6f, + y + 13, + true, + width / 3 - 10, + 0xc0c0c0 + ); + + int maxLines = 5; + float scale = 1; + int lineCount = fr + .listFormattedStringToWidth(option.desc, width * 2 / 3 - 10) + .size(); + + if (lineCount <= 0) return; + + float paraHeight = 9 * lineCount - 1; + + while (paraHeight >= HEIGHT - 10) { + scale -= 1 / 8f; + lineCount = + fr + .listFormattedStringToWidth( + option.desc, + (int) (width * 2 / 3 / scale - 10) + ) + .size(); + paraHeight = (int) (9 * scale * lineCount - 1 * scale); + } + + GlStateManager.pushMatrix(); + GlStateManager.translate( + x + 5 + width / 3f, + y + HEIGHT / 2f - paraHeight / 2, + 0 + ); + GlStateManager.scale(scale, scale, 1); + + fr.drawSplitString( + option.desc, + 0, + 0, + (int) (width * 2 / 3 / scale - 10), + 0xc0c0c0 + ); - float paraHeight = 9 * lineCount - 1; + GlStateManager.popMatrix(); + } - while (paraHeight >= HEIGHT - 10) { - scale -= 1 / 8f; - lineCount = - fr - .listFormattedStringToWidth( - option.desc, - (int) (width * 2 / 3 / scale - 10) - ) - .size(); - paraHeight = (int) (9 * scale * lineCount - 1 * scale); + public int getHeight() { + return HEIGHT; } - GlStateManager.pushMatrix(); - GlStateManager.translate( - x + 5 + width / 3f, - y + HEIGHT / 2f - paraHeight / 2, - 0 - ); - GlStateManager.scale(scale, scale, 1); - - fr.drawSplitString( - option.desc, - 0, - 0, - (int) (width * 2 / 3 / scale - 10), - 0xc0c0c0 + public abstract boolean mouseInput( + int x, + int y, + int width, + int mouseX, + int mouseY ); - GlStateManager.popMatrix(); - } - - public int getHeight() { - return HEIGHT; - } - - public abstract boolean mouseInput( - int x, - int y, - int width, - int mouseX, - int mouseY - ); - - public abstract boolean keyboardInput(); - - public boolean mouseInputOverlay( - int x, - int y, - int width, - int mouseX, - int mouseY - ) { - return false; - } - - public void renderOverlay(int x, int y, int width) {} + public abstract boolean keyboardInput(); + + public boolean mouseInputOverlay( + int x, + int y, + int width, + int mouseX, + int mouseY + ) { + return false; + } + + public void renderOverlay(int x, int y, int width) {} } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorAccordion.java b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorAccordion.java index 2387b3c..5270c01 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorAccordion.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorAccordion.java @@ -13,89 +13,93 @@ import org.lwjgl.opengl.GL11; public class GuiOptionEditorAccordion extends GuiOptionEditor { - private int accordionId; - private boolean accordionToggled; + private int accordionId; + private boolean accordionToggled; - public GuiOptionEditorAccordion( - ConfigProcessor.ProcessedOption option, - int accordionId - ) { - super(option); - this.accordionToggled = (boolean) option.get(); - this.accordionId = accordionId; - } + public GuiOptionEditorAccordion( + ConfigProcessor.ProcessedOption option, + int accordionId + ) { + super(option); + this.accordionToggled = (boolean) option.get(); + this.accordionId = accordionId; + } - @Override - public int getHeight() { - return 20; - } + @Override + public int getHeight() { + return 20; + } - public int getAccordionId() { - return accordionId; - } + public int getAccordionId() { + return accordionId; + } - public boolean getToggled() { - return accordionToggled; - } + public boolean getToggled() { + return accordionToggled; + } - @Override - public void render(int x, int y, int width) { - int height = getHeight(); - RenderUtils.drawFloatingRectDark(x, y, width, height, true); + @Override + public void render(int x, int y, int width) { + int height = getHeight(); + RenderUtils.drawFloatingRectDark(x, y, width, height, true); - Tessellator tessellator = Tessellator.getInstance(); - WorldRenderer worldrenderer = tessellator.getWorldRenderer(); - GlStateManager.enableBlend(); - GlStateManager.disableTexture2D(); - GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); - GlStateManager.color(1, 1, 1, 1); - worldrenderer.begin(GL11.GL_TRIANGLES, DefaultVertexFormats.POSITION); - if (accordionToggled) { - worldrenderer.pos((double) x + 6, (double) y + 6, 0.0D).endVertex(); - worldrenderer - .pos((double) x + 9.75f, (double) y + 13.5f, 0.0D) - .endVertex(); - worldrenderer.pos((double) x + 13.5f, (double) y + 6, 0.0D).endVertex(); - } else { - worldrenderer.pos((double) x + 6, (double) y + 13.5f, 0.0D).endVertex(); - worldrenderer - .pos((double) x + 13.5f, (double) y + 9.75f, 0.0D) - .endVertex(); - worldrenderer.pos((double) x + 6, (double) y + 6, 0.0D).endVertex(); + Tessellator tessellator = Tessellator.getInstance(); + WorldRenderer worldrenderer = tessellator.getWorldRenderer(); + GlStateManager.enableBlend(); + GlStateManager.disableTexture2D(); + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); + GlStateManager.color(1, 1, 1, 1); + worldrenderer.begin(GL11.GL_TRIANGLES, DefaultVertexFormats.POSITION); + if (accordionToggled) { + worldrenderer.pos((double) x + 6, (double) y + 6, 0.0D).endVertex(); + worldrenderer + .pos((double) x + 9.75f, (double) y + 13.5f, 0.0D) + .endVertex(); + worldrenderer + .pos((double) x + 13.5f, (double) y + 6, 0.0D) + .endVertex(); + } else { + worldrenderer + .pos((double) x + 6, (double) y + 13.5f, 0.0D) + .endVertex(); + worldrenderer + .pos((double) x + 13.5f, (double) y + 9.75f, 0.0D) + .endVertex(); + worldrenderer.pos((double) x + 6, (double) y + 6, 0.0D).endVertex(); + } + tessellator.draw(); + GlStateManager.enableTexture2D(); + GlStateManager.disableBlend(); + + TextRenderUtils.drawStringScaledMaxWidth( + option.name, + Minecraft.getMinecraft().fontRendererObj, + x + 18, + y + 6, + false, + width - 10, + 0xc0c0c0 + ); } - tessellator.draw(); - GlStateManager.enableTexture2D(); - GlStateManager.disableBlend(); - TextRenderUtils.drawStringScaledMaxWidth( - option.name, - Minecraft.getMinecraft().fontRendererObj, - x + 18, - y + 6, - false, - width - 10, - 0xc0c0c0 - ); - } + @Override + public boolean mouseInput(int x, int y, int width, int mouseX, int mouseY) { + if ( + Mouse.getEventButtonState() && + mouseX > x && + mouseX < x + width && + mouseY > y && + mouseY < y + getHeight() + ) { + accordionToggled = !accordionToggled; + return true; + } - @Override - public boolean mouseInput(int x, int y, int width, int mouseX, int mouseY) { - if ( - Mouse.getEventButtonState() && - mouseX > x && - mouseX < x + width && - mouseY > y && - mouseY < y + getHeight() - ) { - accordionToggled = !accordionToggled; - return true; + return false; } - return false; - } - - @Override - public boolean keyboardInput() { - return false; - } + @Override + public boolean keyboardInput() { + return false; + } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorBoolean.java b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorBoolean.java index 1e8b647..508a7cc 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorBoolean.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorBoolean.java @@ -5,33 +5,40 @@ import com.thatgravyboat.skyblockhud.core.config.struct.ConfigProcessor; public class GuiOptionEditorBoolean extends GuiOptionEditor { - private final GuiElementBoolean bool; - - public GuiOptionEditorBoolean(ConfigProcessor.ProcessedOption option) { - super(option); - bool = new GuiElementBoolean(0, 0, (boolean) option.get(), 10, option::set); - } - - @Override - public void render(int x, int y, int width) { - super.render(x, y, width); - int height = getHeight(); - - bool.x = x + width / 6 - 24; - bool.y = y + height - 7 - 14; - bool.render(); - } - - @Override - public boolean mouseInput(int x, int y, int width, int mouseX, int mouseY) { - int height = getHeight(); - bool.x = x + width / 6 - 24; - bool.y = y + height - 7 - 14; - return bool.mouseInput(mouseX, mouseY); - } - - @Override - public boolean keyboardInput() { - return false; - } + private final GuiElementBoolean bool; + + public GuiOptionEditorBoolean(ConfigProcessor.ProcessedOption option) { + super(option); + bool = + new GuiElementBoolean( + 0, + 0, + (boolean) option.get(), + 10, + option::set + ); + } + + @Override + public void render(int x, int y, int width) { + super.render(x, y, width); + int height = getHeight(); + + bool.x = x + width / 6 - 24; + bool.y = y + height - 7 - 14; + bool.render(); + } + + @Override + public boolean mouseInput(int x, int y, int width, int mouseX, int mouseY) { + int height = getHeight(); + bool.x = x + width / 6 - 24; + bool.y = y + height - 7 - 14; + return bool.mouseInput(mouseX, mouseY); + } + + @Override + public boolean keyboardInput() { + return false; + } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorButton.java b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorButton.java index 514f676..01fb7bd 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorButton.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorButton.java @@ -13,73 +13,74 @@ import org.lwjgl.input.Mouse; public class GuiOptionEditorButton extends GuiOptionEditor { - private final String runnableId; - private String buttonText; - private Config config; + private final String runnableId; + private String buttonText; + private Config config; - public GuiOptionEditorButton( - ConfigProcessor.ProcessedOption option, - String runnableId, - String buttonText, - Config config - ) { - super(option); - this.runnableId = runnableId; - this.config = config; + public GuiOptionEditorButton( + ConfigProcessor.ProcessedOption option, + String runnableId, + String buttonText, + Config config + ) { + super(option); + this.runnableId = runnableId; + this.config = config; - this.buttonText = buttonText; - if (this.buttonText != null && this.buttonText.isEmpty()) this.buttonText = - null; - } + this.buttonText = buttonText; + if ( + this.buttonText != null && this.buttonText.isEmpty() + ) this.buttonText = null; + } - @Override - public void render(int x, int y, int width) { - super.render(x, y, width); + @Override + public void render(int x, int y, int width) { + super.render(x, y, width); - int height = getHeight(); + int height = getHeight(); - GlStateManager.color(1, 1, 1, 1); - Minecraft.getMinecraft().getTextureManager().bindTexture(button_tex); - RenderUtils.drawTexturedRect( - x + width / 6 - 24, - y + height - 7 - 14, - 48, - 16 - ); + GlStateManager.color(1, 1, 1, 1); + Minecraft.getMinecraft().getTextureManager().bindTexture(button_tex); + RenderUtils.drawTexturedRect( + x + width / 6 - 24, + y + height - 7 - 14, + 48, + 16 + ); - if (buttonText != null) { - TextRenderUtils.drawStringCenteredScaledMaxWidth( - buttonText, - Minecraft.getMinecraft().fontRendererObj, - x + width / 6, - y + height - 7 - 6, - false, - 44, - 0xFF303030 - ); + if (buttonText != null) { + TextRenderUtils.drawStringCenteredScaledMaxWidth( + buttonText, + Minecraft.getMinecraft().fontRendererObj, + x + width / 6, + y + height - 7 - 6, + false, + 44, + 0xFF303030 + ); + } } - } - @Override - public boolean mouseInput(int x, int y, int width, int mouseX, int mouseY) { - if (Mouse.getEventButtonState()) { - int height = getHeight(); - if ( - mouseX > x + width / 6 - 24 && - mouseX < x + width / 6 + 24 && - mouseY > y + height - 7 - 14 && - mouseY < y + height - 7 + 2 - ) { - config.executeRunnable(runnableId); - return true; - } - } + @Override + public boolean mouseInput(int x, int y, int width, int mouseX, int mouseY) { + if (Mouse.getEventButtonState()) { + int height = getHeight(); + if ( + mouseX > x + width / 6 - 24 && + mouseX < x + width / 6 + 24 && + mouseY > y + height - 7 - 14 && + mouseY < y + height - 7 + 2 + ) { + config.executeRunnable(runnableId); + return true; + } + } - return false; - } + return false; + } - @Override - public boolean keyboardInput() { - return false; - } + @Override + public boolean keyboardInput() { + return false; + } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorColour.java b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorColour.java index 5052daa..ed44e5d 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorColour.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorColour.java @@ -12,81 +12,83 @@ import org.lwjgl.input.Mouse; public class GuiOptionEditorColour extends GuiOptionEditor { - private String chromaColour; - private GuiElementColour colourElement = null; + private String chromaColour; + private GuiElementColour colourElement = null; - public GuiOptionEditorColour(ConfigProcessor.ProcessedOption option) { - super(option); - this.chromaColour = (String) option.get(); - } - - @Override - public void render(int x, int y, int width) { - super.render(x, y, width); - int height = getHeight(); + public GuiOptionEditorColour(ConfigProcessor.ProcessedOption option) { + super(option); + this.chromaColour = (String) option.get(); + } - int argb = ChromaColour.specialToChromaRGB(chromaColour); - int r = (argb >> 16) & 0xFF; - int g = (argb >> 8) & 0xFF; - int b = argb & 0xFF; - GlStateManager.color(r / 255f, g / 255f, b / 255f, 1); - Minecraft.getMinecraft().getTextureManager().bindTexture(button_white); - RenderUtils.drawTexturedRect( - x + width / 6f - 24, - y + height - 7 - 14, - 48, - 16 - ); - } + @Override + public void render(int x, int y, int width) { + super.render(x, y, width); + int height = getHeight(); - @Override - public void renderOverlay(int x, int y, int width) { - if (colourElement != null) { - colourElement.render(); + int argb = ChromaColour.specialToChromaRGB(chromaColour); + int r = (argb >> 16) & 0xFF; + int g = (argb >> 8) & 0xFF; + int b = argb & 0xFF; + GlStateManager.color(r / 255f, g / 255f, b / 255f, 1); + Minecraft.getMinecraft().getTextureManager().bindTexture(button_white); + RenderUtils.drawTexturedRect( + x + width / 6f - 24, + y + height - 7 - 14, + 48, + 16 + ); } - } - @Override - public boolean mouseInputOverlay( - int x, - int y, - int width, - int mouseX, - int mouseY - ) { - return colourElement != null && colourElement.mouseInput(mouseX, mouseY); - } - - @Override - public boolean mouseInput(int x, int y, int width, int mouseX, int mouseY) { - int height = getHeight(); + @Override + public void renderOverlay(int x, int y, int width) { + if (colourElement != null) { + colourElement.render(); + } + } - if ( - Mouse.getEventButtonState() && - Mouse.getEventButton() == 0 && - mouseX > x + width / 6 - 24 && - mouseX < x + width / 6 + 24 && - mouseY > y + height - 7 - 14 && - mouseY < y + height - 7 + 2 + @Override + public boolean mouseInputOverlay( + int x, + int y, + int width, + int mouseX, + int mouseY ) { - colourElement = - new GuiElementColour( - mouseX, - mouseY, - (String) option.get(), - val -> { - option.set(val); - chromaColour = val; - }, - () -> colourElement = null + return ( + colourElement != null && colourElement.mouseInput(mouseX, mouseY) ); } - return false; - } + @Override + public boolean mouseInput(int x, int y, int width, int mouseX, int mouseY) { + int height = getHeight(); - @Override - public boolean keyboardInput() { - return colourElement != null && colourElement.keyboardInput(); - } + if ( + Mouse.getEventButtonState() && + Mouse.getEventButton() == 0 && + mouseX > x + width / 6 - 24 && + mouseX < x + width / 6 + 24 && + mouseY > y + height - 7 - 14 && + mouseY < y + height - 7 + 2 + ) { + colourElement = + new GuiElementColour( + mouseX, + mouseY, + (String) option.get(), + val -> { + option.set(val); + chromaColour = val; + }, + () -> colourElement = null + ); + } + + return false; + } + + @Override + public boolean keyboardInput() { + return colourElement != null && colourElement.keyboardInput(); + } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorDraggableList.java b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorDraggableList.java index c3b962f..619e144 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorDraggableList.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorDraggableList.java @@ -21,378 +21,386 @@ import org.lwjgl.opengl.GL11; public class GuiOptionEditorDraggableList extends GuiOptionEditor { - private static final ResourceLocation DELETE = new ResourceLocation( - "notenoughupdates:core/delete.png" - ); - - private String[] exampleText; - private List activeText; - private int currentDragging = -1; - private int dragStartIndex = -1; - - private long trashHoverTime = -1; - - private int dragOffsetX = -1; - private int dragOffsetY = -1; - - private boolean dropdownOpen = false; - - public GuiOptionEditorDraggableList( - ConfigProcessor.ProcessedOption option, - String[] exampleText - ) { - super(option); - this.exampleText = exampleText; - this.activeText = (List) option.get(); - } - - @Override - public int getHeight() { - int height = super.getHeight() + 13; - - for (int strIndex : activeText) { - String str = exampleText[strIndex]; - height += 10 * str.split("\n").length; - } + private static final ResourceLocation DELETE = new ResourceLocation( + "notenoughupdates:core/delete.png" + ); - return height; - } + private String[] exampleText; + private List activeText; + private int currentDragging = -1; + private int dragStartIndex = -1; - @Override - public void render(int x, int y, int width) { - super.render(x, y, width); + private long trashHoverTime = -1; - int height = getHeight(); + private int dragOffsetX = -1; + private int dragOffsetY = -1; - GlStateManager.color(1, 1, 1, 1); - Minecraft.getMinecraft().getTextureManager().bindTexture(button_tex); - RenderUtils.drawTexturedRect(x + width / 6f - 24, y + 45 - 7 - 14, 48, 16); + private boolean dropdownOpen = false; - TextRenderUtils.drawStringCenteredScaledMaxWidth( - "Add", - Minecraft.getMinecraft().fontRendererObj, - x + width / 6f, - y + 45 - 7 - 6, - false, - 44, - 0xFF303030 - ); + public GuiOptionEditorDraggableList( + ConfigProcessor.ProcessedOption option, + String[] exampleText + ) { + super(option); + this.exampleText = exampleText; + this.activeText = (List) option.get(); + } - long currentTime = System.currentTimeMillis(); - float greenBlue = LerpUtils.clampZeroOne( - ((trashHoverTime < 0 ? 250 : 0) + trashHoverTime - currentTime) / 250f - ); - GlStateManager.color(1, greenBlue, greenBlue, 1); - Minecraft.getMinecraft().getTextureManager().bindTexture(DELETE); - Utils.drawTexturedRect( - x + width / 6f + 27, - y + 45 - 7 - 13, - 11, - 14, - GL11.GL_NEAREST - ); + @Override + public int getHeight() { + int height = super.getHeight() + 13; - Gui.drawRect(x + 5, y + 45, x + width - 5, y + height - 5, 0xffdddddd); - Gui.drawRect(x + 6, y + 46, x + width - 6, y + height - 6, 0xff000000); + for (int strIndex : activeText) { + String str = exampleText[strIndex]; + height += 10 * str.split("\n").length; + } - int i = 0; - int yOff = 0; - for (int strIndex : activeText) { - String str = exampleText[strIndex]; + return height; + } - String[] multilines = str.split("\n"); + @Override + public void render(int x, int y, int width) { + super.render(x, y, width); - int ySize = multilines.length * 10; + int height = getHeight(); - if (i++ != dragStartIndex) { - for ( - int multilineIndex = 0; - multilineIndex < multilines.length; - multilineIndex++ - ) { - String line = multilines[multilineIndex]; - Utils.drawStringScaledMaxWidth( - line + EnumChatFormatting.RESET, - Minecraft.getMinecraft().fontRendererObj, - x + 20, - y + 50 + yOff + multilineIndex * 10, - true, - width - 20, - 0xffffffff - ); - } - Minecraft - .getMinecraft() - .fontRendererObj.drawString( - "\u2261", - x + 10, - y + 50 + yOff + ySize / 2f - 4, - 0xffffff, - true - ); - } - - yOff += ySize; - } - } - - @Override - public void renderOverlay(int x, int y, int width) { - super.renderOverlay(x, y, width); - - if (dropdownOpen) { - List remaining = new ArrayList<>(); - for (int i = 0; i < exampleText.length; i++) { - remaining.add(i); - } - remaining.removeAll(activeText); - - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - int dropdownWidth = Math.min(width / 2 - 10, 150); - int left = dragOffsetX; - int top = dragOffsetY; - - int dropdownHeight = -1 + 12 * remaining.size(); - - int main = 0xff202026; - int outline = 0xff404046; - Gui.drawRect(left, top, left + 1, top + dropdownHeight, outline); //Left - Gui.drawRect(left + 1, top, left + dropdownWidth, top + 1, outline); //Top - Gui.drawRect( - left + dropdownWidth - 1, - top + 1, - left + dropdownWidth, - top + dropdownHeight, - outline - ); //Right - Gui.drawRect( - left + 1, - top + dropdownHeight - 1, - left + dropdownWidth - 1, - top + dropdownHeight, - outline - ); //Bottom - Gui.drawRect( - left + 1, - top + 1, - left + dropdownWidth - 1, - top + dropdownHeight - 1, - main - ); //Middle - - int dropdownY = -1; - for (int strIndex : remaining) { - String str = exampleText[strIndex]; - if (str.isEmpty()) { - str = ""; - } - TextRenderUtils.drawStringScaledMaxWidth( - str.replaceAll("(\n.*)+", " ..."), - fr, - left + 3, - top + 3 + dropdownY, - false, - dropdownWidth - 6, - 0xffa0a0a0 + GlStateManager.color(1, 1, 1, 1); + Minecraft.getMinecraft().getTextureManager().bindTexture(button_tex); + RenderUtils.drawTexturedRect( + x + width / 6f - 24, + y + 45 - 7 - 14, + 48, + 16 ); - dropdownY += 12; - } - } else if (currentDragging >= 0) { - int opacity = 0x80; - long currentTime = System.currentTimeMillis(); - if (trashHoverTime < 0) { - float greenBlue = LerpUtils.clampZeroOne( - (currentTime + trashHoverTime) / 250f + + TextRenderUtils.drawStringCenteredScaledMaxWidth( + "Add", + Minecraft.getMinecraft().fontRendererObj, + x + width / 6f, + y + 45 - 7 - 6, + false, + 44, + 0xFF303030 ); - opacity = (int) (opacity * greenBlue); - } else { + + long currentTime = System.currentTimeMillis(); float greenBlue = LerpUtils.clampZeroOne( - (250 + trashHoverTime - currentTime) / 250f - ); - opacity = (int) (opacity * greenBlue); - } - - if (opacity < 20) return; - - ScaledResolution scaledResolution = new ScaledResolution( - Minecraft.getMinecraft() - ); - int mouseX = - Mouse.getX() * - scaledResolution.getScaledWidth() / - Minecraft.getMinecraft().displayWidth; - int mouseY = - scaledResolution.getScaledHeight() - - Mouse.getY() * - scaledResolution.getScaledHeight() / - Minecraft.getMinecraft().displayHeight - - 1; - - String str = exampleText[currentDragging]; - - String[] multilines = str.split("\n"); - - GlStateManager.enableBlend(); - for ( - int multilineIndex = 0; - multilineIndex < multilines.length; - multilineIndex++ - ) { - String line = multilines[multilineIndex]; - Utils.drawStringScaledMaxWidth( - line + EnumChatFormatting.RESET, - Minecraft.getMinecraft().fontRendererObj, - dragOffsetX + mouseX + 10, - dragOffsetY + mouseY + multilineIndex * 10, - true, - width - 20, - 0xffffff | (opacity << 24) + ((trashHoverTime < 0 ? 250 : 0) + trashHoverTime - currentTime) / + 250f ); - } - - int ySize = multilines.length * 10; - - Minecraft - .getMinecraft() - .fontRendererObj.drawString( - "\u2261", - dragOffsetX + mouseX, - dragOffsetY + mouseY + ySize / 2f - 4, - 0xffffff, - true + GlStateManager.color(1, greenBlue, greenBlue, 1); + Minecraft.getMinecraft().getTextureManager().bindTexture(DELETE); + Utils.drawTexturedRect( + x + width / 6f + 27, + y + 45 - 7 - 13, + 11, + 14, + GL11.GL_NEAREST ); - } - } - - @Override - public boolean mouseInput(int x, int y, int width, int mouseX, int mouseY) { - if ( - !Mouse.getEventButtonState() && - !dropdownOpen && - dragStartIndex >= 0 && - Mouse.getEventButton() == 0 && - mouseX >= x + width / 6 + 27 - 3 && - mouseX <= x + width / 6 + 27 + 11 + 3 && - mouseY >= y + 45 - 7 - 13 - 3 && - mouseY <= y + 45 - 7 - 13 + 14 + 3 - ) { - activeText.remove(dragStartIndex); - currentDragging = -1; - dragStartIndex = -1; - return false; - } - if (!Mouse.isButtonDown(0) || dropdownOpen) { - currentDragging = -1; - dragStartIndex = -1; - if (trashHoverTime > 0) trashHoverTime = -System.currentTimeMillis(); - } else if ( - currentDragging >= 0 && - mouseX >= x + width / 6 + 27 - 3 && - mouseX <= x + width / 6 + 27 + 11 + 3 && - mouseY >= y + 45 - 7 - 13 - 3 && - mouseY <= y + 45 - 7 - 13 + 14 + 3 - ) { - if (trashHoverTime < 0) trashHoverTime = System.currentTimeMillis(); - } else { - if (trashHoverTime > 0) trashHoverTime = -System.currentTimeMillis(); - } + Gui.drawRect(x + 5, y + 45, x + width - 5, y + height - 5, 0xffdddddd); + Gui.drawRect(x + 6, y + 46, x + width - 6, y + height - 6, 0xff000000); - if (Mouse.getEventButtonState()) { - int height = getHeight(); + int i = 0; + int yOff = 0; + for (int strIndex : activeText) { + String str = exampleText[strIndex]; + + String[] multilines = str.split("\n"); + + int ySize = multilines.length * 10; + + if (i++ != dragStartIndex) { + for ( + int multilineIndex = 0; + multilineIndex < multilines.length; + multilineIndex++ + ) { + String line = multilines[multilineIndex]; + Utils.drawStringScaledMaxWidth( + line + EnumChatFormatting.RESET, + Minecraft.getMinecraft().fontRendererObj, + x + 20, + y + 50 + yOff + multilineIndex * 10, + true, + width - 20, + 0xffffffff + ); + } + Minecraft + .getMinecraft() + .fontRendererObj.drawString( + "\u2261", + x + 10, + y + 50 + yOff + ySize / 2f - 4, + 0xffffff, + true + ); + } - if (dropdownOpen) { - List remaining = new ArrayList<>(); - for (int i = 0; i < exampleText.length; i++) { - remaining.add(i); + yOff += ySize; } - remaining.removeAll(activeText); + } - int dropdownWidth = Math.min(width / 2 - 10, 150); - int left = dragOffsetX; - int top = dragOffsetY; + @Override + public void renderOverlay(int x, int y, int width) { + super.renderOverlay(x, y, width); - int dropdownHeight = -1 + 12 * remaining.size(); + if (dropdownOpen) { + List remaining = new ArrayList<>(); + for (int i = 0; i < exampleText.length; i++) { + remaining.add(i); + } + remaining.removeAll(activeText); + + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + int dropdownWidth = Math.min(width / 2 - 10, 150); + int left = dragOffsetX; + int top = dragOffsetY; + + int dropdownHeight = -1 + 12 * remaining.size(); + + int main = 0xff202026; + int outline = 0xff404046; + Gui.drawRect(left, top, left + 1, top + dropdownHeight, outline); //Left + Gui.drawRect(left + 1, top, left + dropdownWidth, top + 1, outline); //Top + Gui.drawRect( + left + dropdownWidth - 1, + top + 1, + left + dropdownWidth, + top + dropdownHeight, + outline + ); //Right + Gui.drawRect( + left + 1, + top + dropdownHeight - 1, + left + dropdownWidth - 1, + top + dropdownHeight, + outline + ); //Bottom + Gui.drawRect( + left + 1, + top + 1, + left + dropdownWidth - 1, + top + dropdownHeight - 1, + main + ); //Middle + + int dropdownY = -1; + for (int strIndex : remaining) { + String str = exampleText[strIndex]; + if (str.isEmpty()) { + str = ""; + } + TextRenderUtils.drawStringScaledMaxWidth( + str.replaceAll("(\n.*)+", " ..."), + fr, + left + 3, + top + 3 + dropdownY, + false, + dropdownWidth - 6, + 0xffa0a0a0 + ); + dropdownY += 12; + } + } else if (currentDragging >= 0) { + int opacity = 0x80; + long currentTime = System.currentTimeMillis(); + if (trashHoverTime < 0) { + float greenBlue = LerpUtils.clampZeroOne( + (currentTime + trashHoverTime) / 250f + ); + opacity = (int) (opacity * greenBlue); + } else { + float greenBlue = LerpUtils.clampZeroOne( + (250 + trashHoverTime - currentTime) / 250f + ); + opacity = (int) (opacity * greenBlue); + } - if ( - mouseX > left && - mouseX < left + dropdownWidth && - mouseY > top && - mouseY < top + dropdownHeight - ) { - int dropdownY = -1; - for (int strIndex : remaining) { - if (mouseY < top + dropdownY + 12) { - activeText.add(0, strIndex); - if (remaining.size() == 1) dropdownOpen = false; - return true; + if (opacity < 20) return; + + ScaledResolution scaledResolution = new ScaledResolution( + Minecraft.getMinecraft() + ); + int mouseX = + Mouse.getX() * + scaledResolution.getScaledWidth() / + Minecraft.getMinecraft().displayWidth; + int mouseY = + scaledResolution.getScaledHeight() - + Mouse.getY() * + scaledResolution.getScaledHeight() / + Minecraft.getMinecraft().displayHeight - + 1; + + String str = exampleText[currentDragging]; + + String[] multilines = str.split("\n"); + + GlStateManager.enableBlend(); + for ( + int multilineIndex = 0; + multilineIndex < multilines.length; + multilineIndex++ + ) { + String line = multilines[multilineIndex]; + Utils.drawStringScaledMaxWidth( + line + EnumChatFormatting.RESET, + Minecraft.getMinecraft().fontRendererObj, + dragOffsetX + mouseX + 10, + dragOffsetY + mouseY + multilineIndex * 10, + true, + width - 20, + 0xffffff | (opacity << 24) + ); } - dropdownY += 12; - } + int ySize = multilines.length * 10; + + Minecraft + .getMinecraft() + .fontRendererObj.drawString( + "\u2261", + dragOffsetX + mouseX, + dragOffsetY + mouseY + ySize / 2f - 4, + 0xffffff, + true + ); } + } - dropdownOpen = false; - return true; - } - - if ( - activeText.size() < exampleText.length && - mouseX > x + width / 6 - 24 && - mouseX < x + width / 6 + 24 && - mouseY > y + 45 - 7 - 14 && - mouseY < y + 45 - 7 + 2 - ) { - dropdownOpen = !dropdownOpen; - dragOffsetX = mouseX; - dragOffsetY = mouseY; - return true; - } - - if ( - Mouse.getEventButton() == 0 && - mouseX > x + 5 && - mouseX < x + width - 5 && - mouseY > y + 45 && - mouseY < y + height - 6 - ) { - int yOff = 0; - int i = 0; - for (int strIndex : activeText) { - int ySize = 10 * exampleText[strIndex].split("\n").length; - if (mouseY < y + 50 + yOff + ySize) { - dragOffsetX = x + 10 - mouseX; - dragOffsetY = y + 50 + yOff - mouseY; - - currentDragging = strIndex; - dragStartIndex = i; - break; - } - yOff += ySize; - i++; + @Override + public boolean mouseInput(int x, int y, int width, int mouseX, int mouseY) { + if ( + !Mouse.getEventButtonState() && + !dropdownOpen && + dragStartIndex >= 0 && + Mouse.getEventButton() == 0 && + mouseX >= x + width / 6 + 27 - 3 && + mouseX <= x + width / 6 + 27 + 11 + 3 && + mouseY >= y + 45 - 7 - 13 - 3 && + mouseY <= y + 45 - 7 - 13 + 14 + 3 + ) { + activeText.remove(dragStartIndex); + currentDragging = -1; + dragStartIndex = -1; + return false; } - } - } else if (Mouse.getEventButton() == -1 && currentDragging >= 0) { - int yOff = 0; - int i = 0; - for (int strIndex : activeText) { - if (dragOffsetY + mouseY + 4 < y + 50 + yOff + 10) { - activeText.remove(dragStartIndex); - activeText.add(i, currentDragging); - - dragStartIndex = i; - break; + + if (!Mouse.isButtonDown(0) || dropdownOpen) { + currentDragging = -1; + dragStartIndex = -1; + if (trashHoverTime > 0) trashHoverTime = + -System.currentTimeMillis(); + } else if ( + currentDragging >= 0 && + mouseX >= x + width / 6 + 27 - 3 && + mouseX <= x + width / 6 + 27 + 11 + 3 && + mouseY >= y + 45 - 7 - 13 - 3 && + mouseY <= y + 45 - 7 - 13 + 14 + 3 + ) { + if (trashHoverTime < 0) trashHoverTime = System.currentTimeMillis(); + } else { + if (trashHoverTime > 0) trashHoverTime = + -System.currentTimeMillis(); } - yOff += 10 * exampleText[strIndex].split("\n").length; - i++; - } - } - return false; - } + if (Mouse.getEventButtonState()) { + int height = getHeight(); + + if (dropdownOpen) { + List remaining = new ArrayList<>(); + for (int i = 0; i < exampleText.length; i++) { + remaining.add(i); + } + remaining.removeAll(activeText); + + int dropdownWidth = Math.min(width / 2 - 10, 150); + int left = dragOffsetX; + int top = dragOffsetY; + + int dropdownHeight = -1 + 12 * remaining.size(); + + if ( + mouseX > left && + mouseX < left + dropdownWidth && + mouseY > top && + mouseY < top + dropdownHeight + ) { + int dropdownY = -1; + for (int strIndex : remaining) { + if (mouseY < top + dropdownY + 12) { + activeText.add(0, strIndex); + if (remaining.size() == 1) dropdownOpen = false; + return true; + } + + dropdownY += 12; + } + } + + dropdownOpen = false; + return true; + } - @Override - public boolean keyboardInput() { - return false; - } + if ( + activeText.size() < exampleText.length && + mouseX > x + width / 6 - 24 && + mouseX < x + width / 6 + 24 && + mouseY > y + 45 - 7 - 14 && + mouseY < y + 45 - 7 + 2 + ) { + dropdownOpen = !dropdownOpen; + dragOffsetX = mouseX; + dragOffsetY = mouseY; + return true; + } + + if ( + Mouse.getEventButton() == 0 && + mouseX > x + 5 && + mouseX < x + width - 5 && + mouseY > y + 45 && + mouseY < y + height - 6 + ) { + int yOff = 0; + int i = 0; + for (int strIndex : activeText) { + int ySize = 10 * exampleText[strIndex].split("\n").length; + if (mouseY < y + 50 + yOff + ySize) { + dragOffsetX = x + 10 - mouseX; + dragOffsetY = y + 50 + yOff - mouseY; + + currentDragging = strIndex; + dragStartIndex = i; + break; + } + yOff += ySize; + i++; + } + } + } else if (Mouse.getEventButton() == -1 && currentDragging >= 0) { + int yOff = 0; + int i = 0; + for (int strIndex : activeText) { + if (dragOffsetY + mouseY + 4 < y + 50 + yOff + 10) { + activeText.remove(dragStartIndex); + activeText.add(i, currentDragging); + + dragStartIndex = i; + break; + } + yOff += 10 * exampleText[strIndex].split("\n").length; + i++; + } + } + + return false; + } + + @Override + public boolean keyboardInput() { + return false; + } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorDropdown.java b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorDropdown.java index 41c0acd..8aa5c08 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorDropdown.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorDropdown.java @@ -12,227 +12,233 @@ import org.lwjgl.opengl.GL11; public class GuiOptionEditorDropdown extends GuiOptionEditor { - private final String[] values; - private final boolean useOrdinal; - private int selected; - private boolean open = false; - - public GuiOptionEditorDropdown( - ConfigProcessor.ProcessedOption option, - String[] values, - int selected, - boolean useOrdinal - ) { - super(option); - if (selected >= values.length) selected = values.length; - this.values = values; - this.selected = selected; - this.useOrdinal = useOrdinal; - } - - @Override - public void render(int x, int y, int width) { - super.render(x, y, width); - - if (!open) { - int height = getHeight(); - - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - int dropdownWidth = Math.min(width / 3 - 10, 80); - int left = x + width / 6 - dropdownWidth / 2; - int top = y + height - 7 - 14; - - String selectedString = " - Select - "; - if (selected >= 0 && selected < values.length) { - selectedString = values[selected]; - } - - RenderUtils.drawFloatingRectDark(left, top, dropdownWidth, 14, false); - TextRenderUtils.drawStringScaled( - "\u25BC", - fr, - left + dropdownWidth - 10, - y + height - 7 - 15, - false, - 0xffa0a0a0, - 2 - ); - - TextRenderUtils.drawStringScaledMaxWidth( - selectedString, - fr, - left + 3, - top + 3, - false, - dropdownWidth - 16, - 0xffa0a0a0 - ); + private final String[] values; + private final boolean useOrdinal; + private int selected; + private boolean open = false; + + public GuiOptionEditorDropdown( + ConfigProcessor.ProcessedOption option, + String[] values, + int selected, + boolean useOrdinal + ) { + super(option); + if (selected >= values.length) selected = values.length; + this.values = values; + this.selected = selected; + this.useOrdinal = useOrdinal; } - } - - @Override - public void renderOverlay(int x, int y, int width) { - if (open) { - String selectedString = " - Select - "; - if (selected >= 0 && selected < values.length) { - selectedString = values[selected]; - } - - int height = getHeight(); - - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - int dropdownWidth = Math.min(width / 3 - 10, 80); - int left = x + width / 6 - dropdownWidth / 2; - int top = y + height - 7 - 14; - - int dropdownHeight = 13 + 12 * values.length; - - int main = 0xff202026; - int blue = 0xff2355ad; - Gui.drawRect(left, top, left + 1, top + dropdownHeight, blue); //Left - Gui.drawRect(left + 1, top, left + dropdownWidth, top + 1, blue); //Top - Gui.drawRect( - left + dropdownWidth - 1, - top + 1, - left + dropdownWidth, - top + dropdownHeight, - blue - ); //Right - Gui.drawRect( - left + 1, - top + dropdownHeight - 1, - left + dropdownWidth - 1, - top + dropdownHeight, - blue - ); //Bottom - Gui.drawRect( - left + 1, - top + 1, - left + dropdownWidth - 1, - top + dropdownHeight - 1, - main - ); //Middle - - Gui.drawRect( - left + 1, - top + 14 - 1, - left + dropdownWidth - 1, - top + 14, - blue - ); //Bar - - int dropdownY = 13; - for (String option : values) { - if (option.isEmpty()) { - option = ""; + + @Override + public void render(int x, int y, int width) { + super.render(x, y, width); + + if (!open) { + int height = getHeight(); + + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + int dropdownWidth = Math.min(width / 3 - 10, 80); + int left = x + width / 6 - dropdownWidth / 2; + int top = y + height - 7 - 14; + + String selectedString = " - Select - "; + if (selected >= 0 && selected < values.length) { + selectedString = values[selected]; + } + + RenderUtils.drawFloatingRectDark( + left, + top, + dropdownWidth, + 14, + false + ); + TextRenderUtils.drawStringScaled( + "\u25BC", + fr, + left + dropdownWidth - 10, + y + height - 7 - 15, + false, + 0xffa0a0a0, + 2 + ); + + TextRenderUtils.drawStringScaledMaxWidth( + selectedString, + fr, + left + 3, + top + 3, + false, + dropdownWidth - 16, + 0xffa0a0a0 + ); } - TextRenderUtils.drawStringScaledMaxWidth( - option, - fr, - left + 3, - top + 3 + dropdownY, - false, - dropdownWidth - 6, - 0xffa0a0a0 - ); - dropdownY += 12; - } - - TextRenderUtils.drawStringScaled( - "\u25B2", - fr, - left + dropdownWidth - 10, - y + height - 7 - 15, - false, - 0xffa0a0a0, - 2 - ); - - TextRenderUtils.drawStringScaledMaxWidth( - selectedString, - fr, - left + 3, - top + 3, - false, - dropdownWidth - 16, - 0xffa0a0a0 - ); } - } - - @Override - public boolean mouseInput(int x, int y, int width, int mouseX, int mouseY) { - int height = getHeight(); - - int left = x + width / 6 - 40; - int top = y + height - 7 - 14; - - if (Mouse.getEventButtonState() && Mouse.getEventButton() == 0) { - if ( - mouseX >= left && - mouseX <= left + 80 && - mouseY >= top && - mouseY <= top + 14 - ) { - open = !open; - return true; - } + + @Override + public void renderOverlay(int x, int y, int width) { + if (open) { + String selectedString = " - Select - "; + if (selected >= 0 && selected < values.length) { + selectedString = values[selected]; + } + + int height = getHeight(); + + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + int dropdownWidth = Math.min(width / 3 - 10, 80); + int left = x + width / 6 - dropdownWidth / 2; + int top = y + height - 7 - 14; + + int dropdownHeight = 13 + 12 * values.length; + + int main = 0xff202026; + int blue = 0xff2355ad; + Gui.drawRect(left, top, left + 1, top + dropdownHeight, blue); //Left + Gui.drawRect(left + 1, top, left + dropdownWidth, top + 1, blue); //Top + Gui.drawRect( + left + dropdownWidth - 1, + top + 1, + left + dropdownWidth, + top + dropdownHeight, + blue + ); //Right + Gui.drawRect( + left + 1, + top + dropdownHeight - 1, + left + dropdownWidth - 1, + top + dropdownHeight, + blue + ); //Bottom + Gui.drawRect( + left + 1, + top + 1, + left + dropdownWidth - 1, + top + dropdownHeight - 1, + main + ); //Middle + + Gui.drawRect( + left + 1, + top + 14 - 1, + left + dropdownWidth - 1, + top + 14, + blue + ); //Bar + + int dropdownY = 13; + for (String option : values) { + if (option.isEmpty()) { + option = ""; + } + TextRenderUtils.drawStringScaledMaxWidth( + option, + fr, + left + 3, + top + 3 + dropdownY, + false, + dropdownWidth - 6, + 0xffa0a0a0 + ); + dropdownY += 12; + } + + TextRenderUtils.drawStringScaled( + "\u25B2", + fr, + left + dropdownWidth - 10, + y + height - 7 - 15, + false, + 0xffa0a0a0, + 2 + ); + + TextRenderUtils.drawStringScaledMaxWidth( + selectedString, + fr, + left + 3, + top + 3, + false, + dropdownWidth - 16, + 0xffa0a0a0 + ); + } } - return false; - } - - @Override - public boolean mouseInputOverlay( - int x, - int y, - int width, - int mouseX, - int mouseY - ) { - int height = getHeight(); - - int left = x + width / 6 - 40; - int top = y + height - 7 - 14; - - if (Mouse.getEventButtonState() && Mouse.getEventButton() == 0) { - if ( - !( - mouseX >= left && - mouseX <= left + 80 && - mouseY >= top && - mouseY <= top + 14 - ) && - open - ) { - open = false; - if (mouseX >= left && mouseX <= left + 80) { - int dropdownY = 13; - for (int ordinal = 0; ordinal < values.length; ordinal++) { + @Override + public boolean mouseInput(int x, int y, int width, int mouseX, int mouseY) { + int height = getHeight(); + + int left = x + width / 6 - 40; + int top = y + height - 7 - 14; + + if (Mouse.getEventButtonState() && Mouse.getEventButton() == 0) { if ( - mouseY >= top + 3 + dropdownY && - mouseY <= top + 3 + dropdownY + 12 + mouseX >= left && + mouseX <= left + 80 && + mouseY >= top && + mouseY <= top + 14 ) { - selected = ordinal; - if (useOrdinal) { - option.set(selected); - } else { - option.set(values[selected]); - } - return true; + open = !open; + return true; } - dropdownY += 12; - } } - return true; - } + + return false; } - return false; - } + @Override + public boolean mouseInputOverlay( + int x, + int y, + int width, + int mouseX, + int mouseY + ) { + int height = getHeight(); + + int left = x + width / 6 - 40; + int top = y + height - 7 - 14; + + if (Mouse.getEventButtonState() && Mouse.getEventButton() == 0) { + if ( + !( + mouseX >= left && + mouseX <= left + 80 && + mouseY >= top && + mouseY <= top + 14 + ) && + open + ) { + open = false; + if (mouseX >= left && mouseX <= left + 80) { + int dropdownY = 13; + for (int ordinal = 0; ordinal < values.length; ordinal++) { + if ( + mouseY >= top + 3 + dropdownY && + mouseY <= top + 3 + dropdownY + 12 + ) { + selected = ordinal; + if (useOrdinal) { + option.set(selected); + } else { + option.set(values[selected]); + } + return true; + } + dropdownY += 12; + } + } + return true; + } + } + + return false; + } - @Override - public boolean keyboardInput() { - return false; - } + @Override + public boolean keyboardInput() { + return false; + } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorSlider.java b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorSlider.java index b9ad389..dd981d8 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorSlider.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorSlider.java @@ -10,166 +10,170 @@ import org.lwjgl.input.Mouse; public class GuiOptionEditorSlider extends GuiOptionEditor { - private final GuiElementSlider slider; - private final GuiElementTextField textField; - - public GuiOptionEditorSlider( - ConfigProcessor.ProcessedOption option, - float minValue, - float maxValue, - float minStep - ) { - super(option); - if (minStep < 0) minStep = 0.01f; - - float floatVal = ((Number) option.get()).floatValue(); - { - String strVal; - if (floatVal % 1 == 0) { - strVal = Integer.toString((int) floatVal); - } else { - strVal = Float.toString(floatVal); - } - textField = - new GuiElementTextField( - strVal, - GuiElementTextField.NO_SPACE | - GuiElementTextField.NUM_ONLY | - GuiElementTextField.SCALE_TEXT - ); + private final GuiElementSlider slider; + private final GuiElementTextField textField; + + public GuiOptionEditorSlider( + ConfigProcessor.ProcessedOption option, + float minValue, + float maxValue, + float minStep + ) { + super(option); + if (minStep < 0) minStep = 0.01f; + + float floatVal = ((Number) option.get()).floatValue(); + { + String strVal; + if (floatVal % 1 == 0) { + strVal = Integer.toString((int) floatVal); + } else { + strVal = Float.toString(floatVal); + } + textField = + new GuiElementTextField( + strVal, + GuiElementTextField.NO_SPACE | + GuiElementTextField.NUM_ONLY | + GuiElementTextField.SCALE_TEXT + ); + } + + slider = + new GuiElementSlider( + 0, + 0, + 80, + minValue, + maxValue, + minStep, + floatVal, + val -> { + option.set(val); + + String strVal; + if (val % 1 == 0) { + strVal = Integer.toString(val.intValue()); + } else { + strVal = Float.toString(val); + strVal = + strVal.replaceAll("(\\.\\d\\d\\d)(?:\\d)+", "$1"); + strVal = strVal.replaceAll("0+$", ""); + } + textField.setText(strVal); + } + ); } - slider = - new GuiElementSlider( - 0, - 0, - 80, - minValue, - maxValue, - minStep, - floatVal, - val -> { - option.set(val); - - String strVal; - if (val % 1 == 0) { - strVal = Integer.toString(val.intValue()); - } else { - strVal = Float.toString(val); - strVal = strVal.replaceAll("(\\.\\d\\d\\d)(?:\\d)+", "$1"); - strVal = strVal.replaceAll("0+$", ""); - } - textField.setText(strVal); + @Override + public void render(int x, int y, int width) { + super.render(x, y, width); + int height = getHeight(); + + int fullWidth = Math.min(width / 3 - 10, 80); + int sliderWidth = (fullWidth - 5) * 3 / 4; + int textFieldWidth = (fullWidth - 5) / 4; + + slider.x = x + width / 6 - fullWidth / 2; + slider.y = y + height - 7 - 14; + slider.width = sliderWidth; + slider.render(); + + if (textField.getFocus()) { + textField.setOptions( + GuiElementTextField.NO_SPACE | GuiElementTextField.NUM_ONLY + ); + textField.setSize( + Minecraft + .getMinecraft() + .fontRendererObj.getStringWidth(textField.getText()) + + 10, + 16 + ); + } else { + textField.setSize(textFieldWidth, 16); + textField.setOptions( + GuiElementTextField.NO_SPACE | + GuiElementTextField.NUM_ONLY | + GuiElementTextField.SCALE_TEXT + ); } - ); - } - - @Override - public void render(int x, int y, int width) { - super.render(x, y, width); - int height = getHeight(); - - int fullWidth = Math.min(width / 3 - 10, 80); - int sliderWidth = (fullWidth - 5) * 3 / 4; - int textFieldWidth = (fullWidth - 5) / 4; - - slider.x = x + width / 6 - fullWidth / 2; - slider.y = y + height - 7 - 14; - slider.width = sliderWidth; - slider.render(); - - if (textField.getFocus()) { - textField.setOptions( - GuiElementTextField.NO_SPACE | GuiElementTextField.NUM_ONLY - ); - textField.setSize( - Minecraft - .getMinecraft() - .fontRendererObj.getStringWidth(textField.getText()) + - 10, - 16 - ); - } else { - textField.setSize(textFieldWidth, 16); - textField.setOptions( - GuiElementTextField.NO_SPACE | - GuiElementTextField.NUM_ONLY | - GuiElementTextField.SCALE_TEXT - ); - } - textField.render( - x + width / 6 - fullWidth / 2 + sliderWidth + 5, - y + height - 7 - 14 - ); - } - - @Override - public boolean mouseInput(int x, int y, int width, int mouseX, int mouseY) { - int height = getHeight(); - - int fullWidth = Math.min(width / 3 - 10, 80); - int sliderWidth = (fullWidth - 5) * 3 / 4; - int textFieldWidth = (fullWidth - 5) / 4; - - slider.x = x + width / 6 - fullWidth / 2; - slider.y = y + height - 7 - 14; - slider.width = sliderWidth; - if (slider.mouseInput(mouseX, mouseY)) { - textField.unfocus(); - return true; + textField.render( + x + width / 6 - fullWidth / 2 + sliderWidth + 5, + y + height - 7 - 14 + ); } - if (textField.getFocus()) { - textFieldWidth = - Minecraft - .getMinecraft() - .fontRendererObj.getStringWidth(textField.getText()) + - 10; - } + @Override + public boolean mouseInput(int x, int y, int width, int mouseX, int mouseY) { + int height = getHeight(); - int textFieldX = x + width / 6 - fullWidth / 2 + sliderWidth + 5; - int textFieldY = y + height - 7 - 14; - textField.setSize(textFieldWidth, 16); + int fullWidth = Math.min(width / 3 - 10, 80); + int sliderWidth = (fullWidth - 5) * 3 / 4; + int textFieldWidth = (fullWidth - 5) / 4; - if ( - Mouse.getEventButtonState() && - (Mouse.getEventButton() == 0 || Mouse.getEventButton() == 1) - ) { - if ( - mouseX > textFieldX && - mouseX < textFieldX + textFieldWidth && - mouseY > textFieldY && - mouseY < textFieldY + 16 - ) { - textField.mouseClicked(mouseX, mouseY, Mouse.getEventButton()); - return true; - } - textField.unfocus(); - } - - return false; - } + slider.x = x + width / 6 - fullWidth / 2; + slider.y = y + height - 7 - 14; + slider.width = sliderWidth; + if (slider.mouseInput(mouseX, mouseY)) { + textField.unfocus(); + return true; + } - @Override - public boolean keyboardInput() { - if (Keyboard.getEventKeyState() && textField.getFocus()) { - textField.keyTyped(Keyboard.getEventCharacter(), Keyboard.getEventKey()); + if (textField.getFocus()) { + textFieldWidth = + Minecraft + .getMinecraft() + .fontRendererObj.getStringWidth(textField.getText()) + + 10; + } - try { - textField.setCustomBorderColour(0xffffffff); - float f = Float.parseFloat(textField.getText()); - if (option.set(f)) { - slider.setValue(f); - } else { - textField.setCustomBorderColour(0xff0000ff); + int textFieldX = x + width / 6 - fullWidth / 2 + sliderWidth + 5; + int textFieldY = y + height - 7 - 14; + textField.setSize(textFieldWidth, 16); + + if ( + Mouse.getEventButtonState() && + (Mouse.getEventButton() == 0 || Mouse.getEventButton() == 1) + ) { + if ( + mouseX > textFieldX && + mouseX < textFieldX + textFieldWidth && + mouseY > textFieldY && + mouseY < textFieldY + 16 + ) { + textField.mouseClicked(mouseX, mouseY, Mouse.getEventButton()); + return true; + } + textField.unfocus(); } - } catch (Exception e) { - textField.setCustomBorderColour(0xffff0000); - } - return true; + return false; + } + + @Override + public boolean keyboardInput() { + if (Keyboard.getEventKeyState() && textField.getFocus()) { + textField.keyTyped( + Keyboard.getEventCharacter(), + Keyboard.getEventKey() + ); + + try { + textField.setCustomBorderColour(0xffffffff); + float f = Float.parseFloat(textField.getText()); + if (option.set(f)) { + slider.setValue(f); + } else { + textField.setCustomBorderColour(0xff0000ff); + } + } catch (Exception e) { + textField.setCustomBorderColour(0xffff0000); + } + + return true; + } + return false; } - return false; - } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorText.java b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorText.java index 701bf00..3e712f2 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorText.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorText.java @@ -10,93 +10,96 @@ import org.lwjgl.input.Mouse; public class GuiOptionEditorText extends GuiOptionEditor { - private final GuiElementTextField textField; - - public GuiOptionEditorText(ConfigProcessor.ProcessedOption option) { - super(option); - textField = new GuiElementTextField((String) option.get(), 0); - } - - @Override - public void render(int x, int y, int width) { - super.render(x, y, width); - int height = getHeight(); - - int fullWidth = Math.min(width / 3 - 10, 80); - - int textFieldX = x + width / 6 - fullWidth / 2; - if (textField.getFocus()) { - fullWidth = - Math.max( - fullWidth, - Minecraft - .getMinecraft() - .fontRendererObj.getStringWidth(textField.getText()) + - 10 - ); - } + private final GuiElementTextField textField; - textField.setSize(fullWidth, 16); + public GuiOptionEditorText(ConfigProcessor.ProcessedOption option) { + super(option); + textField = new GuiElementTextField((String) option.get(), 0); + } - textField.render(textFieldX, y + height - 7 - 14); - } + @Override + public void render(int x, int y, int width) { + super.render(x, y, width); + int height = getHeight(); - @Override - public boolean mouseInput(int x, int y, int width, int mouseX, int mouseY) { - int height = getHeight(); + int fullWidth = Math.min(width / 3 - 10, 80); - int fullWidth = Math.min(width / 3 - 10, 80); + int textFieldX = x + width / 6 - fullWidth / 2; + if (textField.getFocus()) { + fullWidth = + Math.max( + fullWidth, + Minecraft + .getMinecraft() + .fontRendererObj.getStringWidth(textField.getText()) + + 10 + ); + } - int textFieldX = x + width / 6 - fullWidth / 2; + textField.setSize(fullWidth, 16); - if (textField.getFocus()) { - fullWidth = - Math.max( - fullWidth, - Minecraft - .getMinecraft() - .fontRendererObj.getStringWidth(textField.getText()) + - 10 - ); + textField.render(textFieldX, y + height - 7 - 14); } - int textFieldY = y + height - 7 - 14; - textField.setSize(fullWidth, 16); - - if ( - Mouse.getEventButtonState() && - (Mouse.getEventButton() == 0 || Mouse.getEventButton() == 1) - ) { - if ( - mouseX > textFieldX && - mouseX < textFieldX + fullWidth && - mouseY > textFieldY && - mouseY < textFieldY + 16 - ) { - textField.mouseClicked(mouseX, mouseY, Mouse.getEventButton()); - return true; - } - textField.unfocus(); + @Override + public boolean mouseInput(int x, int y, int width, int mouseX, int mouseY) { + int height = getHeight(); + + int fullWidth = Math.min(width / 3 - 10, 80); + + int textFieldX = x + width / 6 - fullWidth / 2; + + if (textField.getFocus()) { + fullWidth = + Math.max( + fullWidth, + Minecraft + .getMinecraft() + .fontRendererObj.getStringWidth(textField.getText()) + + 10 + ); + } + + int textFieldY = y + height - 7 - 14; + textField.setSize(fullWidth, 16); + + if ( + Mouse.getEventButtonState() && + (Mouse.getEventButton() == 0 || Mouse.getEventButton() == 1) + ) { + if ( + mouseX > textFieldX && + mouseX < textFieldX + fullWidth && + mouseY > textFieldY && + mouseY < textFieldY + 16 + ) { + textField.mouseClicked(mouseX, mouseY, Mouse.getEventButton()); + return true; + } + textField.unfocus(); + } + + return false; } - return false; - } - - @Override - public boolean keyboardInput() { - if (Keyboard.getEventKeyState() && textField.getFocus()) { - Keyboard.enableRepeatEvents(true); - textField.keyTyped(Keyboard.getEventCharacter(), Keyboard.getEventKey()); - - try { - textField.setCustomBorderColour(0xffffffff); - option.set(textField.getText()); - } catch (Exception e) { - textField.setCustomBorderColour(0xffff0000); - } - - return true; + @Override + public boolean keyboardInput() { + if (Keyboard.getEventKeyState() && textField.getFocus()) { + Keyboard.enableRepeatEvents(true); + textField.keyTyped( + Keyboard.getEventCharacter(), + Keyboard.getEventKey() + ); + + try { + textField.setCustomBorderColour(0xffffffff); + option.set(textField.getText()); + } catch (Exception e) { + textField.setCustomBorderColour(0xffff0000); + } + + return true; + } + return false; } - return false; - } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiPositionEditor.java b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiPositionEditor.java index e85f5c4..eaa399e 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiPositionEditor.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiPositionEditor.java @@ -13,234 +13,254 @@ import org.lwjgl.input.Mouse; public class GuiPositionEditor extends GuiScreen { - private final Position position; - private Position originalPosition; - private final int elementWidth; - private final int elementHeight; - private final Runnable renderCallback; - private final Runnable positionChangedCallback; - private final Runnable closedCallback; - private boolean clicked = false; - private int grabbedX = 0; - private int grabbedY = 0; - - private int guiScaleOverride = -1; - - public GuiPositionEditor( - Position position, - int elementWidth, - int elementHeight, - Runnable renderCallback, - Runnable positionChangedCallback, - Runnable closedCallback - ) { - this.position = position; - this.originalPosition = position.clone(); - this.elementWidth = elementWidth == -1 ? this.width : elementWidth; - this.elementHeight = elementHeight; - this.renderCallback = renderCallback; - this.positionChangedCallback = positionChangedCallback; - this.closedCallback = closedCallback; - } - - public GuiPositionEditor withScale(int scale) { - this.guiScaleOverride = scale; - return this; - } - - @Override - public void onGuiClosed() { - super.onGuiClosed(); - closedCallback.run(); - } - - @Override - public void drawScreen(int mouseX, int mouseY, float partialTicks) { - super.drawScreen(mouseX, mouseY, partialTicks); - ScaledResolution scaledResolution; - if (guiScaleOverride >= 0) { - scaledResolution = Utils.pushGuiScale(guiScaleOverride); - } else { - scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); + private final Position position; + private Position originalPosition; + private final int elementWidth; + private final int elementHeight; + private final Runnable renderCallback; + private final Runnable positionChangedCallback; + private final Runnable closedCallback; + private boolean clicked = false; + private int grabbedX = 0; + private int grabbedY = 0; + + private int guiScaleOverride = -1; + + public GuiPositionEditor( + Position position, + int elementWidth, + int elementHeight, + Runnable renderCallback, + Runnable positionChangedCallback, + Runnable closedCallback + ) { + this.position = position; + this.originalPosition = position.clone(); + this.elementWidth = elementWidth == -1 ? this.width : elementWidth; + this.elementHeight = elementHeight; + this.renderCallback = renderCallback; + this.positionChangedCallback = positionChangedCallback; + this.closedCallback = closedCallback; } - this.width = scaledResolution.getScaledWidth(); - this.height = scaledResolution.getScaledHeight(); - mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth; - mouseY = - height - - Mouse.getY() * - height / - Minecraft.getMinecraft().displayHeight - - 1; - - drawDefaultBackground(); - - if (clicked) { - grabbedX += - position.moveX(mouseX - grabbedX, elementWidth, scaledResolution); - grabbedY += - position.moveY(mouseY - grabbedY, elementHeight, scaledResolution); + public GuiPositionEditor withScale(int scale) { + this.guiScaleOverride = scale; + return this; } - renderCallback.run(); + @Override + public void onGuiClosed() { + super.onGuiClosed(); + closedCallback.run(); + } - int x = position.getAbsX(scaledResolution, elementWidth); - int y = position.getAbsY(scaledResolution, elementHeight); + @Override + public void drawScreen(int mouseX, int mouseY, float partialTicks) { + super.drawScreen(mouseX, mouseY, partialTicks); + ScaledResolution scaledResolution; + if (guiScaleOverride >= 0) { + scaledResolution = Utils.pushGuiScale(guiScaleOverride); + } else { + scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); + } - if (position.isCenterX()) x -= elementWidth / 2; - if (position.isCenterY()) y -= elementHeight / 2; - Gui.drawRect(x, y, x + elementWidth, y + elementHeight, 0x80404040); + this.width = scaledResolution.getScaledWidth(); + this.height = scaledResolution.getScaledHeight(); + mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth; + mouseY = + height - + Mouse.getY() * + height / + Minecraft.getMinecraft().displayHeight - + 1; - if (guiScaleOverride >= 0) { - Utils.pushGuiScale(-1); - } + drawDefaultBackground(); + + if (clicked) { + grabbedX += + position.moveX( + mouseX - grabbedX, + elementWidth, + scaledResolution + ); + grabbedY += + position.moveY( + mouseY - grabbedY, + elementHeight, + scaledResolution + ); + } + + renderCallback.run(); + + int x = position.getAbsX(scaledResolution, elementWidth); + int y = position.getAbsY(scaledResolution, elementHeight); + + if (position.isCenterX()) x -= elementWidth / 2; + if (position.isCenterY()) y -= elementHeight / 2; + Gui.drawRect(x, y, x + elementWidth, y + elementHeight, 0x80404040); + + if (guiScaleOverride >= 0) { + Utils.pushGuiScale(-1); + } - scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); - Utils.drawStringCentered( - "Position Editor", - Minecraft.getMinecraft().fontRendererObj, - scaledResolution.getScaledWidth() / 2f, - 8, - true, - 0xffffff - ); - Utils.drawStringCentered( - "R to Reset - Arrow keys/mouse to move", - Minecraft.getMinecraft().fontRendererObj, - scaledResolution.getScaledWidth() / 2f, - 18, - true, - 0xffffff - ); - } - - @Override - protected void mouseClicked(int mouseX, int mouseY, int mouseButton) - throws IOException { - super.mouseClicked(mouseX, mouseY, mouseButton); - - if (mouseButton == 0) { - ScaledResolution scaledResolution; - if (guiScaleOverride >= 0) { - scaledResolution = Utils.pushGuiScale(guiScaleOverride); - } else { scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); - } - mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth; - mouseY = - height - - Mouse.getY() * - height / - Minecraft.getMinecraft().displayHeight - - 1; - - int x = position.getAbsX(scaledResolution, elementWidth); - int y = position.getAbsY(scaledResolution, elementHeight); - if (position.isCenterX()) x -= elementWidth / 2; - if (position.isCenterY()) y -= elementHeight / 2; - - if ( - mouseX >= x && - mouseY >= y && - mouseX <= x + elementWidth && - mouseY <= y + elementHeight - ) { - clicked = true; - grabbedX = mouseX; - grabbedY = mouseY; - } - - if (guiScaleOverride >= 0) { - Utils.pushGuiScale(-1); - } - } - } - - @Override - protected void keyTyped(char typedChar, int keyCode) throws IOException { - Keyboard.enableRepeatEvents(true); - - if (keyCode == Keyboard.KEY_R) { - position.set(originalPosition); - } else if (!clicked) { - boolean shiftHeld = - Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || - Keyboard.isKeyDown(Keyboard.KEY_RSHIFT); - int dist = shiftHeld ? 10 : 1; - if (keyCode == Keyboard.KEY_DOWN) { - position.moveY( - dist, - elementHeight, - new ScaledResolution(Minecraft.getMinecraft()) - ); - } else if (keyCode == Keyboard.KEY_UP) { - position.moveY( - -dist, - elementHeight, - new ScaledResolution(Minecraft.getMinecraft()) - ); - } else if (keyCode == Keyboard.KEY_LEFT) { - position.moveX( - -dist, - elementWidth, - new ScaledResolution(Minecraft.getMinecraft()) + Utils.drawStringCentered( + "Position Editor", + Minecraft.getMinecraft().fontRendererObj, + scaledResolution.getScaledWidth() / 2f, + 8, + true, + 0xffffff ); - } else if (keyCode == Keyboard.KEY_RIGHT) { - position.moveX( - dist, - elementWidth, - new ScaledResolution(Minecraft.getMinecraft()) + Utils.drawStringCentered( + "R to Reset - Arrow keys/mouse to move", + Minecraft.getMinecraft().fontRendererObj, + scaledResolution.getScaledWidth() / 2f, + 18, + true, + 0xffffff ); - } } - super.keyTyped(typedChar, keyCode); - } - - @Override - protected void mouseReleased(int mouseX, int mouseY, int state) { - super.mouseReleased(mouseX, mouseY, state); - clicked = false; - } - - @Override - protected void mouseClickMove( - int mouseX, - int mouseY, - int clickedMouseButton, - long timeSinceLastClick - ) { - super.mouseClickMove( - mouseX, - mouseY, - clickedMouseButton, - timeSinceLastClick - ); - - if (clicked) { - ScaledResolution scaledResolution; - if (guiScaleOverride >= 0) { - scaledResolution = Utils.pushGuiScale(guiScaleOverride); - } else { - scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); - } - mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth; - mouseY = - height - - Mouse.getY() * - height / - Minecraft.getMinecraft().displayHeight - - 1; - - grabbedX += - position.moveX(mouseX - grabbedX, elementWidth, scaledResolution); - grabbedY += - position.moveY(mouseY - grabbedY, elementHeight, scaledResolution); - positionChangedCallback.run(); - - if (guiScaleOverride >= 0) { - Utils.pushGuiScale(-1); - } + + @Override + protected void mouseClicked(int mouseX, int mouseY, int mouseButton) + throws IOException { + super.mouseClicked(mouseX, mouseY, mouseButton); + + if (mouseButton == 0) { + ScaledResolution scaledResolution; + if (guiScaleOverride >= 0) { + scaledResolution = Utils.pushGuiScale(guiScaleOverride); + } else { + scaledResolution = + new ScaledResolution(Minecraft.getMinecraft()); + } + mouseX = + Mouse.getX() * width / Minecraft.getMinecraft().displayWidth; + mouseY = + height - + Mouse.getY() * + height / + Minecraft.getMinecraft().displayHeight - + 1; + + int x = position.getAbsX(scaledResolution, elementWidth); + int y = position.getAbsY(scaledResolution, elementHeight); + if (position.isCenterX()) x -= elementWidth / 2; + if (position.isCenterY()) y -= elementHeight / 2; + + if ( + mouseX >= x && + mouseY >= y && + mouseX <= x + elementWidth && + mouseY <= y + elementHeight + ) { + clicked = true; + grabbedX = mouseX; + grabbedY = mouseY; + } + + if (guiScaleOverride >= 0) { + Utils.pushGuiScale(-1); + } + } + } + + @Override + protected void keyTyped(char typedChar, int keyCode) throws IOException { + Keyboard.enableRepeatEvents(true); + + if (keyCode == Keyboard.KEY_R) { + position.set(originalPosition); + } else if (!clicked) { + boolean shiftHeld = + Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || + Keyboard.isKeyDown(Keyboard.KEY_RSHIFT); + int dist = shiftHeld ? 10 : 1; + if (keyCode == Keyboard.KEY_DOWN) { + position.moveY( + dist, + elementHeight, + new ScaledResolution(Minecraft.getMinecraft()) + ); + } else if (keyCode == Keyboard.KEY_UP) { + position.moveY( + -dist, + elementHeight, + new ScaledResolution(Minecraft.getMinecraft()) + ); + } else if (keyCode == Keyboard.KEY_LEFT) { + position.moveX( + -dist, + elementWidth, + new ScaledResolution(Minecraft.getMinecraft()) + ); + } else if (keyCode == Keyboard.KEY_RIGHT) { + position.moveX( + dist, + elementWidth, + new ScaledResolution(Minecraft.getMinecraft()) + ); + } + } + super.keyTyped(typedChar, keyCode); + } + + @Override + protected void mouseReleased(int mouseX, int mouseY, int state) { + super.mouseReleased(mouseX, mouseY, state); + clicked = false; + } + + @Override + protected void mouseClickMove( + int mouseX, + int mouseY, + int clickedMouseButton, + long timeSinceLastClick + ) { + super.mouseClickMove( + mouseX, + mouseY, + clickedMouseButton, + timeSinceLastClick + ); + + if (clicked) { + ScaledResolution scaledResolution; + if (guiScaleOverride >= 0) { + scaledResolution = Utils.pushGuiScale(guiScaleOverride); + } else { + scaledResolution = + new ScaledResolution(Minecraft.getMinecraft()); + } + mouseX = + Mouse.getX() * width / Minecraft.getMinecraft().displayWidth; + mouseY = + height - + Mouse.getY() * + height / + Minecraft.getMinecraft().displayHeight - + 1; + + grabbedX += + position.moveX( + mouseX - grabbedX, + elementWidth, + scaledResolution + ); + grabbedY += + position.moveY( + mouseY - grabbedY, + elementHeight, + scaledResolution + ); + positionChangedCallback.run(); + + if (guiScaleOverride >= 0) { + Utils.pushGuiScale(-1); + } + } } - } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/config/struct/ConfigProcessor.java b/src/main/java/com/thatgravyboat/skyblockhud/core/config/struct/ConfigProcessor.java index df8d55a..559fa9e 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/config/struct/ConfigProcessor.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/config/struct/ConfigProcessor.java @@ -11,244 +11,284 @@ import java.util.List; public class ConfigProcessor { - public static class ProcessedCategory { + public static class ProcessedCategory { - public final String name; - public final String desc; - public final LinkedHashMap options = new LinkedHashMap<>(); + public final String name; + public final String desc; + public final LinkedHashMap options = new LinkedHashMap<>(); - public ProcessedCategory(String name, String desc) { - this.name = name; - this.desc = desc; + public ProcessedCategory(String name, String desc) { + this.name = name; + this.desc = desc; + } } - } - public static class ProcessedOption { + public static class ProcessedOption { - public final String name; - public final String desc; - public final int subcategoryId; - public GuiOptionEditor editor; + public final String name; + public final String desc; + public final int subcategoryId; + public GuiOptionEditor editor; - public int accordionId = -1; + public int accordionId = -1; - private final Field field; - private final Object container; + private final Field field; + private final Object container; - public ProcessedOption( - String name, - String desc, - int subcategoryId, - Field field, - Object container - ) { - this.name = name; - this.desc = desc; - this.subcategoryId = subcategoryId; + public ProcessedOption( + String name, + String desc, + int subcategoryId, + Field field, + Object container + ) { + this.name = name; + this.desc = desc; + this.subcategoryId = subcategoryId; - this.field = field; - this.container = container; - } + this.field = field; + this.container = container; + } - public Object get() { - try { - return field.get(container); - } catch (Exception e) { - return null; - } - } + public Object get() { + try { + return field.get(container); + } catch (Exception e) { + return null; + } + } - public boolean set(Object value) { - try { - if (field.getType() == int.class && value instanceof Number) { - field.set(container, ((Number) value).intValue()); - } else { - field.set(container, value); + public boolean set(Object value) { + try { + if (field.getType() == int.class && value instanceof Number) { + field.set(container, ((Number) value).intValue()); + } else { + field.set(container, value); + } + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } } - return true; - } catch (Exception e) { - e.printStackTrace(); - return false; - } } - } - - public static LinkedHashMap create(Config config) { - LinkedHashMap processedConfig = new LinkedHashMap<>(); - for (Field categoryField : config.getClass().getDeclaredFields()) { - boolean exposePresent = categoryField.isAnnotationPresent(Expose.class); - boolean categoryPresent = categoryField.isAnnotationPresent( - Category.class - ); - - if (exposePresent && categoryPresent) { - Object categoryObj; - try { - categoryObj = categoryField.get(config); - } catch (Exception e) { - //System.err.printf("Failed to load config category %s. Field was not accessible.\n", categoryField.getName()); - continue; - } - Category categoryAnnotation = categoryField.getAnnotation( - Category.class - ); - ProcessedCategory cat = new ProcessedCategory( - categoryAnnotation.name(), - categoryAnnotation.desc() - ); - processedConfig.put(categoryField.getName(), cat); - - for (Field optionField : categoryObj.getClass().getDeclaredFields()) { - boolean optionPresent = optionField.isAnnotationPresent( - ConfigOption.class - ); - - if (optionPresent) { - ConfigOption optionAnnotation = optionField.getAnnotation( - ConfigOption.class + public static LinkedHashMap create( + Config config + ) { + LinkedHashMap processedConfig = new LinkedHashMap<>(); + for (Field categoryField : config.getClass().getDeclaredFields()) { + boolean exposePresent = categoryField.isAnnotationPresent( + Expose.class ); - ProcessedOption option = new ProcessedOption( - optionAnnotation.name(), - optionAnnotation.desc(), - optionAnnotation.subcategoryId(), - optionField, - categoryObj + boolean categoryPresent = categoryField.isAnnotationPresent( + Category.class ); - if (optionField.isAnnotationPresent(ConfigAccordionId.class)) { - ConfigAccordionId annotation = optionField.getAnnotation( - ConfigAccordionId.class - ); - option.accordionId = annotation.id(); - } - GuiOptionEditor editor = null; - Class optionType = optionField.getType(); - if (optionField.isAnnotationPresent(ConfigEditorButton.class)) { - ConfigEditorButton configEditorAnnotation = optionField.getAnnotation( - ConfigEditorButton.class - ); - editor = - new GuiOptionEditorButton( - option, - configEditorAnnotation.runnableId(), - configEditorAnnotation.buttonText(), - config - ); - } - if ( - optionType.isAssignableFrom(boolean.class) && - optionField.isAnnotationPresent(ConfigEditorBoolean.class) - ) { - editor = new GuiOptionEditorBoolean(option); - } - if ( - optionType.isAssignableFrom(boolean.class) && - optionField.isAnnotationPresent(ConfigEditorAccordion.class) - ) { - ConfigEditorAccordion configEditorAnnotation = optionField.getAnnotation( - ConfigEditorAccordion.class - ); - editor = - new GuiOptionEditorAccordion( - option, - configEditorAnnotation.id() - ); - } - if (optionType.isAssignableFrom(int.class)) { - if (optionField.isAnnotationPresent(ConfigEditorDropdown.class)) { - ConfigEditorDropdown configEditorAnnotation = optionField.getAnnotation( - ConfigEditorDropdown.class - ); - editor = - new GuiOptionEditorDropdown( - option, - configEditorAnnotation.values(), - (int) option.get(), - true - ); - } - } - if (optionType.isAssignableFrom(List.class)) { - if ( - optionField.isAnnotationPresent(ConfigEditorDraggableList.class) - ) { - ConfigEditorDraggableList configEditorAnnotation = optionField.getAnnotation( - ConfigEditorDraggableList.class - ); - editor = - new GuiOptionEditorDraggableList( - option, - configEditorAnnotation.exampleText() - ); - } - } - if (optionType.isAssignableFrom(String.class)) { - if (optionField.isAnnotationPresent(ConfigEditorDropdown.class)) { - ConfigEditorDropdown configEditorAnnotation = optionField.getAnnotation( - ConfigEditorDropdown.class - ); - editor = - new GuiOptionEditorDropdown( - option, - configEditorAnnotation.values(), - configEditorAnnotation.initialIndex(), - false - ); - } else if ( - optionField.isAnnotationPresent(ConfigEditorColour.class) - ) { - editor = new GuiOptionEditorColour(option); - } else if ( - optionField.isAnnotationPresent(ConfigEditorText.class) - ) { - editor = new GuiOptionEditorText(option); - } - } - if ( - optionType.isAssignableFrom(int.class) || - optionType.isAssignableFrom(float.class) || - optionType.isAssignableFrom(double.class) - ) { - if (optionField.isAnnotationPresent(ConfigEditorSlider.class)) { - ConfigEditorSlider configEditorAnnotation = optionField.getAnnotation( - ConfigEditorSlider.class + if (exposePresent && categoryPresent) { + Object categoryObj; + try { + categoryObj = categoryField.get(config); + } catch (Exception e) { + //System.err.printf("Failed to load config category %s. Field was not accessible.\n", categoryField.getName()); + continue; + } + + Category categoryAnnotation = categoryField.getAnnotation( + Category.class ); - editor = - new GuiOptionEditorSlider( - option, - configEditorAnnotation.minValue(), - configEditorAnnotation.maxValue(), - configEditorAnnotation.minStep() - ); - } - } - if (optionType.isAssignableFrom(String.class)) { - if (optionField.isAnnotationPresent(ConfigEditorDropdown.class)) { - ConfigEditorDropdown configEditorAnnotation = optionField.getAnnotation( - ConfigEditorDropdown.class + ProcessedCategory cat = new ProcessedCategory( + categoryAnnotation.name(), + categoryAnnotation.desc() ); - editor = - new GuiOptionEditorDropdown( - option, - configEditorAnnotation.values(), - 0, - false - ); - } - } - if (editor == null) { - //System.err.printf("Failed to load config option %s. Could not find suitable editor.\n", optionField.getName()); - continue; + processedConfig.put(categoryField.getName(), cat); + + for (Field optionField : categoryObj + .getClass() + .getDeclaredFields()) { + boolean optionPresent = optionField.isAnnotationPresent( + ConfigOption.class + ); + + if (optionPresent) { + ConfigOption optionAnnotation = optionField.getAnnotation( + ConfigOption.class + ); + ProcessedOption option = new ProcessedOption( + optionAnnotation.name(), + optionAnnotation.desc(), + optionAnnotation.subcategoryId(), + optionField, + categoryObj + ); + if ( + optionField.isAnnotationPresent( + ConfigAccordionId.class + ) + ) { + ConfigAccordionId annotation = optionField.getAnnotation( + ConfigAccordionId.class + ); + option.accordionId = annotation.id(); + } + + GuiOptionEditor editor = null; + Class optionType = optionField.getType(); + if ( + optionField.isAnnotationPresent( + ConfigEditorButton.class + ) + ) { + ConfigEditorButton configEditorAnnotation = optionField.getAnnotation( + ConfigEditorButton.class + ); + editor = + new GuiOptionEditorButton( + option, + configEditorAnnotation.runnableId(), + configEditorAnnotation.buttonText(), + config + ); + } + if ( + optionType.isAssignableFrom(boolean.class) && + optionField.isAnnotationPresent( + ConfigEditorBoolean.class + ) + ) { + editor = new GuiOptionEditorBoolean(option); + } + if ( + optionType.isAssignableFrom(boolean.class) && + optionField.isAnnotationPresent( + ConfigEditorAccordion.class + ) + ) { + ConfigEditorAccordion configEditorAnnotation = optionField.getAnnotation( + ConfigEditorAccordion.class + ); + editor = + new GuiOptionEditorAccordion( + option, + configEditorAnnotation.id() + ); + } + if (optionType.isAssignableFrom(int.class)) { + if ( + optionField.isAnnotationPresent( + ConfigEditorDropdown.class + ) + ) { + ConfigEditorDropdown configEditorAnnotation = optionField.getAnnotation( + ConfigEditorDropdown.class + ); + editor = + new GuiOptionEditorDropdown( + option, + configEditorAnnotation.values(), + (int) option.get(), + true + ); + } + } + if (optionType.isAssignableFrom(List.class)) { + if ( + optionField.isAnnotationPresent( + ConfigEditorDraggableList.class + ) + ) { + ConfigEditorDraggableList configEditorAnnotation = optionField.getAnnotation( + ConfigEditorDraggableList.class + ); + editor = + new GuiOptionEditorDraggableList( + option, + configEditorAnnotation.exampleText() + ); + } + } + if (optionType.isAssignableFrom(String.class)) { + if ( + optionField.isAnnotationPresent( + ConfigEditorDropdown.class + ) + ) { + ConfigEditorDropdown configEditorAnnotation = optionField.getAnnotation( + ConfigEditorDropdown.class + ); + editor = + new GuiOptionEditorDropdown( + option, + configEditorAnnotation.values(), + configEditorAnnotation.initialIndex(), + false + ); + } else if ( + optionField.isAnnotationPresent( + ConfigEditorColour.class + ) + ) { + editor = new GuiOptionEditorColour(option); + } else if ( + optionField.isAnnotationPresent( + ConfigEditorText.class + ) + ) { + editor = new GuiOptionEditorText(option); + } + } + if ( + optionType.isAssignableFrom(int.class) || + optionType.isAssignableFrom(float.class) || + optionType.isAssignableFrom(double.class) + ) { + if ( + optionField.isAnnotationPresent( + ConfigEditorSlider.class + ) + ) { + ConfigEditorSlider configEditorAnnotation = optionField.getAnnotation( + ConfigEditorSlider.class + ); + editor = + new GuiOptionEditorSlider( + option, + configEditorAnnotation.minValue(), + configEditorAnnotation.maxValue(), + configEditorAnnotation.minStep() + ); + } + } + if (optionType.isAssignableFrom(String.class)) { + if ( + optionField.isAnnotationPresent( + ConfigEditorDropdown.class + ) + ) { + ConfigEditorDropdown configEditorAnnotation = optionField.getAnnotation( + ConfigEditorDropdown.class + ); + editor = + new GuiOptionEditorDropdown( + option, + configEditorAnnotation.values(), + 0, + false + ); + } + } + if (editor == null) { + //System.err.printf("Failed to load config option %s. Could not find suitable editor.\n", optionField.getName()); + continue; + } + option.editor = editor; + cat.options.put(optionField.getName(), option); + } + } + } else if (exposePresent || categoryPresent) { + //System.err.printf("Failed to load config category %s. Both @Expose and @Category must be present.\n", categoryField.getName()); } - option.editor = editor; - cat.options.put(optionField.getName(), option); - } } - } else if (exposePresent || categoryPresent) { - //System.err.printf("Failed to load config category %s. Both @Expose and @Category must be present.\n", categoryField.getName()); - } + return processedConfig; } - return processedConfig; - } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/util/GuiElementSlider.java b/src/main/java/com/thatgravyboat/skyblockhud/core/util/GuiElementSlider.java index c27c5e3..cdd745d 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/util/GuiElementSlider.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/util/GuiElementSlider.java @@ -13,167 +13,178 @@ import org.lwjgl.opengl.GL11; public class GuiElementSlider extends GuiElement { - public int x; - public int y; - public int width; - private static final int HEIGHT = 16; - - private float minValue; - private float maxValue; - private float minStep; - - private float value; - private Consumer setCallback; - - private boolean clicked = false; - - public GuiElementSlider( - int x, - int y, - int width, - float minValue, - float maxValue, - float minStep, - float value, - Consumer setCallback - ) { - if (minStep < 0) minStep = 0.01f; - - this.x = x; - this.y = y; - this.width = width; - this.minValue = minValue; - this.maxValue = maxValue; - this.minStep = minStep; - this.value = value; - this.setCallback = setCallback; - } - - public void setValue(float value) { - this.value = value; - } - - @Override - public void render() { - final ScaledResolution scaledResolution = new ScaledResolution( - Minecraft.getMinecraft() - ); - int mouseX = - Mouse.getX() * - scaledResolution.getScaledWidth() / - Minecraft.getMinecraft().displayWidth; - - float value = this.value; - if (clicked) { - value = (mouseX - x) * (maxValue - minValue) / width + minValue; - value = Math.max(minValue, Math.min(maxValue, value)); - value = Math.round(value / minStep) * minStep; - } - - float sliderAmount = Math.max( - 0, - Math.min(1, (value - minValue) / (maxValue - minValue)) - ); - int sliderAmountI = (int) (width * sliderAmount); - - GlStateManager.color(1f, 1f, 1f, 1f); - Minecraft.getMinecraft().getTextureManager().bindTexture(slider_on_cap); - Utils.drawTexturedRect(x, y, 4, HEIGHT, GL11.GL_NEAREST); - Minecraft.getMinecraft().getTextureManager().bindTexture(slider_off_cap); - Utils.drawTexturedRect(x + width - 4, y, 4, HEIGHT, GL11.GL_NEAREST); - - if (sliderAmountI > 5) { - Minecraft - .getMinecraft() - .getTextureManager() - .bindTexture(slider_on_segment); - Utils.drawTexturedRect( - x + 4, - y, - sliderAmountI - 4, - HEIGHT, - GL11.GL_NEAREST - ); + public int x; + public int y; + public int width; + private static final int HEIGHT = 16; + + private float minValue; + private float maxValue; + private float minStep; + + private float value; + private Consumer setCallback; + + private boolean clicked = false; + + public GuiElementSlider( + int x, + int y, + int width, + float minValue, + float maxValue, + float minStep, + float value, + Consumer setCallback + ) { + if (minStep < 0) minStep = 0.01f; + + this.x = x; + this.y = y; + this.width = width; + this.minValue = minValue; + this.maxValue = maxValue; + this.minStep = minStep; + this.value = value; + this.setCallback = setCallback; } - if (sliderAmountI < width - 5) { - Minecraft - .getMinecraft() - .getTextureManager() - .bindTexture(slider_off_segment); - Utils.drawTexturedRect( - x + sliderAmountI, - y, - width - 4 - sliderAmountI, - HEIGHT, - GL11.GL_NEAREST - ); + public void setValue(float value) { + this.value = value; } - for (int i = 1; i < 4; i++) { - int notchX = x + width * i / 4 - 1; - Minecraft - .getMinecraft() - .getTextureManager() - .bindTexture( - notchX > x + sliderAmountI ? slider_off_notch : slider_on_notch + @Override + public void render() { + final ScaledResolution scaledResolution = new ScaledResolution( + Minecraft.getMinecraft() + ); + int mouseX = + Mouse.getX() * + scaledResolution.getScaledWidth() / + Minecraft.getMinecraft().displayWidth; + + float value = this.value; + if (clicked) { + value = (mouseX - x) * (maxValue - minValue) / width + minValue; + value = Math.max(minValue, Math.min(maxValue, value)); + value = Math.round(value / minStep) * minStep; + } + + float sliderAmount = Math.max( + 0, + Math.min(1, (value - minValue) / (maxValue - minValue)) + ); + int sliderAmountI = (int) (width * sliderAmount); + + GlStateManager.color(1f, 1f, 1f, 1f); + Minecraft.getMinecraft().getTextureManager().bindTexture(slider_on_cap); + Utils.drawTexturedRect(x, y, 4, HEIGHT, GL11.GL_NEAREST); + Minecraft + .getMinecraft() + .getTextureManager() + .bindTexture(slider_off_cap); + Utils.drawTexturedRect(x + width - 4, y, 4, HEIGHT, GL11.GL_NEAREST); + + if (sliderAmountI > 5) { + Minecraft + .getMinecraft() + .getTextureManager() + .bindTexture(slider_on_segment); + Utils.drawTexturedRect( + x + 4, + y, + sliderAmountI - 4, + HEIGHT, + GL11.GL_NEAREST + ); + } + + if (sliderAmountI < width - 5) { + Minecraft + .getMinecraft() + .getTextureManager() + .bindTexture(slider_off_segment); + Utils.drawTexturedRect( + x + sliderAmountI, + y, + width - 4 - sliderAmountI, + HEIGHT, + GL11.GL_NEAREST + ); + } + + for (int i = 1; i < 4; i++) { + int notchX = x + width * i / 4 - 1; + Minecraft + .getMinecraft() + .getTextureManager() + .bindTexture( + notchX > x + sliderAmountI + ? slider_off_notch + : slider_on_notch + ); + Utils.drawTexturedRect( + notchX, + y + (HEIGHT - 4) / 2f, + 2, + 4, + GL11.GL_NEAREST + ); + } + + Minecraft + .getMinecraft() + .getTextureManager() + .bindTexture(slider_button_new); + Utils.drawTexturedRect( + x + sliderAmountI - 4, + y, + 8, + HEIGHT, + GL11.GL_NEAREST ); - Utils.drawTexturedRect( - notchX, - y + (HEIGHT - 4) / 2f, - 2, - 4, - GL11.GL_NEAREST - ); - } - - Minecraft.getMinecraft().getTextureManager().bindTexture(slider_button_new); - Utils.drawTexturedRect( - x + sliderAmountI - 4, - y, - 8, - HEIGHT, - GL11.GL_NEAREST - ); - } - - @Override - public boolean mouseInput(int mouseX, int mouseY) { - if (!Mouse.isButtonDown(0)) { - clicked = false; } - if (Mouse.getEventButton() == 0) { - clicked = - Mouse.getEventButtonState() && - mouseX > x && - mouseX < x + width && - mouseY > y && - mouseY < y + HEIGHT; - if (clicked) { - value = (mouseX - x) * (maxValue - minValue) / width + minValue; - value = Math.max(minValue, Math.min(maxValue, value)); - value = (float) (Math.round(value / minStep) * (double) minStep); - setCallback.accept(value); - return true; - } + @Override + public boolean mouseInput(int mouseX, int mouseY) { + if (!Mouse.isButtonDown(0)) { + clicked = false; + } + + if (Mouse.getEventButton() == 0) { + clicked = + Mouse.getEventButtonState() && + mouseX > x && + mouseX < x + width && + mouseY > y && + mouseY < y + HEIGHT; + if (clicked) { + value = (mouseX - x) * (maxValue - minValue) / width + minValue; + value = Math.max(minValue, Math.min(maxValue, value)); + value = + (float) (Math.round(value / minStep) * (double) minStep); + setCallback.accept(value); + return true; + } + } + + if ( + !Mouse.getEventButtonState() && + Mouse.getEventButton() == -1 && + clicked + ) { + value = (mouseX - x) * (maxValue - minValue) / width + minValue; + value = Math.max(minValue, Math.min(maxValue, value)); + value = Math.round(value / minStep) * minStep; + setCallback.accept(value); + return true; + } + + return false; } - if ( - !Mouse.getEventButtonState() && Mouse.getEventButton() == -1 && clicked - ) { - value = (mouseX - x) * (maxValue - minValue) / width + minValue; - value = Math.max(minValue, Math.min(maxValue, value)); - value = Math.round(value / minStep) * minStep; - setCallback.accept(value); - return true; + @Override + public boolean keyboardInput() { + return false; } - - return false; - } - - @Override - public boolean keyboardInput() { - return false; - } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/util/MiscUtils.java b/src/main/java/com/thatgravyboat/skyblockhud/core/util/MiscUtils.java index dc390f9..4173694 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/util/MiscUtils.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/util/MiscUtils.java @@ -20,99 +20,113 @@ import org.lwjgl.input.Mouse; public class MiscUtils { - public static void copyToClipboard(String str) { - Toolkit - .getDefaultToolkit() - .getSystemClipboard() - .setContents(new StringSelection(str), null); - } + public static void copyToClipboard(String str) { + Toolkit + .getDefaultToolkit() + .getSystemClipboard() + .setContents(new StringSelection(str), null); + } - private static void unzip(InputStream src, File dest) { - //buffer for read and write data to file - byte[] buffer = new byte[1024]; - try { - ZipInputStream zis = new ZipInputStream(src); - ZipEntry ze = zis.getNextEntry(); - while (ze != null) { - if (!ze.isDirectory()) { - String fileName = ze.getName(); - File newFile = new File(dest, fileName); - //create directories for sub directories in zip - new File(newFile.getParent()).mkdirs(); - FileOutputStream fos = new FileOutputStream(newFile); - int len; - while ((len = zis.read(buffer)) > 0) { - fos.write(buffer, 0, len); - } - fos.close(); + private static void unzip(InputStream src, File dest) { + //buffer for read and write data to file + byte[] buffer = new byte[1024]; + try { + ZipInputStream zis = new ZipInputStream(src); + ZipEntry ze = zis.getNextEntry(); + while (ze != null) { + if (!ze.isDirectory()) { + String fileName = ze.getName(); + File newFile = new File(dest, fileName); + //create directories for sub directories in zip + new File(newFile.getParent()).mkdirs(); + FileOutputStream fos = new FileOutputStream(newFile); + int len; + while ((len = zis.read(buffer)) > 0) { + fos.write(buffer, 0, len); + } + fos.close(); + } + //close this ZipEntry + zis.closeEntry(); + ze = zis.getNextEntry(); + } + //close last ZipEntry + zis.closeEntry(); + zis.close(); + } catch (IOException e) { + e.printStackTrace(); } - //close this ZipEntry - zis.closeEntry(); - ze = zis.getNextEntry(); - } - //close last ZipEntry - zis.closeEntry(); - zis.close(); - } catch (IOException e) { - e.printStackTrace(); } - } - public static void recursiveDelete(File file) { - if (file.isDirectory() && !Files.isSymbolicLink(file.toPath())) { - for (File child : file.listFiles()) { - recursiveDelete(child); - } + public static void recursiveDelete(File file) { + if (file.isDirectory() && !Files.isSymbolicLink(file.toPath())) { + for (File child : file.listFiles()) { + recursiveDelete(child); + } + } + file.delete(); } - file.delete(); - } - private static String currentCursor = null; + private static String currentCursor = null; - public static void resetCursor() { - if (currentCursor == null) { - return; + public static void resetCursor() { + if (currentCursor == null) { + return; + } + currentCursor = null; + try { + Mouse.setNativeCursor(null); + } catch (Exception ignored) {} } - currentCursor = null; - try { - Mouse.setNativeCursor(null); - } catch (Exception ignored) {} - } - public static void setCursor( - ResourceLocation loc, - int hotspotX, - int hotspotY - ) { - if (currentCursor != null && loc.getResourcePath().equals(currentCursor)) { - return; - } - currentCursor = loc.getResourcePath(); - try { - BufferedImage image = ImageIO.read( - Minecraft - .getMinecraft() - .getResourceManager() - .getResource(loc) - .getInputStream() - ); - int maxSize = Cursor.getMaxCursorSize(); - IntBuffer buffer = BufferUtils.createIntBuffer(maxSize * maxSize); - for (int i = 0; i < maxSize * maxSize; i++) { - int cursorX = i % maxSize; - int cursorY = i / maxSize; - if (cursorX >= image.getWidth() || cursorY >= image.getHeight()) { - buffer.put(0x00000000); - } else { - buffer.put(image.getRGB(cursorX, image.getHeight() - 1 - cursorY)); + public static void setCursor( + ResourceLocation loc, + int hotspotX, + int hotspotY + ) { + if ( + currentCursor != null && loc.getResourcePath().equals(currentCursor) + ) { + return; + } + currentCursor = loc.getResourcePath(); + try { + BufferedImage image = ImageIO.read( + Minecraft + .getMinecraft() + .getResourceManager() + .getResource(loc) + .getInputStream() + ); + int maxSize = Cursor.getMaxCursorSize(); + IntBuffer buffer = BufferUtils.createIntBuffer(maxSize * maxSize); + for (int i = 0; i < maxSize * maxSize; i++) { + int cursorX = i % maxSize; + int cursorY = i / maxSize; + if ( + cursorX >= image.getWidth() || cursorY >= image.getHeight() + ) { + buffer.put(0x00000000); + } else { + buffer.put( + image.getRGB(cursorX, image.getHeight() - 1 - cursorY) + ); + } + } + buffer.flip(); + Mouse.setNativeCursor( + new Cursor( + maxSize, + maxSize, + hotspotX, + hotspotY, + 1, + buffer, + null + ) + ); + } catch (Exception e) { + e.printStackTrace(); } - } - buffer.flip(); - Mouse.setNativeCursor( - new Cursor(maxSize, maxSize, hotspotX, hotspotY, 1, buffer, null) - ); - } catch (Exception e) { - e.printStackTrace(); } - } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/util/Splitters.java b/src/main/java/com/thatgravyboat/skyblockhud/core/util/Splitters.java index 1690f74..f13fbc7 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/util/Splitters.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/util/Splitters.java @@ -4,5 +4,5 @@ import com.google.common.base.Splitter; public class Splitters { - public static final Splitter NEWLINE_SPLITTER = Splitter.on('\n'); + public static final Splitter NEWLINE_SPLITTER = Splitter.on('\n'); } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/util/StringUtils.java b/src/main/java/com/thatgravyboat/skyblockhud/core/util/StringUtils.java index 37d3429..48c7566 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/util/StringUtils.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/util/StringUtils.java @@ -7,31 +7,34 @@ import net.minecraft.client.gui.FontRenderer; public class StringUtils { - public static final Set PROTOCOLS = Sets.newHashSet("http", "https"); - - public static String cleanColour(String in) { - return in.replaceAll("(?i)\\u00A7.", ""); - } - - public static String cleanColourNotModifiers(String in) { - return in.replaceAll("(?i)\\u00A7[0-9a-f]", "\u00A7r"); - } - - public static String trimToWidth(String str, int len) { - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - String trim = fr.trimStringToWidth(str, len); - - if (str.length() != trim.length() && !trim.endsWith(" ")) { - char next = str.charAt(trim.length()); - if (next != ' ') { - String[] split = trim.split(" "); - String last = split[split.length - 1]; - if (last.length() < 8) { - trim = trim.substring(0, trim.length() - last.length()); - } - } + public static final Set PROTOCOLS = Sets.newHashSet( + "http", + "https" + ); + + public static String cleanColour(String in) { + return in.replaceAll("(?i)\\u00A7.", ""); + } + + public static String cleanColourNotModifiers(String in) { + return in.replaceAll("(?i)\\u00A7[0-9a-f]", "\u00A7r"); } - return trim; - } + public static String trimToWidth(String str, int len) { + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + String trim = fr.trimStringToWidth(str, len); + + if (str.length() != trim.length() && !trim.endsWith(" ")) { + char next = str.charAt(trim.length()); + if (next != ' ') { + String[] split = trim.split(" "); + String last = split[split.length - 1]; + if (last.length() < 8) { + trim = trim.substring(0, trim.length() - last.length()); + } + } + } + + return trim; + } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/util/lerp/LerpUtils.java b/src/main/java/com/thatgravyboat/skyblockhud/core/util/lerp/LerpUtils.java index 56c4b92..b24bbe6 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/util/lerp/LerpUtils.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/util/lerp/LerpUtils.java @@ -2,25 +2,26 @@ package com.thatgravyboat.skyblockhud.core.util.lerp; public class LerpUtils { - public static float clampZeroOne(float f) { - return Math.max(0, Math.min(1, f)); - } + public static float clampZeroOne(float f) { + return Math.max(0, Math.min(1, f)); + } - public static float sigmoid(float val) { - return (float) (1 / (1 + Math.exp(-val))); - } + public static float sigmoid(float val) { + return (float) (1 / (1 + Math.exp(-val))); + } - private static final float sigmoidStr = 8; - private static final float sigmoidA = - -1 / (sigmoid(-0.5f * sigmoidStr) - sigmoid(0.5f * sigmoidStr)); - private static final float sigmoidB = sigmoidA * sigmoid(-0.5f * sigmoidStr); + private static final float sigmoidStr = 8; + private static final float sigmoidA = + -1 / (sigmoid(-0.5f * sigmoidStr) - sigmoid(0.5f * sigmoidStr)); + private static final float sigmoidB = + sigmoidA * sigmoid(-0.5f * sigmoidStr); - public static float sigmoidZeroOne(float f) { - f = clampZeroOne(f); - return sigmoidA * sigmoid(sigmoidStr * (f - 0.5f)) - sigmoidB; - } + public static float sigmoidZeroOne(float f) { + f = clampZeroOne(f); + return sigmoidA * sigmoid(sigmoidStr * (f - 0.5f)) - sigmoidB; + } - public static float lerp(float a, float b, float amount) { - return b + (a - b) * clampZeroOne(amount); - } + public static float lerp(float a, float b, float amount) { + return b + (a - b) * clampZeroOne(amount); + } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/util/lerp/LerpingFloat.java b/src/main/java/com/thatgravyboat/skyblockhud/core/util/lerp/LerpingFloat.java index 7eedcac..9e379c7 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/util/lerp/LerpingFloat.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/util/lerp/LerpingFloat.java @@ -2,67 +2,68 @@ package com.thatgravyboat.skyblockhud.core.util.lerp; public class LerpingFloat { - private int timeSpent; - private long lastMillis; - private int timeToReachTarget; + private int timeSpent; + private long lastMillis; + private int timeToReachTarget; - private float targetValue; - private float lerpValue; + private float targetValue; + private float lerpValue; - public LerpingFloat(float initialValue, int timeToReachTarget) { - this.targetValue = this.lerpValue = initialValue; - this.timeToReachTarget = timeToReachTarget; - } + public LerpingFloat(float initialValue, int timeToReachTarget) { + this.targetValue = this.lerpValue = initialValue; + this.timeToReachTarget = timeToReachTarget; + } + + public LerpingFloat(int initialValue) { + this(initialValue, 200); + } - public LerpingFloat(int initialValue) { - this(initialValue, 200); - } + public void tick() { + int lastTimeSpent = timeSpent; + this.timeSpent += System.currentTimeMillis() - lastMillis; - public void tick() { - int lastTimeSpent = timeSpent; - this.timeSpent += System.currentTimeMillis() - lastMillis; + float lastDistPercentToTarget = + lastTimeSpent / (float) timeToReachTarget; + float distPercentToTarget = timeSpent / (float) timeToReachTarget; + float fac = (1 - lastDistPercentToTarget) / lastDistPercentToTarget; - float lastDistPercentToTarget = lastTimeSpent / (float) timeToReachTarget; - float distPercentToTarget = timeSpent / (float) timeToReachTarget; - float fac = (1 - lastDistPercentToTarget) / lastDistPercentToTarget; + float startValue = lerpValue - (targetValue - lerpValue) / fac; - float startValue = lerpValue - (targetValue - lerpValue) / fac; + float dist = targetValue - startValue; + if (dist == 0) return; - float dist = targetValue - startValue; - if (dist == 0) return; + float oldLerpValue = lerpValue; + if (distPercentToTarget >= 1) { + lerpValue = targetValue; + } else { + lerpValue = startValue + dist * distPercentToTarget; + } - float oldLerpValue = lerpValue; - if (distPercentToTarget >= 1) { - lerpValue = targetValue; - } else { - lerpValue = startValue + dist * distPercentToTarget; + if (lerpValue == oldLerpValue) { + timeSpent = lastTimeSpent; + } else { + this.lastMillis = System.currentTimeMillis(); + } } - if (lerpValue == oldLerpValue) { - timeSpent = lastTimeSpent; - } else { - this.lastMillis = System.currentTimeMillis(); + public void resetTimer() { + this.timeSpent = 0; + this.lastMillis = System.currentTimeMillis(); } - } - - public void resetTimer() { - this.timeSpent = 0; - this.lastMillis = System.currentTimeMillis(); - } - public void setTarget(float targetValue) { - this.targetValue = targetValue; - } + public void setTarget(float targetValue) { + this.targetValue = targetValue; + } - public void setValue(float value) { - this.targetValue = this.lerpValue = value; - } + public void setValue(float value) { + this.targetValue = this.lerpValue = value; + } - public float getValue() { - return lerpValue; - } + public float getValue() { + return lerpValue; + } - public float getTarget() { - return targetValue; - } + public float getTarget() { + return targetValue; + } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/util/lerp/LerpingInteger.java b/src/main/java/com/thatgravyboat/skyblockhud/core/util/lerp/LerpingInteger.java index de9aec4..63e7143 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/util/lerp/LerpingInteger.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/util/lerp/LerpingInteger.java @@ -2,75 +2,76 @@ package com.thatgravyboat.skyblockhud.core.util.lerp; public class LerpingInteger { - private int timeSpent; - private long lastMillis; - private int timeToReachTarget; + private int timeSpent; + private long lastMillis; + private int timeToReachTarget; - private int targetValue; - private int lerpValue; + private int targetValue; + private int lerpValue; - public LerpingInteger(int initialValue, int timeToReachTarget) { - this.targetValue = this.lerpValue = initialValue; - this.timeToReachTarget = timeToReachTarget; - } + public LerpingInteger(int initialValue, int timeToReachTarget) { + this.targetValue = this.lerpValue = initialValue; + this.timeToReachTarget = timeToReachTarget; + } - public LerpingInteger(int initialValue) { - this(initialValue, 200); - } + public LerpingInteger(int initialValue) { + this(initialValue, 200); + } - public void tick() { - int lastTimeSpent = timeSpent; - this.timeSpent += System.currentTimeMillis() - lastMillis; + public void tick() { + int lastTimeSpent = timeSpent; + this.timeSpent += System.currentTimeMillis() - lastMillis; - float lastDistPercentToTarget = lastTimeSpent / (float) timeToReachTarget; - float distPercentToTarget = timeSpent / (float) timeToReachTarget; - float fac = (1 - lastDistPercentToTarget) / lastDistPercentToTarget; + float lastDistPercentToTarget = + lastTimeSpent / (float) timeToReachTarget; + float distPercentToTarget = timeSpent / (float) timeToReachTarget; + float fac = (1 - lastDistPercentToTarget) / lastDistPercentToTarget; - int startValue = lerpValue - (int) ((targetValue - lerpValue) / fac); + int startValue = lerpValue - (int) ((targetValue - lerpValue) / fac); - int dist = targetValue - startValue; - if (dist == 0) return; + int dist = targetValue - startValue; + if (dist == 0) return; - int oldLerpValue = lerpValue; - if (distPercentToTarget >= 1) { - lerpValue = targetValue; - } else { - lerpValue = startValue + (int) (dist * distPercentToTarget); - } + int oldLerpValue = lerpValue; + if (distPercentToTarget >= 1) { + lerpValue = targetValue; + } else { + lerpValue = startValue + (int) (dist * distPercentToTarget); + } - if (lerpValue == oldLerpValue) { - timeSpent = lastTimeSpent; - } else { - this.lastMillis = System.currentTimeMillis(); + if (lerpValue == oldLerpValue) { + timeSpent = lastTimeSpent; + } else { + this.lastMillis = System.currentTimeMillis(); + } } - } - public int getTimeSpent() { - return timeSpent; - } + public int getTimeSpent() { + return timeSpent; + } - public void resetTimer() { - this.timeSpent = 0; - this.lastMillis = System.currentTimeMillis(); - } + public void resetTimer() { + this.timeSpent = 0; + this.lastMillis = System.currentTimeMillis(); + } - public void setTimeToReachTarget(int timeToReachTarget) { - this.timeToReachTarget = timeToReachTarget; - } + public void setTimeToReachTarget(int timeToReachTarget) { + this.timeToReachTarget = timeToReachTarget; + } - public void setTarget(int targetValue) { - this.targetValue = targetValue; - } + public void setTarget(int targetValue) { + this.targetValue = targetValue; + } - public void setValue(int value) { - this.targetValue = this.lerpValue = value; - } + public void setValue(int value) { + this.targetValue = this.lerpValue = value; + } - public int getValue() { - return lerpValue; - } + public int getValue() { + return lerpValue; + } - public int getTarget() { - return targetValue; - } + public int getTarget() { + return targetValue; + } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/util/render/RenderUtils.java b/src/main/java/com/thatgravyboat/skyblockhud/core/util/render/RenderUtils.java index 042df83..242166b 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/util/render/RenderUtils.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/util/render/RenderUtils.java @@ -14,304 +14,330 @@ import org.lwjgl.opengl.GL14; public class RenderUtils { - public static void drawFloatingRectDark(int x, int y, int width, int height) { - drawFloatingRectDark(x, y, width, height, true); - } + public static void drawFloatingRectDark( + int x, + int y, + int width, + int height + ) { + drawFloatingRectDark(x, y, width, height, true); + } - public static void drawFloatingRectDark( - int x, - int y, - int width, - int height, - boolean shadow - ) { - int alpha = 0xf0000000; + public static void drawFloatingRectDark( + int x, + int y, + int width, + int height, + boolean shadow + ) { + int alpha = 0xf0000000; - if (OpenGlHelper.isFramebufferEnabled()) { - ScaledResolution scaledResolution = new ScaledResolution( - Minecraft.getMinecraft() - ); - BackgroundBlur.renderBlurredBackground( - 15, - scaledResolution.getScaledWidth(), - scaledResolution.getScaledHeight(), - x, - y, - width, - height, - true - ); - } else { - alpha = 0xff000000; - } + if (OpenGlHelper.isFramebufferEnabled()) { + ScaledResolution scaledResolution = new ScaledResolution( + Minecraft.getMinecraft() + ); + BackgroundBlur.renderBlurredBackground( + 15, + scaledResolution.getScaledWidth(), + scaledResolution.getScaledHeight(), + x, + y, + width, + height, + true + ); + } else { + alpha = 0xff000000; + } - int main = alpha | 0x202026; - int light = 0xff303036; - int dark = 0xff101016; - Gui.drawRect(x, y, x + 1, y + height, light); //Left - Gui.drawRect(x + 1, y, x + width, y + 1, light); //Top - Gui.drawRect(x + width - 1, y + 1, x + width, y + height, dark); //Right - Gui.drawRect(x + 1, y + height - 1, x + width - 1, y + height, dark); //Bottom - Gui.drawRect(x + 1, y + 1, x + width - 1, y + height - 1, main); //Middle - if (shadow) { - Gui.drawRect(x + width, y + 2, x + width + 2, y + height + 2, 0x70000000); //Right shadow - Gui.drawRect(x + 2, y + height, x + width, y + height + 2, 0x70000000); //Bottom shadow + int main = alpha | 0x202026; + int light = 0xff303036; + int dark = 0xff101016; + Gui.drawRect(x, y, x + 1, y + height, light); //Left + Gui.drawRect(x + 1, y, x + width, y + 1, light); //Top + Gui.drawRect(x + width - 1, y + 1, x + width, y + height, dark); //Right + Gui.drawRect(x + 1, y + height - 1, x + width - 1, y + height, dark); //Bottom + Gui.drawRect(x + 1, y + 1, x + width - 1, y + height - 1, main); //Middle + if (shadow) { + Gui.drawRect( + x + width, + y + 2, + x + width + 2, + y + height + 2, + 0x70000000 + ); //Right shadow + Gui.drawRect( + x + 2, + y + height, + x + width, + y + height + 2, + 0x70000000 + ); //Bottom shadow + } } - } - public static void drawFloatingRect(int x, int y, int width, int height) { - drawFloatingRectWithAlpha(x, y, width, height, 0xFF, true); - } + public static void drawFloatingRect(int x, int y, int width, int height) { + drawFloatingRectWithAlpha(x, y, width, height, 0xFF, true); + } - public static void drawFloatingRectWithAlpha( - int x, - int y, - int width, - int height, - int alpha, - boolean shadow - ) { - int main = (alpha << 24) | 0xc0c0c0; - int light = (alpha << 24) | 0xf0f0f0; - int dark = (alpha << 24) | 0x909090; - Gui.drawRect(x, y, x + 1, y + height, light); //Left - Gui.drawRect(x + 1, y, x + width, y + 1, light); //Top - Gui.drawRect(x + width - 1, y + 1, x + width, y + height, dark); //Right - Gui.drawRect(x + 1, y + height - 1, x + width - 1, y + height, dark); //Bottom - Gui.drawRect(x + 1, y + 1, x + width - 1, y + height - 1, main); //Middle - if (shadow) { - Gui.drawRect( - x + width, - y + 2, - x + width + 2, - y + height + 2, - (alpha * 3 / 5) << 24 - ); //Right shadow - Gui.drawRect( - x + 2, - y + height, - x + width, - y + height + 2, - (alpha * 3 / 5) << 24 - ); //Bottom shadow + public static void drawFloatingRectWithAlpha( + int x, + int y, + int width, + int height, + int alpha, + boolean shadow + ) { + int main = (alpha << 24) | 0xc0c0c0; + int light = (alpha << 24) | 0xf0f0f0; + int dark = (alpha << 24) | 0x909090; + Gui.drawRect(x, y, x + 1, y + height, light); //Left + Gui.drawRect(x + 1, y, x + width, y + 1, light); //Top + Gui.drawRect(x + width - 1, y + 1, x + width, y + height, dark); //Right + Gui.drawRect(x + 1, y + height - 1, x + width - 1, y + height, dark); //Bottom + Gui.drawRect(x + 1, y + 1, x + width - 1, y + height - 1, main); //Middle + if (shadow) { + Gui.drawRect( + x + width, + y + 2, + x + width + 2, + y + height + 2, + (alpha * 3 / 5) << 24 + ); //Right shadow + Gui.drawRect( + x + 2, + y + height, + x + width, + y + height + 2, + (alpha * 3 / 5) << 24 + ); //Bottom shadow + } } - } - public static void drawTexturedModalRect( - int x, - int y, - int textureX, - int textureY, - int width, - int height - ) { - double f = 0.00390625; - double f1 = 0.00390625; - Tessellator tessellator = Tessellator.getInstance(); - WorldRenderer worldrenderer = tessellator.getWorldRenderer(); - worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX); - worldrenderer - .pos(x + 0.0, y + height, 0.0) - .tex((textureX + 0.0) * f, (textureY + height) * f1) - .endVertex(); - worldrenderer - .pos(x + width, y + height, 0.0) - .tex((textureX + width) * f, (textureY + height) * f1) - .endVertex(); - worldrenderer - .pos(x + width, y + 0.0, 0.0) - .tex((textureX + width) * f, (textureY + 0.0) * f1) - .endVertex(); - worldrenderer - .pos(x + 0.0, y + 0.0, 0.0) - .tex((textureX + 0.0) * f, (textureY + 0.0) * f1) - .endVertex(); - tessellator.draw(); - } + public static void drawTexturedModalRect( + int x, + int y, + int textureX, + int textureY, + int width, + int height + ) { + double f = 0.00390625; + double f1 = 0.00390625; + Tessellator tessellator = Tessellator.getInstance(); + WorldRenderer worldrenderer = tessellator.getWorldRenderer(); + worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX); + worldrenderer + .pos(x + 0.0, y + height, 0.0) + .tex((textureX + 0.0) * f, (textureY + height) * f1) + .endVertex(); + worldrenderer + .pos(x + width, y + height, 0.0) + .tex((textureX + width) * f, (textureY + height) * f1) + .endVertex(); + worldrenderer + .pos(x + width, y + 0.0, 0.0) + .tex((textureX + width) * f, (textureY + 0.0) * f1) + .endVertex(); + worldrenderer + .pos(x + 0.0, y + 0.0, 0.0) + .tex((textureX + 0.0) * f, (textureY + 0.0) * f1) + .endVertex(); + tessellator.draw(); + } - public static void drawTexturedRect( - float x, - float y, - float width, - float height - ) { - drawTexturedRect(x, y, width, height, 0, 1, 0, 1); - } + public static void drawTexturedRect( + float x, + float y, + float width, + float height + ) { + drawTexturedRect(x, y, width, height, 0, 1, 0, 1); + } - public static void drawTexturedRect( - float x, - float y, - float width, - float height, - int filter - ) { - drawTexturedRect(x, y, width, height, 0, 1, 0, 1, filter); - } + public static void drawTexturedRect( + float x, + float y, + float width, + float height, + int filter + ) { + drawTexturedRect(x, y, width, height, 0, 1, 0, 1, filter); + } - public static void drawTexturedRect( - float x, - float y, - float width, - float height, - float uMin, - float uMax, - float vMin, - float vMax - ) { - drawTexturedRect( - x, - y, - width, - height, - uMin, - uMax, - vMin, - vMax, - GL11.GL_NEAREST - ); - } + public static void drawTexturedRect( + float x, + float y, + float width, + float height, + float uMin, + float uMax, + float vMin, + float vMax + ) { + drawTexturedRect( + x, + y, + width, + height, + uMin, + uMax, + vMin, + vMax, + GL11.GL_NEAREST + ); + } - public static void drawTexturedRect( - float x, - float y, - float width, - float height, - float uMin, - float uMax, - float vMin, - float vMax, - int filter - ) { - GlStateManager.enableBlend(); - GL14.glBlendFuncSeparate( - GL11.GL_SRC_ALPHA, - GL11.GL_ONE_MINUS_SRC_ALPHA, - GL11.GL_ONE, - GL11.GL_ONE_MINUS_SRC_ALPHA - ); + public static void drawTexturedRect( + float x, + float y, + float width, + float height, + float uMin, + float uMax, + float vMin, + float vMax, + int filter + ) { + GlStateManager.enableBlend(); + GL14.glBlendFuncSeparate( + GL11.GL_SRC_ALPHA, + GL11.GL_ONE_MINUS_SRC_ALPHA, + GL11.GL_ONE, + GL11.GL_ONE_MINUS_SRC_ALPHA + ); - drawTexturedRectNoBlend( - x, - y, - width, - height, - uMin, - uMax, - vMin, - vMax, - filter - ); + drawTexturedRectNoBlend( + x, + y, + width, + height, + uMin, + uMax, + vMin, + vMax, + filter + ); - GlStateManager.disableBlend(); - } + GlStateManager.disableBlend(); + } - public static void drawTexturedRectNoBlend( - float x, - float y, - float width, - float height, - float uMin, - float uMax, - float vMin, - float vMax, - int filter - ) { - GlStateManager.enableTexture2D(); + public static void drawTexturedRectNoBlend( + float x, + float y, + float width, + float height, + float uMin, + float uMax, + float vMin, + float vMax, + int filter + ) { + GlStateManager.enableTexture2D(); - GL11.glTexParameteri( - GL11.GL_TEXTURE_2D, - GL11.GL_TEXTURE_MIN_FILTER, - filter - ); - GL11.glTexParameteri( - GL11.GL_TEXTURE_2D, - GL11.GL_TEXTURE_MAG_FILTER, - filter - ); + GL11.glTexParameteri( + GL11.GL_TEXTURE_2D, + GL11.GL_TEXTURE_MIN_FILTER, + filter + ); + GL11.glTexParameteri( + GL11.GL_TEXTURE_2D, + GL11.GL_TEXTURE_MAG_FILTER, + filter + ); - Tessellator tessellator = Tessellator.getInstance(); - WorldRenderer worldrenderer = tessellator.getWorldRenderer(); - worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX); - worldrenderer.pos(x, y + height, 0.0D).tex(uMin, vMax).endVertex(); - worldrenderer.pos(x + width, y + height, 0.0D).tex(uMax, vMax).endVertex(); - worldrenderer.pos(x + width, y, 0.0D).tex(uMax, vMin).endVertex(); - worldrenderer.pos(x, y, 0.0D).tex(uMin, vMin).endVertex(); - tessellator.draw(); + Tessellator tessellator = Tessellator.getInstance(); + WorldRenderer worldrenderer = tessellator.getWorldRenderer(); + worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX); + worldrenderer.pos(x, y + height, 0.0D).tex(uMin, vMax).endVertex(); + worldrenderer + .pos(x + width, y + height, 0.0D) + .tex(uMax, vMax) + .endVertex(); + worldrenderer.pos(x + width, y, 0.0D).tex(uMax, vMin).endVertex(); + worldrenderer.pos(x, y, 0.0D).tex(uMin, vMin).endVertex(); + tessellator.draw(); - GL11.glTexParameteri( - GL11.GL_TEXTURE_2D, - GL11.GL_TEXTURE_MIN_FILTER, - GL11.GL_NEAREST - ); - GL11.glTexParameteri( - GL11.GL_TEXTURE_2D, - GL11.GL_TEXTURE_MAG_FILTER, - GL11.GL_NEAREST - ); - } + GL11.glTexParameteri( + GL11.GL_TEXTURE_2D, + GL11.GL_TEXTURE_MIN_FILTER, + GL11.GL_NEAREST + ); + GL11.glTexParameteri( + GL11.GL_TEXTURE_2D, + GL11.GL_TEXTURE_MAG_FILTER, + GL11.GL_NEAREST + ); + } - public static void drawGradientRect( - int zLevel, - int left, - int top, - int right, - int bottom, - int startColor, - int endColor - ) { - float startAlpha = (float) (startColor >> 24 & 255) / 255.0F; - float startRed = (float) (startColor >> 16 & 255) / 255.0F; - float startGreen = (float) (startColor >> 8 & 255) / 255.0F; - float startBlue = (float) (startColor & 255) / 255.0F; - float endAlpha = (float) (endColor >> 24 & 255) / 255.0F; - float endRed = (float) (endColor >> 16 & 255) / 255.0F; - float endGreen = (float) (endColor >> 8 & 255) / 255.0F; - float endBlue = (float) (endColor & 255) / 255.0F; + public static void drawGradientRect( + int zLevel, + int left, + int top, + int right, + int bottom, + int startColor, + int endColor + ) { + float startAlpha = (float) (startColor >> 24 & 255) / 255.0F; + float startRed = (float) (startColor >> 16 & 255) / 255.0F; + float startGreen = (float) (startColor >> 8 & 255) / 255.0F; + float startBlue = (float) (startColor & 255) / 255.0F; + float endAlpha = (float) (endColor >> 24 & 255) / 255.0F; + float endRed = (float) (endColor >> 16 & 255) / 255.0F; + float endGreen = (float) (endColor >> 8 & 255) / 255.0F; + float endBlue = (float) (endColor & 255) / 255.0F; - GlStateManager.disableTexture2D(); - GlStateManager.enableBlend(); - GlStateManager.disableAlpha(); - GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); - GlStateManager.shadeModel(7425); + GlStateManager.disableTexture2D(); + GlStateManager.enableBlend(); + GlStateManager.disableAlpha(); + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); + GlStateManager.shadeModel(7425); - Tessellator tessellator = Tessellator.getInstance(); - WorldRenderer worldrenderer = tessellator.getWorldRenderer(); - worldrenderer.begin(7, DefaultVertexFormats.POSITION_COLOR); - worldrenderer - .pos(right, top, zLevel) - .color(startRed, startGreen, startBlue, startAlpha) - .endVertex(); - worldrenderer - .pos(left, top, zLevel) - .color(startRed, startGreen, startBlue, startAlpha) - .endVertex(); - worldrenderer - .pos(left, bottom, zLevel) - .color(endRed, endGreen, endBlue, endAlpha) - .endVertex(); - worldrenderer - .pos(right, bottom, zLevel) - .color(endRed, endGreen, endBlue, endAlpha) - .endVertex(); - tessellator.draw(); + Tessellator tessellator = Tessellator.getInstance(); + WorldRenderer worldrenderer = tessellator.getWorldRenderer(); + worldrenderer.begin(7, DefaultVertexFormats.POSITION_COLOR); + worldrenderer + .pos(right, top, zLevel) + .color(startRed, startGreen, startBlue, startAlpha) + .endVertex(); + worldrenderer + .pos(left, top, zLevel) + .color(startRed, startGreen, startBlue, startAlpha) + .endVertex(); + worldrenderer + .pos(left, bottom, zLevel) + .color(endRed, endGreen, endBlue, endAlpha) + .endVertex(); + worldrenderer + .pos(right, bottom, zLevel) + .color(endRed, endGreen, endBlue, endAlpha) + .endVertex(); + tessellator.draw(); - GlStateManager.shadeModel(7424); - GlStateManager.disableBlend(); - GlStateManager.enableAlpha(); - GlStateManager.enableTexture2D(); - } + GlStateManager.shadeModel(7424); + GlStateManager.disableBlend(); + GlStateManager.enableAlpha(); + GlStateManager.enableTexture2D(); + } - public static void drawInnerBox(int left, int top, int width, int height) { - Gui.drawRect(left, top, left + width, top + height, 0x6008080E); //Middle - Gui.drawRect(left, top, left + 1, top + height, 0xff08080E); //Left - Gui.drawRect(left, top, left + width, top + 1, 0xff08080E); //Top - Gui.drawRect(left + width - 1, top, left + width, top + height, 0xff28282E); //Right - Gui.drawRect( - left, - top + height - 1, - left + width, - top + height, - 0xff28282E - ); //Bottom - } + public static void drawInnerBox(int left, int top, int width, int height) { + Gui.drawRect(left, top, left + width, top + height, 0x6008080E); //Middle + Gui.drawRect(left, top, left + 1, top + height, 0xff08080E); //Left + Gui.drawRect(left, top, left + width, top + 1, 0xff08080E); //Top + Gui.drawRect( + left + width - 1, + top, + left + width, + top + height, + 0xff28282E + ); //Right + Gui.drawRect( + left, + top + height - 1, + left + width, + top + height, + 0xff28282E + ); //Bottom + } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/util/render/TextRenderUtils.java b/src/main/java/com/thatgravyboat/skyblockhud/core/util/render/TextRenderUtils.java index 566953a..4284012 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/util/render/TextRenderUtils.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/util/render/TextRenderUtils.java @@ -13,355 +13,364 @@ import org.lwjgl.opengl.GL11; public class TextRenderUtils { - public static int getCharVertLen(char c) { - if ("acegmnopqrsuvwxyz".indexOf(c) >= 0) { - return 5; - } else { - return 7; + public static int getCharVertLen(char c) { + if ("acegmnopqrsuvwxyz".indexOf(c) >= 0) { + return 5; + } else { + return 7; + } } - } - - public static float getVerticalHeight(String str) { - str = StringUtils.cleanColour(str); - float height = 0; - for (int i = 0; i < str.length(); i++) { - char c = str.charAt(i); - int charHeight = getCharVertLen(c); - height += charHeight + 1.5f; + + public static float getVerticalHeight(String str) { + str = StringUtils.cleanColour(str); + float height = 0; + for (int i = 0; i < str.length(); i++) { + char c = str.charAt(i); + int charHeight = getCharVertLen(c); + height += charHeight + 1.5f; + } + return height; } - return height; - } - - public static void drawStringVertical( - String str, - FontRenderer fr, - float x, - float y, - boolean shadow, - int colour - ) { - String format = FontRenderer.getFormatFromString(str); - str = StringUtils.cleanColour(str); - for (int i = 0; i < str.length(); i++) { - char c = str.charAt(i); - - int charHeight = getCharVertLen(c); - int charWidth = fr.getCharWidth(c); - fr.drawString( - format + c, - x + (5 - charWidth) / 2f, - y - 7 + charHeight, - colour, - shadow - ); - - y += charHeight + 1.5f; + + public static void drawStringVertical( + String str, + FontRenderer fr, + float x, + float y, + boolean shadow, + int colour + ) { + String format = FontRenderer.getFormatFromString(str); + str = StringUtils.cleanColour(str); + for (int i = 0; i < str.length(); i++) { + char c = str.charAt(i); + + int charHeight = getCharVertLen(c); + int charWidth = fr.getCharWidth(c); + fr.drawString( + format + c, + x + (5 - charWidth) / 2f, + y - 7 + charHeight, + colour, + shadow + ); + + y += charHeight + 1.5f; + } } - } - - public static void drawStringScaledMaxWidth( - String str, - FontRenderer fr, - float x, - float y, - boolean shadow, - int len, - int colour - ) { - int strLen = fr.getStringWidth(str); - float factor = len / (float) strLen; - factor = Math.min(1, factor); - - drawStringScaled(str, fr, x, y, shadow, colour, factor); - } - - public static void drawStringCentered( - String str, - FontRenderer fr, - float x, - float y, - boolean shadow, - int colour - ) { - int strLen = fr.getStringWidth(str); - - float x2 = x - strLen / 2f; - float y2 = y - fr.FONT_HEIGHT / 2f; - - GL11.glTranslatef(x2, y2, 0); - fr.drawString(str, 0, 0, colour, shadow); - GL11.glTranslatef(-x2, -y2, 0); - } - - public static void drawStringScaled( - String str, - FontRenderer fr, - float x, - float y, - boolean shadow, - int colour, - float factor - ) { - GlStateManager.scale(factor, factor, 1); - fr.drawString(str, x / factor, y / factor, colour, shadow); - GlStateManager.scale(1 / factor, 1 / factor, 1); - } - - public static void drawStringCenteredScaledMaxWidth( - String str, - FontRenderer fr, - float x, - float y, - boolean shadow, - int len, - int colour - ) { - int strLen = fr.getStringWidth(str); - float factor = len / (float) strLen; - factor = Math.min(1, factor); - int newLen = Math.min(strLen, len); - - float fontHeight = 8 * factor; - - drawStringScaled( - str, - fr, - x - newLen / 2, - y - fontHeight / 2, - shadow, - colour, - factor - ); - } - - public static void renderToolTip( - ItemStack stack, - int mouseX, - int mouseY, - int screenWidth, - int screenHeight, - FontRenderer fontStd - ) { - List list = stack.getTooltip( - Minecraft.getMinecraft().thePlayer, - Minecraft.getMinecraft().gameSettings.advancedItemTooltips - ); - - for (int i = 0; i < list.size(); ++i) { - if (i == 0) { - list.set(i, stack.getRarity().rarityColor + list.get(i)); - } else { - list.set(i, EnumChatFormatting.GRAY + list.get(i)); - } + + public static void drawStringScaledMaxWidth( + String str, + FontRenderer fr, + float x, + float y, + boolean shadow, + int len, + int colour + ) { + int strLen = fr.getStringWidth(str); + float factor = len / (float) strLen; + factor = Math.min(1, factor); + + drawStringScaled(str, fr, x, y, shadow, colour, factor); } - FontRenderer font = stack.getItem().getFontRenderer(stack); - drawHoveringText( - list, - mouseX, - mouseY, - screenWidth, - screenHeight, - -1, - font == null ? fontStd : font - ); - } - - public static void drawHoveringText( - List textLines, - final int mouseX, - final int mouseY, - final int screenWidth, - final int screenHeight, - final int maxTextWidth, - FontRenderer font - ) { - if (!textLines.isEmpty()) { - GlStateManager.disableRescaleNormal(); - RenderHelper.disableStandardItemLighting(); - GlStateManager.disableLighting(); - GlStateManager.disableDepth(); - int tooltipTextWidth = 0; - - for (String textLine : textLines) { - int textLineWidth = font.getStringWidth(textLine); - - if (textLineWidth > tooltipTextWidth) { - tooltipTextWidth = textLineWidth; - } - } - - boolean needsWrap = false; - - int titleLinesCount = 1; - int tooltipX = mouseX + 12; - if (tooltipX + tooltipTextWidth + 4 > screenWidth) { - tooltipX = mouseX - 16 - tooltipTextWidth; - if ( - tooltipX < 4 - ) { // if the tooltip doesn't fit on the screen - if (mouseX > screenWidth / 2) { - tooltipTextWidth = mouseX - 12 - 8; - } else { - tooltipTextWidth = screenWidth - 16 - mouseX; - } - needsWrap = true; - } - } - - if (maxTextWidth > 0 && tooltipTextWidth > maxTextWidth) { - tooltipTextWidth = maxTextWidth; - needsWrap = true; - } - - if (needsWrap) { - int wrappedTooltipWidth = 0; - List wrappedTextLines = new ArrayList(); - for (int i = 0; i < textLines.size(); i++) { - String textLine = textLines.get(i); - List wrappedLine = font.listFormattedStringToWidth( - textLine, - tooltipTextWidth - ); - if (i == 0) { - titleLinesCount = wrappedLine.size(); - } - - for (String line : wrappedLine) { - int lineWidth = font.getStringWidth(line); - if (lineWidth > wrappedTooltipWidth) { - wrappedTooltipWidth = lineWidth; + public static void drawStringCentered( + String str, + FontRenderer fr, + float x, + float y, + boolean shadow, + int colour + ) { + int strLen = fr.getStringWidth(str); + + float x2 = x - strLen / 2f; + float y2 = y - fr.FONT_HEIGHT / 2f; + + GL11.glTranslatef(x2, y2, 0); + fr.drawString(str, 0, 0, colour, shadow); + GL11.glTranslatef(-x2, -y2, 0); + } + + public static void drawStringScaled( + String str, + FontRenderer fr, + float x, + float y, + boolean shadow, + int colour, + float factor + ) { + GlStateManager.scale(factor, factor, 1); + fr.drawString(str, x / factor, y / factor, colour, shadow); + GlStateManager.scale(1 / factor, 1 / factor, 1); + } + + public static void drawStringCenteredScaledMaxWidth( + String str, + FontRenderer fr, + float x, + float y, + boolean shadow, + int len, + int colour + ) { + int strLen = fr.getStringWidth(str); + float factor = len / (float) strLen; + factor = Math.min(1, factor); + int newLen = Math.min(strLen, len); + + float fontHeight = 8 * factor; + + drawStringScaled( + str, + fr, + x - newLen / 2, + y - fontHeight / 2, + shadow, + colour, + factor + ); + } + + public static void renderToolTip( + ItemStack stack, + int mouseX, + int mouseY, + int screenWidth, + int screenHeight, + FontRenderer fontStd + ) { + List list = stack.getTooltip( + Minecraft.getMinecraft().thePlayer, + Minecraft.getMinecraft().gameSettings.advancedItemTooltips + ); + + for (int i = 0; i < list.size(); ++i) { + if (i == 0) { + list.set(i, stack.getRarity().rarityColor + list.get(i)); + } else { + list.set(i, EnumChatFormatting.GRAY + list.get(i)); } - wrappedTextLines.add(line); - } } - tooltipTextWidth = wrappedTooltipWidth; - textLines = wrappedTextLines; - if (mouseX > screenWidth / 2) { - tooltipX = mouseX - 16 - tooltipTextWidth; - } else { - tooltipX = mouseX + 12; - } - } + FontRenderer font = stack.getItem().getFontRenderer(stack); + drawHoveringText( + list, + mouseX, + mouseY, + screenWidth, + screenHeight, + -1, + font == null ? fontStd : font + ); + } - int tooltipY = mouseY - 12; - int tooltipHeight = 8; + public static void drawHoveringText( + List textLines, + final int mouseX, + final int mouseY, + final int screenWidth, + final int screenHeight, + final int maxTextWidth, + FontRenderer font + ) { + if (!textLines.isEmpty()) { + GlStateManager.disableRescaleNormal(); + RenderHelper.disableStandardItemLighting(); + GlStateManager.disableLighting(); + GlStateManager.disableDepth(); + int tooltipTextWidth = 0; + + for (String textLine : textLines) { + int textLineWidth = font.getStringWidth(textLine); + + if (textLineWidth > tooltipTextWidth) { + tooltipTextWidth = textLineWidth; + } + } - if (textLines.size() > 1) { - tooltipHeight += (textLines.size() - 1) * 10; - if (textLines.size() > titleLinesCount) { - tooltipHeight += 2; // gap between title lines and next lines - } - } - - if (tooltipY + tooltipHeight + 6 > screenHeight) { - tooltipY = screenHeight - tooltipHeight - 6; - } - - final int zLevel = 300; - final int backgroundColor = 0xF0100010; - RenderUtils.drawGradientRect( - zLevel, - tooltipX - 3, - tooltipY - 4, - tooltipX + tooltipTextWidth + 3, - tooltipY - 3, - backgroundColor, - backgroundColor - ); - RenderUtils.drawGradientRect( - zLevel, - tooltipX - 3, - tooltipY + tooltipHeight + 3, - tooltipX + tooltipTextWidth + 3, - tooltipY + tooltipHeight + 4, - backgroundColor, - backgroundColor - ); - RenderUtils.drawGradientRect( - zLevel, - tooltipX - 3, - tooltipY - 3, - tooltipX + tooltipTextWidth + 3, - tooltipY + tooltipHeight + 3, - backgroundColor, - backgroundColor - ); - RenderUtils.drawGradientRect( - zLevel, - tooltipX - 4, - tooltipY - 3, - tooltipX - 3, - tooltipY + tooltipHeight + 3, - backgroundColor, - backgroundColor - ); - RenderUtils.drawGradientRect( - zLevel, - tooltipX + tooltipTextWidth + 3, - tooltipY - 3, - tooltipX + tooltipTextWidth + 4, - tooltipY + tooltipHeight + 3, - backgroundColor, - backgroundColor - ); - final int borderColorStart = 0x505000FF; - final int borderColorEnd = - (borderColorStart & 0xFEFEFE) >> 1 | borderColorStart & 0xFF000000; - RenderUtils.drawGradientRect( - zLevel, - tooltipX - 3, - tooltipY - 3 + 1, - tooltipX - 3 + 1, - tooltipY + tooltipHeight + 3 - 1, - borderColorStart, - borderColorEnd - ); - RenderUtils.drawGradientRect( - zLevel, - tooltipX + tooltipTextWidth + 2, - tooltipY - 3 + 1, - tooltipX + tooltipTextWidth + 3, - tooltipY + tooltipHeight + 3 - 1, - borderColorStart, - borderColorEnd - ); - RenderUtils.drawGradientRect( - zLevel, - tooltipX - 3, - tooltipY - 3, - tooltipX + tooltipTextWidth + 3, - tooltipY - 3 + 1, - borderColorStart, - borderColorStart - ); - RenderUtils.drawGradientRect( - zLevel, - tooltipX - 3, - tooltipY + tooltipHeight + 2, - tooltipX + tooltipTextWidth + 3, - tooltipY + tooltipHeight + 3, - borderColorEnd, - borderColorEnd - ); - - for (int lineNumber = 0; lineNumber < textLines.size(); ++lineNumber) { - String line = textLines.get(lineNumber); - font.drawStringWithShadow(line, (float) tooltipX, (float) tooltipY, -1); - - if (lineNumber + 1 == titleLinesCount) { - tooltipY += 2; - } + boolean needsWrap = false; + + int titleLinesCount = 1; + int tooltipX = mouseX + 12; + if (tooltipX + tooltipTextWidth + 4 > screenWidth) { + tooltipX = mouseX - 16 - tooltipTextWidth; + if (tooltipX < 4) { // if the tooltip doesn't fit on the screen + if (mouseX > screenWidth / 2) { + tooltipTextWidth = mouseX - 12 - 8; + } else { + tooltipTextWidth = screenWidth - 16 - mouseX; + } + needsWrap = true; + } + } + + if (maxTextWidth > 0 && tooltipTextWidth > maxTextWidth) { + tooltipTextWidth = maxTextWidth; + needsWrap = true; + } + + if (needsWrap) { + int wrappedTooltipWidth = 0; + List wrappedTextLines = new ArrayList(); + for (int i = 0; i < textLines.size(); i++) { + String textLine = textLines.get(i); + List wrappedLine = font.listFormattedStringToWidth( + textLine, + tooltipTextWidth + ); + if (i == 0) { + titleLinesCount = wrappedLine.size(); + } + + for (String line : wrappedLine) { + int lineWidth = font.getStringWidth(line); + if (lineWidth > wrappedTooltipWidth) { + wrappedTooltipWidth = lineWidth; + } + wrappedTextLines.add(line); + } + } + tooltipTextWidth = wrappedTooltipWidth; + textLines = wrappedTextLines; + + if (mouseX > screenWidth / 2) { + tooltipX = mouseX - 16 - tooltipTextWidth; + } else { + tooltipX = mouseX + 12; + } + } + + int tooltipY = mouseY - 12; + int tooltipHeight = 8; + + if (textLines.size() > 1) { + tooltipHeight += (textLines.size() - 1) * 10; + if (textLines.size() > titleLinesCount) { + tooltipHeight += 2; // gap between title lines and next lines + } + } - tooltipY += 10; - } + if (tooltipY + tooltipHeight + 6 > screenHeight) { + tooltipY = screenHeight - tooltipHeight - 6; + } + + final int zLevel = 300; + final int backgroundColor = 0xF0100010; + RenderUtils.drawGradientRect( + zLevel, + tooltipX - 3, + tooltipY - 4, + tooltipX + tooltipTextWidth + 3, + tooltipY - 3, + backgroundColor, + backgroundColor + ); + RenderUtils.drawGradientRect( + zLevel, + tooltipX - 3, + tooltipY + tooltipHeight + 3, + tooltipX + tooltipTextWidth + 3, + tooltipY + tooltipHeight + 4, + backgroundColor, + backgroundColor + ); + RenderUtils.drawGradientRect( + zLevel, + tooltipX - 3, + tooltipY - 3, + tooltipX + tooltipTextWidth + 3, + tooltipY + tooltipHeight + 3, + backgroundColor, + backgroundColor + ); + RenderUtils.drawGradientRect( + zLevel, + tooltipX - 4, + tooltipY - 3, + tooltipX - 3, + tooltipY + tooltipHeight + 3, + backgroundColor, + backgroundColor + ); + RenderUtils.drawGradientRect( + zLevel, + tooltipX + tooltipTextWidth + 3, + tooltipY - 3, + tooltipX + tooltipTextWidth + 4, + tooltipY + tooltipHeight + 3, + backgroundColor, + backgroundColor + ); + final int borderColorStart = 0x505000FF; + final int borderColorEnd = + (borderColorStart & 0xFEFEFE) >> 1 | + borderColorStart & + 0xFF000000; + RenderUtils.drawGradientRect( + zLevel, + tooltipX - 3, + tooltipY - 3 + 1, + tooltipX - 3 + 1, + tooltipY + tooltipHeight + 3 - 1, + borderColorStart, + borderColorEnd + ); + RenderUtils.drawGradientRect( + zLevel, + tooltipX + tooltipTextWidth + 2, + tooltipY - 3 + 1, + tooltipX + tooltipTextWidth + 3, + tooltipY + tooltipHeight + 3 - 1, + borderColorStart, + borderColorEnd + ); + RenderUtils.drawGradientRect( + zLevel, + tooltipX - 3, + tooltipY - 3, + tooltipX + tooltipTextWidth + 3, + tooltipY - 3 + 1, + borderColorStart, + borderColorStart + ); + RenderUtils.drawGradientRect( + zLevel, + tooltipX - 3, + tooltipY + tooltipHeight + 2, + tooltipX + tooltipTextWidth + 3, + tooltipY + tooltipHeight + 3, + borderColorEnd, + borderColorEnd + ); + + for ( + int lineNumber = 0; + lineNumber < textLines.size(); + ++lineNumber + ) { + String line = textLines.get(lineNumber); + font.drawStringWithShadow( + line, + (float) tooltipX, + (float) tooltipY, + -1 + ); + + if (lineNumber + 1 == titleLinesCount) { + tooltipY += 2; + } + + tooltipY += 10; + } - GlStateManager.enableLighting(); - GlStateManager.enableDepth(); - RenderHelper.enableStandardItemLighting(); - GlStateManager.enableRescaleNormal(); + GlStateManager.enableLighting(); + GlStateManager.enableDepth(); + RenderHelper.enableStandardItemLighting(); + GlStateManager.enableRescaleNormal(); + } + GlStateManager.disableLighting(); } - GlStateManager.disableLighting(); - } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/dungeons/Classes.java b/src/main/java/com/thatgravyboat/skyblockhud/dungeons/Classes.java index 1c30045..f0f58da 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/dungeons/Classes.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/dungeons/Classes.java @@ -1,50 +1,50 @@ package com.thatgravyboat.skyblockhud.dungeons; public enum Classes { - H("Healer", "H", 154), - M("Mage", "M", 90), - B("Berserk", "B", 122), - A("Archer", "A", 58), - T("Tank", "T", 186); + H("Healer", "H", 154), + M("Mage", "M", 90), + B("Berserk", "B", 122), + A("Archer", "A", 58), + T("Tank", "T", 186); - private final String displayName; - private final String classId; - private final int textureY; + private final String displayName; + private final String classId; + private final int textureY; - Classes(String name, String id, int textureY) { - this.displayName = name; - this.classId = id; - this.textureY = textureY; - } + Classes(String name, String id, int textureY) { + this.displayName = name; + this.classId = id; + this.textureY = textureY; + } - public String getDisplayName() { - return this.displayName; - } + public String getDisplayName() { + return this.displayName; + } - public String getClassId() { - return this.classId; - } + public String getClassId() { + return this.classId; + } - public int getTextureY() { - return this.textureY; - } + public int getTextureY() { + return this.textureY; + } - public static Classes findClass(String input) { - if (input.length() == 1) { - try { - return Classes.valueOf(input.toUpperCase()); - } catch (IllegalArgumentException ignored) {} - } else if (input.length() == 3) { - try { - return Classes.valueOf( - input.replace("[", "").replace("]", "").toUpperCase() - ); - } catch (IllegalArgumentException ignored) {} - } else { - for (Classes clazz : Classes.values()) { - if (clazz.displayName.equalsIgnoreCase(input)) return clazz; - } + public static Classes findClass(String input) { + if (input.length() == 1) { + try { + return Classes.valueOf(input.toUpperCase()); + } catch (IllegalArgumentException ignored) {} + } else if (input.length() == 3) { + try { + return Classes.valueOf( + input.replace("[", "").replace("]", "").toUpperCase() + ); + } catch (IllegalArgumentException ignored) {} + } else { + for (Classes clazz : Classes.values()) { + if (clazz.displayName.equalsIgnoreCase(input)) return clazz; + } + } + return B; } - return B; - } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/dungeons/DungeonHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/dungeons/DungeonHandler.java index 5307273..0c9cb2f 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/dungeons/DungeonHandler.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/dungeons/DungeonHandler.java @@ -13,225 +13,236 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; public class DungeonHandler { - private static final HashMap dungeonPlayersMap = new HashMap<>(); - private static int dungeonTime = 0; - private static int dungeonCleared = 0; - private static boolean bloodKey = false; - private static int witherKeys = 0; - private static int maxSecrets = 0; - private static int secrets = 0; - private static int totalSecrets = 0; - private static int deaths = 0; - private static int crypts = 0; - - private static final Pattern DungeonPlayerRegex = Pattern.compile( - "^\\[([HMBAT])] ([\\w]+) ([0-9]+|DEAD)$" - ); - - @SubscribeEvent - public void onSidebarLineUpdate(SidebarLineUpdateEvent event) { - if (LocationHandler.getCurrentLocation().equals(Locations.CATACOMBS)) { - DungeonHandler.checkForDungeonTime(event.formattedLine); - DungeonHandler.checkForDungeonCleared(event.formattedLine); - DungeonHandler.checkForDungeonKeys(event.formattedLine, event.rawLine); - DungeonHandler.checkForDungeonPlayers( - event.formattedLine, - Minecraft.getMinecraft() - ); - } - } - - @SubscribeEvent - public void onSidebarPost(SidebarPostEvent event) { - if (!LocationHandler.getCurrentLocation().equals(Locations.CATACOMBS)) { - DungeonHandler.clearDungeonStats(); - } - } - - public static void checkForDungeonPlayers(String scoreLine, Minecraft mc) { - Matcher dungeonMatcher = DungeonPlayerRegex.matcher(scoreLine); - if (dungeonMatcher.matches() && DungeonHandler.dungeonTime > 0) { - Classes playerClass = Classes.valueOf(dungeonMatcher.group(1)); - String displayName = dungeonMatcher.group(2); - String health = dungeonMatcher.group(3); - if ( - !mc.thePlayer - .getName() - .toLowerCase() - .startsWith(displayName.toLowerCase().trim()) - ) { - int healthNum = 0; - if (!health.equalsIgnoreCase("dead")) { - try { - healthNum = Integer.parseInt(health); - } catch (NumberFormatException ignored) {} + private static final HashMap dungeonPlayersMap = new HashMap<>(); + private static int dungeonTime = 0; + private static int dungeonCleared = 0; + private static boolean bloodKey = false; + private static int witherKeys = 0; + private static int maxSecrets = 0; + private static int secrets = 0; + private static int totalSecrets = 0; + private static int deaths = 0; + private static int crypts = 0; + + private static final Pattern DungeonPlayerRegex = Pattern.compile( + "^\\[([HMBAT])] ([\\w]+) ([0-9]+|DEAD)$" + ); + + @SubscribeEvent + public void onSidebarLineUpdate(SidebarLineUpdateEvent event) { + if (LocationHandler.getCurrentLocation().equals(Locations.CATACOMBS)) { + DungeonHandler.checkForDungeonTime(event.formattedLine); + DungeonHandler.checkForDungeonCleared(event.formattedLine); + DungeonHandler.checkForDungeonKeys( + event.formattedLine, + event.rawLine + ); + DungeonHandler.checkForDungeonPlayers( + event.formattedLine, + Minecraft.getMinecraft() + ); } - DungeonPlayer player = new DungeonPlayer( - playerClass, - displayName, - healthNum, - health.equalsIgnoreCase("dead") - ); - dungeonPlayersMap.put(displayName.toLowerCase(), player); - } - } - } - - public static void checkForDungeonTime(String scoreLine) { - if (scoreLine.toLowerCase().trim().contains("time elapsed:")) { - String timeLine = scoreLine - .toLowerCase() - .trim() - .replace("time elapsed:", ""); - String[] times = timeLine.split("m "); - int time = 0; - try { - time += - Integer.parseInt(times[0].replace(" ", "").replace("m", "")) * 60; - time += Integer.parseInt(times[1].replace(" ", "").replace("s", "")); - } catch (NumberFormatException ignored) {} - dungeonTime = time; - } - } - - public static void checkForDungeonCleared(String scoreline) { - if (scoreline.toLowerCase().trim().contains("dungeon cleared:")) { - String dungeonClearedText = scoreline - .toLowerCase() - .trim() - .replace("dungeon cleared:", "") - .replace(" ", "") - .replace("%", ""); - try { - dungeonCleared = Integer.parseInt(dungeonClearedText); - } catch (NumberFormatException ignored) {} - } - } - - public static void checkForDungeonKeys(String scoreline, String rawString) { - if (scoreline.toLowerCase().trim().contains("keys:")) { - String dungeonClearedText = scoreline - .toLowerCase() - .trim() - .replace("keys:", "") - .replace(" ", "") - .replace("x", ""); - bloodKey = rawString.contains("\u2713"); - try { - witherKeys = Integer.parseInt(dungeonClearedText); - } catch (NumberFormatException ignored) {} - } - } - - public static void parseSecrets(String statusBar) { - boolean hasSecrets = false; - String[] parts = statusBar.split(" {4,}"); - for (String part : parts) { - if ( - part.toLowerCase().contains("secrets") && - !statusBar.toLowerCase().contains("no secrets") - ) { - hasSecrets = true; - try { - String secret = Utils - .removeColor(part.replace("Secrets", "")) - .replace(" ", ""); - maxSecrets = Integer.parseInt(secret.split("/")[1]); - secrets = Integer.parseInt(secret.split("/")[0]); - } catch (NumberFormatException ignored) {} - } - } - if (!hasSecrets) { - maxSecrets = 0; - secrets = 0; - } - } - - public static void parseTotalSecrets(String playerName) { - if (playerName.toLowerCase().contains("secrets found:")) { - String totalSecret = Utils - .removeColor(playerName.toLowerCase().replace("secrets found:", "")) - .replace(" ", ""); - try { - totalSecrets = Integer.parseInt(totalSecret); - } catch (NumberFormatException ignored) {} - } - } - - public static void parseDeaths(String playerName) { - if (playerName.toLowerCase().contains("deaths:")) { - String death = Utils - .removeColor(playerName.toLowerCase().replace("deaths:", "")) - .replace("(", "") - .replace(")", "") - .replace(" ", ""); - try { - deaths = Integer.parseInt(death); - } catch (NumberFormatException ignored) {} - } - } - - public static void parseCrypts(String playerName) { - if (playerName.toLowerCase().contains("crypts:")) { - String crypt = Utils - .removeColor(playerName.toLowerCase().replace("crypts:", "")) - .replace(" ", ""); - try { - crypts = Integer.parseInt(crypt); - } catch (NumberFormatException ignored) {} - } - } - - public static void clearDungeonStats() { - dungeonPlayersMap.clear(); - dungeonTime = 0; - dungeonCleared = 0; - bloodKey = false; - witherKeys = 0; - maxSecrets = 0; - secrets = 0; - totalSecrets = 0; - deaths = 0; - crypts = 0; - } - - public static HashMap getDungeonPlayers() { - return dungeonPlayersMap; - } - - public static int getDungeonTime() { - return dungeonTime; - } - - public static int getDungeonCleared() { - return dungeonCleared; - } - - public static int getWitherKeys() { - return witherKeys; - } - - public static boolean hasBloodkey() { - return bloodKey; - } - - public static int getMaxSecrets() { - return maxSecrets; - } - - public static int getSecrets() { - return secrets; - } - - public static int getDeaths() { - return deaths; - } - - public static int getTotalSecrets() { - return totalSecrets; - } - - public static int getCrypts() { - return crypts; - } + } + + @SubscribeEvent + public void onSidebarPost(SidebarPostEvent event) { + if (!LocationHandler.getCurrentLocation().equals(Locations.CATACOMBS)) { + DungeonHandler.clearDungeonStats(); + } + } + + public static void checkForDungeonPlayers(String scoreLine, Minecraft mc) { + Matcher dungeonMatcher = DungeonPlayerRegex.matcher(scoreLine); + if (dungeonMatcher.matches() && DungeonHandler.dungeonTime > 0) { + Classes playerClass = Classes.valueOf(dungeonMatcher.group(1)); + String displayName = dungeonMatcher.group(2); + String health = dungeonMatcher.group(3); + if ( + !mc.thePlayer + .getName() + .toLowerCase() + .startsWith(displayName.toLowerCase().trim()) + ) { + int healthNum = 0; + if (!health.equalsIgnoreCase("dead")) { + try { + healthNum = Integer.parseInt(health); + } catch (NumberFormatException ignored) {} + } + DungeonPlayer player = new DungeonPlayer( + playerClass, + displayName, + healthNum, + health.equalsIgnoreCase("dead") + ); + dungeonPlayersMap.put(displayName.toLowerCase(), player); + } + } + } + + public static void checkForDungeonTime(String scoreLine) { + if (scoreLine.toLowerCase().trim().contains("time elapsed:")) { + String timeLine = scoreLine + .toLowerCase() + .trim() + .replace("time elapsed:", ""); + String[] times = timeLine.split("m "); + int time = 0; + try { + time += + Integer.parseInt( + times[0].replace(" ", "").replace("m", "") + ) * + 60; + time += + Integer.parseInt( + times[1].replace(" ", "").replace("s", "") + ); + } catch (NumberFormatException ignored) {} + dungeonTime = time; + } + } + + public static void checkForDungeonCleared(String scoreline) { + if (scoreline.toLowerCase().trim().contains("dungeon cleared:")) { + String dungeonClearedText = scoreline + .toLowerCase() + .trim() + .replace("dungeon cleared:", "") + .replace(" ", "") + .replace("%", ""); + try { + dungeonCleared = Integer.parseInt(dungeonClearedText); + } catch (NumberFormatException ignored) {} + } + } + + public static void checkForDungeonKeys(String scoreline, String rawString) { + if (scoreline.toLowerCase().trim().contains("keys:")) { + String dungeonClearedText = scoreline + .toLowerCase() + .trim() + .replace("keys:", "") + .replace(" ", "") + .replace("x", ""); + bloodKey = rawString.contains("\u2713"); + try { + witherKeys = Integer.parseInt(dungeonClearedText); + } catch (NumberFormatException ignored) {} + } + } + + public static void parseSecrets(String statusBar) { + boolean hasSecrets = false; + String[] parts = statusBar.split(" {4,}"); + for (String part : parts) { + if ( + part.toLowerCase().contains("secrets") && + !statusBar.toLowerCase().contains("no secrets") + ) { + hasSecrets = true; + try { + String secret = Utils + .removeColor(part.replace("Secrets", "")) + .replace(" ", ""); + maxSecrets = Integer.parseInt(secret.split("/")[1]); + secrets = Integer.parseInt(secret.split("/")[0]); + } catch (NumberFormatException ignored) {} + } + } + if (!hasSecrets) { + maxSecrets = 0; + secrets = 0; + } + } + + public static void parseTotalSecrets(String playerName) { + if (playerName.toLowerCase().contains("secrets found:")) { + String totalSecret = Utils + .removeColor( + playerName.toLowerCase().replace("secrets found:", "") + ) + .replace(" ", ""); + try { + totalSecrets = Integer.parseInt(totalSecret); + } catch (NumberFormatException ignored) {} + } + } + + public static void parseDeaths(String playerName) { + if (playerName.toLowerCase().contains("deaths:")) { + String death = Utils + .removeColor(playerName.toLowerCase().replace("deaths:", "")) + .replace("(", "") + .replace(")", "") + .replace(" ", ""); + try { + deaths = Integer.parseInt(death); + } catch (NumberFormatException ignored) {} + } + } + + public static void parseCrypts(String playerName) { + if (playerName.toLowerCase().contains("crypts:")) { + String crypt = Utils + .removeColor(playerName.toLowerCase().replace("crypts:", "")) + .replace(" ", ""); + try { + crypts = Integer.parseInt(crypt); + } catch (NumberFormatException ignored) {} + } + } + + public static void clearDungeonStats() { + dungeonPlayersMap.clear(); + dungeonTime = 0; + dungeonCleared = 0; + bloodKey = false; + witherKeys = 0; + maxSecrets = 0; + secrets = 0; + totalSecrets = 0; + deaths = 0; + crypts = 0; + } + + public static HashMap getDungeonPlayers() { + return dungeonPlayersMap; + } + + public static int getDungeonTime() { + return dungeonTime; + } + + public static int getDungeonCleared() { + return dungeonCleared; + } + + public static int getWitherKeys() { + return witherKeys; + } + + public static boolean hasBloodkey() { + return bloodKey; + } + + public static int getMaxSecrets() { + return maxSecrets; + } + + public static int getSecrets() { + return secrets; + } + + public static int getDeaths() { + return deaths; + } + + public static int getTotalSecrets() { + return totalSecrets; + } + + public static int getCrypts() { + return crypts; + } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/dungeons/DungeonPlayer.java b/src/main/java/com/thatgravyboat/skyblockhud/dungeons/DungeonPlayer.java index 2326090..f517655 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/dungeons/DungeonPlayer.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/dungeons/DungeonPlayer.java @@ -2,36 +2,36 @@ package com.thatgravyboat.skyblockhud.dungeons; public class DungeonPlayer { - private final Classes dungeonClass; - private final String name; - private final int health; - private final boolean dead; + private final Classes dungeonClass; + private final String name; + private final int health; + private final boolean dead; - public DungeonPlayer( - Classes playersClass, - String playersName, - int playersHealth, - boolean isDead - ) { - this.dungeonClass = playersClass; - this.name = playersName; - this.health = isDead ? 0 : playersHealth; - this.dead = isDead; - } + public DungeonPlayer( + Classes playersClass, + String playersName, + int playersHealth, + boolean isDead + ) { + this.dungeonClass = playersClass; + this.name = playersName; + this.health = isDead ? 0 : playersHealth; + this.dead = isDead; + } - public Classes getDungeonClass() { - return this.dungeonClass; - } + public Classes getDungeonClass() { + return this.dungeonClass; + } - public String getName() { - return this.name; - } + public String getName() { + return this.name; + } - public int getHealth() { - return this.dead ? 0 : this.health; - } + public int getHealth() { + return this.dead ? 0 : this.health; + } - public boolean isDead() { - return this.dead; - } + public boolean isDead() { + return this.dead; + } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/handlers/BossbarHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/handlers/BossbarHandler.java index 16ff63f..0338195 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/handlers/BossbarHandler.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/handlers/BossbarHandler.java @@ -12,33 +12,36 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; public class BossbarHandler { - public static boolean bossBarRendered = true; + public static boolean bossBarRendered = true; - @SubscribeEvent(priority = EventPriority.LOWEST) - public void onBossbarRender(RenderGameOverlayEvent.Pre event) { - if ( - event.type == RenderGameOverlayEvent.ElementType.BOSSHEALTH && - BossStatus.bossName != null - ) { - bossBarRendered = !event.isCanceled(); - if (!SkyblockHud.config.main.bossShiftHud) { - bossBarRendered = false; - } - String bossName = Utils.removeColor(BossStatus.bossName); - if ( - SkyblockHud.config.renderer.hideBossBar && - DwarvenMineHandler.currentEvent == DwarvenMineHandler.Event.NONE && - !LocationHandler.getCurrentLocation().equals(Locations.CATACOMBS) - ) { - if (bossName.equalsIgnoreCase("wither")) { - event.setCanceled(true); - bossBarRendered = false; + @SubscribeEvent(priority = EventPriority.LOWEST) + public void onBossbarRender(RenderGameOverlayEvent.Pre event) { + if ( + event.type == RenderGameOverlayEvent.ElementType.BOSSHEALTH && + BossStatus.bossName != null + ) { + bossBarRendered = !event.isCanceled(); + if (!SkyblockHud.config.main.bossShiftHud) { + bossBarRendered = false; + } + String bossName = Utils.removeColor(BossStatus.bossName); + if ( + SkyblockHud.config.renderer.hideBossBar && + DwarvenMineHandler.currentEvent == + DwarvenMineHandler.Event.NONE && + !LocationHandler + .getCurrentLocation() + .equals(Locations.CATACOMBS) + ) { + if (bossName.equalsIgnoreCase("wither")) { + event.setCanceled(true); + bossBarRendered = false; + } + if (bossName.toLowerCase().startsWith("objective:")) { + event.setCanceled(true); + bossBarRendered = false; + } + } } - if (bossName.toLowerCase().startsWith("objective:")) { - event.setCanceled(true); - bossBarRendered = false; - } - } } - } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/handlers/CurrencyHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/handlers/CurrencyHandler.java index f8c6b86..ea0ccca 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/handlers/CurrencyHandler.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/handlers/CurrencyHandler.java @@ -13,120 +13,124 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; public class CurrencyHandler { - private static int bits = 0; - private static double coins = 0; + private static int bits = 0; + private static double coins = 0; - public static void setBits(int amount) { - bits = amount; - } - - public static void setCoins(double amount) { - coins = amount; - } - - public static int getBits() { - return bits; - } - - public static double getCoins() { - return coins; - } + public static void setBits(int amount) { + bits = amount; + } - @SubscribeEvent - public void onSidebarLineUpdate(SidebarLineUpdateEvent event) { - if ( - Utils - .removeColor(event.formattedLine.toLowerCase().trim()) - .contains("purse:") || - Utils - .removeColor(event.formattedLine.toLowerCase().trim()) - .contains("piggy:") - ) { - CurrencyHandler.checkCoins(event.formattedLine); + public static void setCoins(double amount) { + coins = amount; } - if ( - Utils - .removeColor(event.formattedLine.toLowerCase().trim()) - .contains("bits:") && - !event.formattedLine.toLowerCase().contains("(") - ) { - CurrencyHandler.checkBits(event.formattedLine); + + public static int getBits() { + return bits; } - } - @SubscribeEvent - public void onSidebarPost(SidebarPostEvent event) { - if (!Arrays.toString(event.arrayScores).toLowerCase().contains("bits:")) { - CurrencyHandler.setBits(0); + public static double getCoins() { + return coins; } - } - public static String getCoinsFormatted() { - DecimalFormat formatter = new DecimalFormat( - "#,###.0", - DecimalFormatSymbols.getInstance(Locale.CANADA) - ); - String output = formatter.format(coins); - if (output.equals(".0")) output = "0.0"; else if ( - output.equals(",0") - ) output = "0,0"; - return output; - } + @SubscribeEvent + public void onSidebarLineUpdate(SidebarLineUpdateEvent event) { + if ( + Utils + .removeColor(event.formattedLine.toLowerCase().trim()) + .contains("purse:") || + Utils + .removeColor(event.formattedLine.toLowerCase().trim()) + .contains("piggy:") + ) { + CurrencyHandler.checkCoins(event.formattedLine); + } + if ( + Utils + .removeColor(event.formattedLine.toLowerCase().trim()) + .contains("bits:") && + !event.formattedLine.toLowerCase().contains("(") + ) { + CurrencyHandler.checkBits(event.formattedLine); + } + } - public static String getBitsFormatted() { - DecimalFormat formatter = new DecimalFormat( - "#.#", - DecimalFormatSymbols.getInstance(Locale.CANADA) - ); - formatter.setRoundingMode(RoundingMode.FLOOR); - return bits > 999 - ? formatter.format((double) bits / 1000) + "k" - : String.valueOf(bits); - } + @SubscribeEvent + public void onSidebarPost(SidebarPostEvent event) { + if ( + !Arrays.toString(event.arrayScores).toLowerCase().contains("bits:") + ) { + CurrencyHandler.setBits(0); + } + } - public static void checkCoins(String formatedScoreboardLine) { - String purse = Utils - .removeWhiteSpaceAndRemoveWord( - Utils.removeColor(formatedScoreboardLine.toLowerCase().trim()), - Utils - .removeColor(formatedScoreboardLine.toLowerCase().trim()) - .contains("purse:") - ? "purse:" - : "piggy:" - ) - .replace(",", ""); - if (!purse.contains("(") && !purse.contains("+")) { - try { - double coins = Double.parseDouble( - Pattern.compile("[^0-9.]").matcher(purse).replaceAll("") + public static String getCoinsFormatted() { + DecimalFormat formatter = new DecimalFormat( + "#,###.0", + DecimalFormatSymbols.getInstance(Locale.CANADA) ); - CurrencyHandler.setCoins(coins); - } catch (IllegalArgumentException ex) { - System.out.println( - "Failed to parse purse, please report to ThatGravyBoat. Purse Text: " + - purse + String output = formatter.format(coins); + if (output.equals(".0")) output = "0.0"; else if ( + output.equals(",0") + ) output = "0,0"; + return output; + } + + public static String getBitsFormatted() { + DecimalFormat formatter = new DecimalFormat( + "#.#", + DecimalFormatSymbols.getInstance(Locale.CANADA) ); - } + formatter.setRoundingMode(RoundingMode.FLOOR); + return bits > 999 + ? formatter.format((double) bits / 1000) + "k" + : String.valueOf(bits); + } + + public static void checkCoins(String formatedScoreboardLine) { + String purse = Utils + .removeWhiteSpaceAndRemoveWord( + Utils.removeColor(formatedScoreboardLine.toLowerCase().trim()), + Utils + .removeColor( + formatedScoreboardLine.toLowerCase().trim() + ) + .contains("purse:") + ? "purse:" + : "piggy:" + ) + .replace(",", ""); + if (!purse.contains("(") && !purse.contains("+")) { + try { + double coins = Double.parseDouble( + Pattern.compile("[^0-9.]").matcher(purse).replaceAll("") + ); + CurrencyHandler.setCoins(coins); + } catch (IllegalArgumentException ex) { + System.out.println( + "Failed to parse purse, please report to ThatGravyBoat. Purse Text: " + + purse + ); + } + } } - } - public static void checkBits(String formatedScoreboardLine) { - String bits = Utils - .removeWhiteSpaceAndRemoveWord( - Utils.removeColor(formatedScoreboardLine.toLowerCase().trim()), - "bits:" - ) - .replace(",", ""); - try { - int bit = Integer.parseInt( - Pattern.compile("[^0-9]").matcher(bits).replaceAll("") - ); - CurrencyHandler.setBits(bit); - } catch (IllegalArgumentException ex) { - System.out.println( - "Failed to parse bits, please report to ThatGravyBoat. Bits Text: " + - bits - ); + public static void checkBits(String formatedScoreboardLine) { + String bits = Utils + .removeWhiteSpaceAndRemoveWord( + Utils.removeColor(formatedScoreboardLine.toLowerCase().trim()), + "bits:" + ) + .replace(",", ""); + try { + int bit = Integer.parseInt( + Pattern.compile("[^0-9]").matcher(bits).replaceAll("") + ); + CurrencyHandler.setBits(bit); + } catch (IllegalArgumentException ex) { + System.out.println( + "Failed to parse bits, please report to ThatGravyBoat. Bits Text: " + + bits + ); + } } - } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/handlers/HeldItemHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/handlers/HeldItemHandler.java index 8211f0f..e7686d2 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/handlers/HeldItemHandler.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/handlers/HeldItemHandler.java @@ -12,50 +12,54 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; public class HeldItemHandler extends Gui { - public void drawFuelBar(Minecraft mc, int current, int max) { - GenericOverlays.drawSmallBar( - mc, - 100, - 100, - (double) current / (double) max, - 1.0d, - 0xff00ff, - 0xffff00, - 0 - ); - drawString( - mc.fontRendererObj, - "Fuel - " + Math.round(((double) current / (double) max) * 100) + "%", - 100, - 100, - 0xffffff - ); - } + public void drawFuelBar(Minecraft mc, int current, int max) { + GenericOverlays.drawSmallBar( + mc, + 100, + 100, + (double) current / (double) max, + 1.0d, + 0xff00ff, + 0xffff00, + 0 + ); + drawString( + mc.fontRendererObj, + "Fuel - " + + Math.round(((double) current / (double) max) * 100) + + "%", + 100, + 100, + 0xffffff + ); + } - public boolean isDrill(ItemStack stack) { - if (stack == null) return false; - if (!stack.getTagCompound().hasKey("ExtraAttributes")) return false; - return stack - .getTagCompound() - .getCompoundTag("ExtraAttributes") - .hasKey("drill_fuel"); - } + public boolean isDrill(ItemStack stack) { + if (stack == null) return false; + if (!stack.getTagCompound().hasKey("ExtraAttributes")) return false; + return stack + .getTagCompound() + .getCompoundTag("ExtraAttributes") + .hasKey("drill_fuel"); + } - public String getDrillFuel(ItemStack stack) { - NBTTagCompound display = stack.getTagCompound().getCompoundTag("display"); - NBTTagList lore = display.getTagList("Lore", 8); - for (int i = lore.tagCount() - 1; i >= 0; i--) { - String line = Utils.removeColor(lore.getStringTagAt(i)); - if (line.trim().startsWith("Fuel:")) { - return line; - } + public String getDrillFuel(ItemStack stack) { + NBTTagCompound display = stack + .getTagCompound() + .getCompoundTag("display"); + NBTTagList lore = display.getTagList("Lore", 8); + for (int i = lore.tagCount() - 1; i >= 0; i--) { + String line = Utils.removeColor(lore.getStringTagAt(i)); + if (line.trim().startsWith("Fuel:")) { + return line; + } + } + return ""; } - return ""; - } - @SubscribeEvent - public void drawOverlay(RenderGameOverlayEvent.Post event) { - /* + @SubscribeEvent + public void drawOverlay(RenderGameOverlayEvent.Post event) { + /* if (Utils.overlayShouldRender(event.type, SkyblockHud.hasSkyblockScoreboard())){ Minecraft mc = Minecraft.getMinecraft(); ItemStack stack = mc.thePlayer.getHeldItem(); @@ -72,5 +76,5 @@ public class HeldItemHandler extends Gui { } } */ - } + } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/handlers/MapHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/handlers/MapHandler.java index bb2b492..ab618af 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/handlers/MapHandler.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/handlers/MapHandler.java @@ -28,426 +28,457 @@ import org.lwjgl.opengl.GL11; public class MapHandler { - public enum MapIconTypes { - SHOPS, - MISC, - NPC, - INFO, - QUEST - } + public enum MapIconTypes { + SHOPS, + MISC, + NPC, + INFO, + QUEST + } - public static class MapIcon { + public static class MapIcon { - public Vector2f position; - public ResourceLocation icon; - public String tooltip; - public String command; - public MapIconTypes type; + public Vector2f position; + public ResourceLocation icon; + public String tooltip; + public String command; + public MapIconTypes type; - public MapIcon( - Vector2f pos, - ResourceLocation icon, - String tooltip, - MapIconTypes type - ) { - this(pos, icon, tooltip, type, ""); - } + public MapIcon( + Vector2f pos, + ResourceLocation icon, + String tooltip, + MapIconTypes type + ) { + this(pos, icon, tooltip, type, ""); + } - public MapIcon( - Vector2f pos, - ResourceLocation icon, - String tooltip, - MapIconTypes type, - String command - ) { - this.position = pos; - this.icon = icon; - this.tooltip = tooltip; - this.type = type; - this.command = command; - } + public MapIcon( + Vector2f pos, + ResourceLocation icon, + String tooltip, + MapIconTypes type, + String command + ) { + this.position = pos; + this.icon = icon; + this.tooltip = tooltip; + this.type = type; + this.command = command; + } - public boolean canRender() { - SBHConfig.Map mapConfig = SkyblockHud.config.map; - if ( - mapConfig.showInfoIcons && type.equals(MapIconTypes.INFO) - ) return true; else if ( - mapConfig.showMiscIcons && type.equals(MapIconTypes.MISC) - ) return true; else if ( - mapConfig.showNpcIcons && type.equals(MapIconTypes.NPC) - ) return true; else if ( - mapConfig.showQuestIcons && type.equals(MapIconTypes.QUEST) - ) return true; else return ( - mapConfig.showShopIcons && type.equals(MapIconTypes.SHOPS) - ); + public boolean canRender() { + SBHConfig.Map mapConfig = SkyblockHud.config.map; + if ( + mapConfig.showInfoIcons && type.equals(MapIconTypes.INFO) + ) return true; else if ( + mapConfig.showMiscIcons && type.equals(MapIconTypes.MISC) + ) return true; else if ( + mapConfig.showNpcIcons && type.equals(MapIconTypes.NPC) + ) return true; else if ( + mapConfig.showQuestIcons && type.equals(MapIconTypes.QUEST) + ) return true; else return ( + mapConfig.showShopIcons && type.equals(MapIconTypes.SHOPS) + ); + } } - } - public enum Maps { - HUB( - 0.5f, - 494, - 444, - 294, - 218, - 294, - 224, - new ResourceLocation("skyblockhud", "maps/hub.png"), - HubIcons.hubIcons - ), - MUSHROOM( - 1.0f, - 318, - 316, - -84, - 605, - -84, - 612, - new ResourceLocation("skyblockhud", "maps/mushroom.png"), - Collections.emptyList() - ), - SPIDERS( - 1.0f, - 270, - 238, - 400, - 362, - 400, - 364, - new ResourceLocation("skyblockhud", "maps/spidersden.png"), - Collections.emptyList() - ), - NETHER( - 0.5f, - 257, - 371, - 436, - 732, - 433, - 736, - new ResourceLocation("skyblockhud", "maps/fort.png"), - Collections.emptyList() - ), - BARN( - 1.5f, - 135, - 130, - -82, - 320, - -81, - 318, - new ResourceLocation("skyblockhud", "maps/barn.png"), - Collections.emptyList() - ), - DWARVEN( - 0.5f, - 409, - 461, - 206, - 160, - 202, - 166, - new ResourceLocation("skyblockhud", "maps/dwarven.png"), - DwarvenIcons.dwarvenIcons - ), - PARK( - 1.0f, - 211, - 230, - 480, - 133, - 478, - 134, - new ResourceLocation("skyblockhud", "maps/park.png"), - Collections.emptyList() - ); + public enum Maps { + HUB( + 0.5f, + 494, + 444, + 294, + 218, + 294, + 224, + new ResourceLocation("skyblockhud", "maps/hub.png"), + HubIcons.hubIcons + ), + MUSHROOM( + 1.0f, + 318, + 316, + -84, + 605, + -84, + 612, + new ResourceLocation("skyblockhud", "maps/mushroom.png"), + Collections.emptyList() + ), + SPIDERS( + 1.0f, + 270, + 238, + 400, + 362, + 400, + 364, + new ResourceLocation("skyblockhud", "maps/spidersden.png"), + Collections.emptyList() + ), + NETHER( + 0.5f, + 257, + 371, + 436, + 732, + 433, + 736, + new ResourceLocation("skyblockhud", "maps/fort.png"), + Collections.emptyList() + ), + BARN( + 1.5f, + 135, + 130, + -82, + 320, + -81, + 318, + new ResourceLocation("skyblockhud", "maps/barn.png"), + Collections.emptyList() + ), + DWARVEN( + 0.5f, + 409, + 461, + 206, + 160, + 202, + 166, + new ResourceLocation("skyblockhud", "maps/dwarven.png"), + DwarvenIcons.dwarvenIcons + ), + PARK( + 1.0f, + 211, + 230, + 480, + 133, + 478, + 134, + new ResourceLocation("skyblockhud", "maps/park.png"), + Collections.emptyList() + ); - public float scaleFactor; - public int width; - public int height; - public int xMiniOffset; - public int yMiniOffset; - public int xOffset; - public int yOffset; - public ResourceLocation mapTexture; - public List icons; + public float scaleFactor; + public int width; + public int height; + public int xMiniOffset; + public int yMiniOffset; + public int xOffset; + public int yOffset; + public ResourceLocation mapTexture; + public List icons; - Maps( - float scaleFactor, - int width, - int height, - int xMiniOffset, - int yMiniOffset, - int xOffset, - int yOffset, - ResourceLocation mapTexture, - List icons - ) { - this.scaleFactor = scaleFactor; - this.width = width; - this.height = height; - this.xMiniOffset = xMiniOffset; - this.yMiniOffset = yMiniOffset; - this.xOffset = xOffset; - this.yOffset = yOffset; - this.mapTexture = mapTexture; - this.icons = icons; + Maps( + float scaleFactor, + int width, + int height, + int xMiniOffset, + int yMiniOffset, + int xOffset, + int yOffset, + ResourceLocation mapTexture, + List icons + ) { + this.scaleFactor = scaleFactor; + this.width = width; + this.height = height; + this.xMiniOffset = xMiniOffset; + this.yMiniOffset = yMiniOffset; + this.xOffset = xOffset; + this.yOffset = yOffset; + this.mapTexture = mapTexture; + this.icons = icons; + } } - } - @SubscribeEvent - public void renderOverlay(RenderGameOverlayEvent.Post event) { - if ( - Utils.overlayShouldRender( - event.type, - SkyblockHud.hasSkyblockScoreboard(), - SkyblockHud.config.map.showMiniMap - ) - ) { - Minecraft mc = Minecraft.getMinecraft(); - if (mc.currentScreen instanceof MapScreen) return; - if ( - LocationHandler.getCurrentLocation().getCategory().getMap() == null - ) return; - if (mc.thePlayer != null) { - MapHandler.Maps map = LocationHandler - .getCurrentLocation() - .getCategory() - .getMap(); - mc.renderEngine.bindTexture(mapOverlay); - GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f); - Position pos = SkyblockHud.config.map.miniMapPosition; - Gui.drawModalRectWithCustomSizedTexture( - pos.getAbsX(event.resolution, 72), - pos.getAbsY(event.resolution, 72), - 72, - 0, - 72, - 72, - 256, - 256 - ); - mc.renderEngine.bindTexture(map.mapTexture); + @SubscribeEvent + public void renderOverlay(RenderGameOverlayEvent.Post event) { + if ( + Utils.overlayShouldRender( + event.type, + SkyblockHud.hasSkyblockScoreboard(), + SkyblockHud.config.map.showMiniMap + ) + ) { + Minecraft mc = Minecraft.getMinecraft(); + if (mc.currentScreen instanceof MapScreen) return; + if ( + LocationHandler.getCurrentLocation().getCategory().getMap() == + null + ) return; + if (mc.thePlayer != null) { + MapHandler.Maps map = LocationHandler + .getCurrentLocation() + .getCategory() + .getMap(); + mc.renderEngine.bindTexture(mapOverlay); + GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f); + Position pos = SkyblockHud.config.map.miniMapPosition; + Gui.drawModalRectWithCustomSizedTexture( + pos.getAbsX(event.resolution, 72), + pos.getAbsY(event.resolution, 72), + 72, + 0, + 72, + 72, + 256, + 256 + ); + mc.renderEngine.bindTexture(map.mapTexture); - int x = mc.thePlayer.getPosition().getX() + map.xMiniOffset; - int z = mc.thePlayer.getPosition().getZ() + map.yMiniOffset; - float u = (x / (map.width / 256f)) - 33f; - float v = (z / (map.height / 256f)) - 28f; + int x = mc.thePlayer.getPosition().getX() + map.xMiniOffset; + int z = mc.thePlayer.getPosition().getZ() + map.yMiniOffset; + float u = (x / (map.width / 256f)) - 33f; + float v = (z / (map.height / 256f)) - 28f; - GL11.glTexParameteri( - GL11.GL_TEXTURE_2D, - GL11.GL_TEXTURE_WRAP_S, - GL11.GL_CLAMP - ); - GL11.glTexParameteri( - GL11.GL_TEXTURE_2D, - GL11.GL_TEXTURE_WRAP_T, - GL11.GL_CLAMP - ); + GL11.glTexParameteri( + GL11.GL_TEXTURE_2D, + GL11.GL_TEXTURE_WRAP_S, + GL11.GL_CLAMP + ); + GL11.glTexParameteri( + GL11.GL_TEXTURE_2D, + GL11.GL_TEXTURE_WRAP_T, + GL11.GL_CLAMP + ); - Gui.drawModalRectWithCustomSizedTexture( - pos.getAbsX(event.resolution, 72) + 4, - pos.getAbsY(event.resolution, 72) + 2, - u, - v, - 64, - 64, - 256, - 256 - ); + Gui.drawModalRectWithCustomSizedTexture( + pos.getAbsX(event.resolution, 72) + 4, + pos.getAbsY(event.resolution, 72) + 2, + u, + v, + 64, + 64, + 256, + 256 + ); - if (SkyblockHud.config.map.showPlayerLocation) { - mc.fontRendererObj.drawString( - "\u2022", - pos.getAbsX(event.resolution, 72) + 36, - pos.getAbsY(event.resolution, 72) + 34, - 0xff0000, - false - ); - } + if (SkyblockHud.config.map.showPlayerLocation) { + mc.fontRendererObj.drawString( + "\u2022", + pos.getAbsX(event.resolution, 72) + 36, + pos.getAbsY(event.resolution, 72) + 34, + 0xff0000, + false + ); + } - GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f); - mc.renderEngine.bindTexture(mapOverlay); - Gui.drawModalRectWithCustomSizedTexture( - pos.getAbsX(event.resolution, 72), - pos.getAbsY(event.resolution, 72), - 0, - 0, - 72, - 72, - 256, - 256 - ); - String keyCode = GameSettings.getKeyDisplayString( - KeyBindings.map.getKeyCode() - ); - Utils.drawStringCenteredScaled( - keyCode, - mc.fontRendererObj, - pos.getAbsX(event.resolution, 64) + 58, - pos.getAbsY(event.resolution, 72) + 66, - false, - 6, - 0xFFFFFF - ); - BlockPos playerPos = mc.thePlayer.getPosition(); - String position = String.format( - "%d/%d/%d", - playerPos.getX(), - playerPos.getY(), - playerPos.getZ() - ); - Utils.drawStringCenteredScaled( - position, - mc.fontRendererObj, - pos.getAbsX(event.resolution, 64) + 29, - pos.getAbsY(event.resolution, 72) + 66, - false, - 36, - 0xFFFFFF - ); - GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f); - } + GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f); + mc.renderEngine.bindTexture(mapOverlay); + Gui.drawModalRectWithCustomSizedTexture( + pos.getAbsX(event.resolution, 72), + pos.getAbsY(event.resolution, 72), + 0, + 0, + 72, + 72, + 256, + 256 + ); + String keyCode = GameSettings.getKeyDisplayString( + KeyBindings.map.getKeyCode() + ); + Utils.drawStringCenteredScaled( + keyCode, + mc.fontRendererObj, + pos.getAbsX(event.resolution, 64) + 58, + pos.getAbsY(event.resolution, 72) + 66, + false, + 6, + 0xFFFFFF + ); + BlockPos playerPos = mc.thePlayer.getPosition(); + String position = String.format( + "%d/%d/%d", + playerPos.getX(), + playerPos.getY(), + playerPos.getZ() + ); + Utils.drawStringCenteredScaled( + position, + mc.fontRendererObj, + pos.getAbsX(event.resolution, 64) + 29, + pos.getAbsY(event.resolution, 72) + 66, + false, + 36, + 0xFFFFFF + ); + GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f); + } + } } - } - @SubscribeEvent - public void clientTick(TickEvent.ClientTickEvent event) { - if ( - KeyBindings.map.isPressed() && - LocationHandler.getCurrentLocation().getCategory().getMap() != null && - SkyblockHud.hasSkyblockScoreboard() - ) SkyblockHud.screenToOpen = new MapScreen(); - } + @SubscribeEvent + public void clientTick(TickEvent.ClientTickEvent event) { + if ( + KeyBindings.map.isPressed() && + LocationHandler.getCurrentLocation().getCategory().getMap() != + null && + SkyblockHud.hasSkyblockScoreboard() + ) SkyblockHud.screenToOpen = new MapScreen(); + } - public static class MapScreen extends GuiScreen { + public static class MapScreen extends GuiScreen { - public MapHandler.Maps map = LocationHandler - .getCurrentLocation() - .getCategory() - .getMap(); + public MapHandler.Maps map = LocationHandler + .getCurrentLocation() + .getCategory() + .getMap(); - @Override - public void drawScreen(int mouseX, int mouseY, float partialTicks) { - GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f); - this.drawWorldBackground(0); - this.mc.renderEngine.bindTexture(map.mapTexture); - float mapX = (width / 2f) - ((map.width / 2f) * map.scaleFactor); - float mapY = (height / 2f) - ((map.height / 2f) * map.scaleFactor); - Gui.drawModalRectWithCustomSizedTexture( - (int) mapX, - (int) mapY, - 0, - 0, - (int) (map.width * map.scaleFactor), - (int) (map.height * map.scaleFactor), - (int) (map.width * map.scaleFactor), - (int) (map.height * map.scaleFactor) - ); - drawIcons((int) mapX, (int) mapY); - if ( - this.mc.thePlayer != null && SkyblockHud.config.map.showPlayerLocation - ) { - int x = this.mc.thePlayer.getPosition().getX() + map.xOffset; - int z = this.mc.thePlayer.getPosition().getZ() + map.yOffset; - fontRendererObj.drawString( - "\u2022", - (int) (x * map.scaleFactor + mapX), - (int) (z * map.scaleFactor + mapY), - 0xff0000 - ); - } - GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f); - onTooltip(mouseX, mouseY, (int) mapX, (int) mapY); - } + @Override + public void drawScreen(int mouseX, int mouseY, float partialTicks) { + GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f); + this.drawWorldBackground(0); + this.mc.renderEngine.bindTexture(map.mapTexture); + float mapX = (width / 2f) - ((map.width / 2f) * map.scaleFactor); + float mapY = (height / 2f) - ((map.height / 2f) * map.scaleFactor); + Gui.drawModalRectWithCustomSizedTexture( + (int) mapX, + (int) mapY, + 0, + 0, + (int) (map.width * map.scaleFactor), + (int) (map.height * map.scaleFactor), + (int) (map.width * map.scaleFactor), + (int) (map.height * map.scaleFactor) + ); + drawIcons((int) mapX, (int) mapY); + if ( + this.mc.thePlayer != null && + SkyblockHud.config.map.showPlayerLocation + ) { + int x = this.mc.thePlayer.getPosition().getX() + map.xOffset; + int z = this.mc.thePlayer.getPosition().getZ() + map.yOffset; + fontRendererObj.drawString( + "\u2022", + (int) (x * map.scaleFactor + mapX), + (int) (z * map.scaleFactor + mapY), + 0xff0000 + ); + } + GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f); + onTooltip(mouseX, mouseY, (int) mapX, (int) mapY); + } - public void drawIcons(int startX, int startY) { - if (map.icons == null) return; - for (MapIcon icon : map.icons) { - if (!icon.canRender()) continue; - GlStateManager.enableBlend(); - GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f); - this.mc.renderEngine.bindTexture(icon.icon); - float x = - ((icon.position.x + map.xOffset) * map.scaleFactor) + startX - 4; - float y = - ((icon.position.y + map.yOffset) * map.scaleFactor) + startY - 4; - Gui.drawModalRectWithCustomSizedTexture( - (int) x, - (int) y, - 0, - 0, - 8, - 8, - 8, - 8 - ); - GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f); - } - } + public void drawIcons(int startX, int startY) { + if (map.icons == null) return; + for (MapIcon icon : map.icons) { + if (!icon.canRender()) continue; + GlStateManager.enableBlend(); + GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f); + this.mc.renderEngine.bindTexture(icon.icon); + float x = + ((icon.position.x + map.xOffset) * map.scaleFactor) + + startX - + 4; + float y = + ((icon.position.y + map.yOffset) * map.scaleFactor) + + startY - + 4; + Gui.drawModalRectWithCustomSizedTexture( + (int) x, + (int) y, + 0, + 0, + 8, + 8, + 8, + 8 + ); + GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f); + } + } - public void onTooltip(int mouseX, int mouseY, int startX, int startY) { - if (map.icons == null) return; - for (MapIcon icon : map.icons) { - if (!icon.canRender()) continue; - if ( - Utils.inRangeInclusive( - mouseX, - (int) ((icon.position.x + map.xOffset) * map.scaleFactor) + - startX - - 4, - (int) ((icon.position.x + map.xOffset) * map.scaleFactor) + - startX + - 4 - ) && - Utils.inRangeInclusive( - mouseY, - (int) ((icon.position.y + map.yOffset) * map.scaleFactor) + - startY - - 4, - (int) ((icon.position.y + map.yOffset) * map.scaleFactor) + - startY + - 4 - ) - ) { - drawHoveringText( - Arrays.asList(icon.tooltip.split("\n")), - mouseX, - mouseY - ); - break; + public void onTooltip(int mouseX, int mouseY, int startX, int startY) { + if (map.icons == null) return; + for (MapIcon icon : map.icons) { + if (!icon.canRender()) continue; + if ( + Utils.inRangeInclusive( + mouseX, + (int) ( + (icon.position.x + map.xOffset) * map.scaleFactor + ) + + startX - + 4, + (int) ( + (icon.position.x + map.xOffset) * map.scaleFactor + ) + + startX + + 4 + ) && + Utils.inRangeInclusive( + mouseY, + (int) ( + (icon.position.y + map.yOffset) * map.scaleFactor + ) + + startY - + 4, + (int) ( + (icon.position.y + map.yOffset) * map.scaleFactor + ) + + startY + + 4 + ) + ) { + drawHoveringText( + Arrays.asList(icon.tooltip.split("\n")), + mouseX, + mouseY + ); + break; + } + } } - } - } - @Override - protected void mouseClicked(int mouseX, int mouseY, int mouseButton) { - int mapX = (int) ((width / 2f) - ((map.width / 2f) * map.scaleFactor)); - int mapY = (int) ((height / 2f) - ((map.height / 2f) * map.scaleFactor)); - for (MapIcon icon : map.icons) { - if (!icon.canRender()) continue; - if ( - Utils.inRangeInclusive( - mouseX, - (int) ((icon.position.x + map.xOffset) * map.scaleFactor) + - mapX - - 4, - (int) ((icon.position.x + map.xOffset) * map.scaleFactor) + mapX + 4 - ) && - Utils.inRangeInclusive( - mouseY, - (int) ((icon.position.y + map.yOffset) * map.scaleFactor) + - mapY - - 4, - (int) ((icon.position.y + map.yOffset) * map.scaleFactor) + mapY + 4 - ) - ) { - if (!icon.command.isEmpty()) { - this.mc.thePlayer.sendChatMessage("/" + icon.command); - } - break; + @Override + protected void mouseClicked(int mouseX, int mouseY, int mouseButton) { + int mapX = (int) ( + (width / 2f) - ((map.width / 2f) * map.scaleFactor) + ); + int mapY = (int) ( + (height / 2f) - ((map.height / 2f) * map.scaleFactor) + ); + for (MapIcon icon : map.icons) { + if (!icon.canRender()) continue; + if ( + Utils.inRangeInclusive( + mouseX, + (int) ( + (icon.position.x + map.xOffset) * map.scaleFactor + ) + + mapX - + 4, + (int) ( + (icon.position.x + map.xOffset) * map.scaleFactor + ) + + mapX + + 4 + ) && + Utils.inRangeInclusive( + mouseY, + (int) ( + (icon.position.y + map.yOffset) * map.scaleFactor + ) + + mapY - + 4, + (int) ( + (icon.position.y + map.yOffset) * map.scaleFactor + ) + + mapY + + 4 + ) + ) { + if (!icon.command.isEmpty()) { + this.mc.thePlayer.sendChatMessage("/" + icon.command); + } + break; + } + } } - } } - } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/handlers/SlayerHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/handlers/SlayerHandler.java index b0ff88e..6b2c808 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/handlers/SlayerHandler.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/handlers/SlayerHandler.java @@ -11,152 +11,160 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; public class SlayerHandler { - //Optional Characters are required because Hypixel dumb and cuts off text - private static final Pattern COMBAT_XP_REGEX = Pattern.compile( - "\\(([\\d,]+)/([\\dkm]+)\\) comb?a?t? x?p?" - ); - private static final Pattern KILLS_REGEX = Pattern.compile( - "(\\d+)/(\\d+) kills?" - ); + //Optional Characters are required because Hypixel dumb and cuts off text + private static final Pattern COMBAT_XP_REGEX = Pattern.compile( + "\\(([\\d,]+)/([\\dkm]+)\\) comb?a?t? x?p?" + ); + private static final Pattern KILLS_REGEX = Pattern.compile( + "(\\d+)/(\\d+) kills?" + ); - public enum slayerTypes { - ZOMBIE(34, "Revenant Horror"), - WOLF(42, "Sven Packmaster"), - SPIDER(50, "Tarantula Broodfather"), - VOIDGLOOMSERAPH(50, "Voidgloom Seraph"), - NONE(0, ""); + public enum slayerTypes { + ZOMBIE(34, "Revenant Horror"), + WOLF(42, "Sven Packmaster"), + SPIDER(50, "Tarantula Broodfather"), + VOIDGLOOMSERAPH(50, "Voidgloom Seraph"), + NONE(0, ""); - private final String displayName; - private final int x; + private final String displayName; + private final int x; - slayerTypes(int x, String displayName) { - this.displayName = displayName; - this.x = x; - } + slayerTypes(int x, String displayName) { + this.displayName = displayName; + this.x = x; + } - public String getDisplayName() { - return displayName; - } + public String getDisplayName() { + return displayName; + } - public int getX() { - return x; + public int getX() { + return x; + } } - } - public static slayerTypes currentSlayer = slayerTypes.NONE; - public static int slayerTier = 0; - public static boolean isDoingSlayer = false; - public static int progress = 0; - public static int maxKills = 0; - public static boolean bossSlain = false; - public static boolean isKillingBoss = false; + public static slayerTypes currentSlayer = slayerTypes.NONE; + public static int slayerTier = 0; + public static boolean isDoingSlayer = false; + public static int progress = 0; + public static int maxKills = 0; + public static boolean bossSlain = false; + public static boolean isKillingBoss = false; - public static void clearSlayer() { - currentSlayer = slayerTypes.NONE; - isDoingSlayer = false; - progress = 0; - maxKills = 0; - bossSlain = false; - isKillingBoss = false; - } + public static void clearSlayer() { + currentSlayer = slayerTypes.NONE; + isDoingSlayer = false; + progress = 0; + maxKills = 0; + bossSlain = false; + isKillingBoss = false; + } - @SubscribeEvent - public void onSidebarPost(SidebarPostEvent event) { - String arrayString = Arrays.toString(event.arrayScores); - isDoingSlayer = Arrays.toString(event.arrayScores).contains("Slayer Quest"); - if ( - isDoingSlayer && - ( - currentSlayer.equals(slayerTypes.NONE) || - !arrayString - .replace(" ", "") - .contains( - currentSlayer.getDisplayName().replace(" ", "") + - Utils.intToRomanNumeral(slayerTier) - ) - ) - ) { - for (int i = 0; i < event.scores.size(); i++) { - String line = event.scores.get(i); - if (line.contains("Slayer Quest") && event.scores.size() > 3) { - String slayer = event.scores.get(i - 1).toLowerCase(); - SlayerHandler.slayerTypes selectedSlayer = - SlayerHandler.slayerTypes.NONE; - for (slayerTypes types : slayerTypes.values()) { - if ( - slayer.contains(types.displayName.toLowerCase(Locale.ENGLISH)) - ) { - selectedSlayer = types; - break; + @SubscribeEvent + public void onSidebarPost(SidebarPostEvent event) { + String arrayString = Arrays.toString(event.arrayScores); + isDoingSlayer = + Arrays.toString(event.arrayScores).contains("Slayer Quest"); + if ( + isDoingSlayer && + ( + currentSlayer.equals(slayerTypes.NONE) || + !arrayString + .replace(" ", "") + .contains( + currentSlayer.getDisplayName().replace(" ", "") + + Utils.intToRomanNumeral(slayerTier) + ) + ) + ) { + for (int i = 0; i < event.scores.size(); i++) { + String line = event.scores.get(i); + if (line.contains("Slayer Quest") && event.scores.size() > 3) { + String slayer = event.scores.get(i - 1).toLowerCase(); + SlayerHandler.slayerTypes selectedSlayer = + SlayerHandler.slayerTypes.NONE; + for (slayerTypes types : slayerTypes.values()) { + if ( + slayer.contains( + types.displayName.toLowerCase(Locale.ENGLISH) + ) + ) { + selectedSlayer = types; + break; + } + } + SlayerHandler.currentSlayer = selectedSlayer; + SlayerHandler.slayerTier = + Utils.whatRomanNumeral( + slayer + .replace( + selectedSlayer + .getDisplayName() + .toLowerCase(), + "" + ) + .replace(" ", "") + ); + break; + } } - } - SlayerHandler.currentSlayer = selectedSlayer; - SlayerHandler.slayerTier = - Utils.whatRomanNumeral( - slayer - .replace(selectedSlayer.getDisplayName().toLowerCase(), "") - .replace(" ", "") - ); - break; } - } - } - if (!isDoingSlayer) { - clearSlayer(); + if (!isDoingSlayer) { + clearSlayer(); + } } - } - @SubscribeEvent - public void onSidebarLineUpdate(SidebarLineUpdateEvent event) { - if ( - !isDoingSlayer && event.formattedLine.equals("Slayer Quest") - ) isDoingSlayer = true; + @SubscribeEvent + public void onSidebarLineUpdate(SidebarLineUpdateEvent event) { + if ( + !isDoingSlayer && event.formattedLine.equals("Slayer Quest") + ) isDoingSlayer = true; - if (isDoingSlayer) { - String line = event.formattedLine.toLowerCase(); - Matcher killMatcher = KILLS_REGEX.matcher(line); - Matcher xpMatcher = COMBAT_XP_REGEX.matcher(line); + if (isDoingSlayer) { + String line = event.formattedLine.toLowerCase(); + Matcher killMatcher = KILLS_REGEX.matcher(line); + Matcher xpMatcher = COMBAT_XP_REGEX.matcher(line); - if (killMatcher.find()) { - SlayerHandler.bossSlain = false; - SlayerHandler.isKillingBoss = false; - try { - progress = Integer.parseInt(killMatcher.group(1)); - } catch (Exception ignored) {} - try { - maxKills = Integer.parseInt(killMatcher.group(2)); - } catch (Exception ignored) {} - } else if (xpMatcher.find()) { - SlayerHandler.bossSlain = false; - SlayerHandler.isKillingBoss = false; - try { - progress = Integer.parseInt(xpMatcher.group(1)); - } catch (Exception ignored) {} - try { - maxKills = - Integer.parseInt(xpMatcher.group(2).replace("k", "")) * - ( - xpMatcher.group(2).contains("k") - ? 1000 - : xpMatcher.group(2).contains("m") ? 1000000 : 1 - ); - } catch (Exception ignored) {} - } else if (line.contains("slay the boss")) { - SlayerHandler.bossSlain = false; - SlayerHandler.isKillingBoss = true; - SlayerHandler.maxKills = 0; - SlayerHandler.progress = 0; - } else if (line.contains("boss slain")) { - SlayerHandler.isKillingBoss = false; - SlayerHandler.maxKills = 0; - SlayerHandler.progress = 0; - SlayerHandler.bossSlain = true; - } - if (maxKills == 0 && progress == 0) { - SlayerHandler.maxKills = 0; - SlayerHandler.progress = 0; - } + if (killMatcher.find()) { + SlayerHandler.bossSlain = false; + SlayerHandler.isKillingBoss = false; + try { + progress = Integer.parseInt(killMatcher.group(1)); + } catch (Exception ignored) {} + try { + maxKills = Integer.parseInt(killMatcher.group(2)); + } catch (Exception ignored) {} + } else if (xpMatcher.find()) { + SlayerHandler.bossSlain = false; + SlayerHandler.isKillingBoss = false; + try { + progress = Integer.parseInt(xpMatcher.group(1)); + } catch (Exception ignored) {} + try { + maxKills = + Integer.parseInt(xpMatcher.group(2).replace("k", "")) * + ( + xpMatcher.group(2).contains("k") + ? 1000 + : xpMatcher.group(2).contains("m") ? 1000000 : 1 + ); + } catch (Exception ignored) {} + } else if (line.contains("slay the boss")) { + SlayerHandler.bossSlain = false; + SlayerHandler.isKillingBoss = true; + SlayerHandler.maxKills = 0; + SlayerHandler.progress = 0; + } else if (line.contains("boss slain")) { + SlayerHandler.isKillingBoss = false; + SlayerHandler.maxKills = 0; + SlayerHandler.progress = 0; + SlayerHandler.bossSlain = true; + } + if (maxKills == 0 && progress == 0) { + SlayerHandler.maxKills = 0; + SlayerHandler.progress = 0; + } + } } - } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/handlers/TimeHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/handlers/TimeHandler.java index 7a66df2..1fc3d3f 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/handlers/TimeHandler.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/handlers/TimeHandler.java @@ -10,34 +10,39 @@ import org.apache.logging.log4j.LogManager; public class TimeHandler { - public static long time; + public static long time; - @SubscribeEvent - public void onSidebarLineUpdate(SidebarLineUpdateEvent event) { - if ( - Pattern.matches( - "([0-9]*):([0-9]*)(pm|am)", - event.formattedLine.toLowerCase().trim() - ) - ) { - boolean isPm = event.formattedLine.toLowerCase().trim().endsWith("pm"); - SimpleDateFormat parseFormat = new SimpleDateFormat( - "hh:mm a", - Locale.CANADA - ); - String currentTimeString = event.formattedLine - .replace(" ", "") - .replace(isPm ? "pm" : "am", isPm ? " pm" : " am"); - try { - time = - ( - parseFormat.parse(currentTimeString).getTime() - - parseFormat.parse("00:00 am").getTime() - ) / - 1000L; - } catch (ParseException ignored) { - LogManager.getLogger().warn("timeformat error: " + currentTimeString); - } + @SubscribeEvent + public void onSidebarLineUpdate(SidebarLineUpdateEvent event) { + if ( + Pattern.matches( + "([0-9]*):([0-9]*)(pm|am)", + event.formattedLine.toLowerCase().trim() + ) + ) { + boolean isPm = event.formattedLine + .toLowerCase() + .trim() + .endsWith("pm"); + SimpleDateFormat parseFormat = new SimpleDateFormat( + "hh:mm a", + Locale.CANADA + ); + String currentTimeString = event.formattedLine + .replace(" ", "") + .replace(isPm ? "pm" : "am", isPm ? " pm" : " am"); + try { + time = + ( + parseFormat.parse(currentTimeString).getTime() - + parseFormat.parse("00:00 am").getTime() + ) / + 1000L; + } catch (ParseException ignored) { + LogManager + .getLogger() + .warn("timeformat error: " + currentTimeString); + } + } } - } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/handlers/mapicons/DwarvenIcons.java b/src/main/java/com/thatgravyboat/skyblockhud/handlers/mapicons/DwarvenIcons.java index 542846a..abfbd0e 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/handlers/mapicons/DwarvenIcons.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/handlers/mapicons/DwarvenIcons.java @@ -9,90 +9,101 @@ import net.minecraft.util.ResourceLocation; public class DwarvenIcons { - public static List dwarvenIcons = new ArrayList<>(); + public static List dwarvenIcons = new ArrayList<>(); - static { - setupNpcIcons(); - setupMiscIcons(); - setupInfoIcons(); - setupShopIcons(); - setupQuestIcons(); - } + static { + setupNpcIcons(); + setupMiscIcons(); + setupInfoIcons(); + setupShopIcons(); + setupQuestIcons(); + } - private static void setupNpcIcons() { - dwarvenIcons.add( - new MapHandler.MapIcon( - new Vector2f(129, 187), - new ResourceLocation("skyblockhud", "maps/icons/puzzle.png"), - new ComponentBuilder() - .nl("Puzzler", new char[] { 'a', 'l' }) - .nl("Description", 'l') - .nl("The Puzzler gives you a small puzzle each day to solve and") - .nl("gives you 1000 mithril powder.") - .build(), - MapHandler.MapIconTypes.NPC - ) - ); - } + private static void setupNpcIcons() { + dwarvenIcons.add( + new MapHandler.MapIcon( + new Vector2f(129, 187), + new ResourceLocation("skyblockhud", "maps/icons/puzzle.png"), + new ComponentBuilder() + .nl("Puzzler", new char[] { 'a', 'l' }) + .nl("Description", 'l') + .nl( + "The Puzzler gives you a small puzzle each day to solve and" + ) + .nl("gives you 1000 mithril powder.") + .build(), + MapHandler.MapIconTypes.NPC + ) + ); + } - private static void setupMiscIcons() {} + private static void setupMiscIcons() {} - private static void setupInfoIcons() { - dwarvenIcons.add( - new MapHandler.MapIcon( - new Vector2f(129, 187), - new ResourceLocation("skyblockhud", "maps/icons/crown.png"), - new ComponentBuilder() - .nl("King", new char[] { 'a', 'l' }) - .nl("Description", 'l') - .nl("The King allows you to first start commissions and if you click") - .nl("each king which change every skyblock day you will get") - .nl("the King Talisman.") - .nl() - .apd("Click to open HOTM", new char[] { '6', 'l' }) - .build(), - MapHandler.MapIconTypes.INFO, - "hotm" - ) - ); - } + private static void setupInfoIcons() { + dwarvenIcons.add( + new MapHandler.MapIcon( + new Vector2f(129, 187), + new ResourceLocation("skyblockhud", "maps/icons/crown.png"), + new ComponentBuilder() + .nl("King", new char[] { 'a', 'l' }) + .nl("Description", 'l') + .nl( + "The King allows you to first start commissions and if you click" + ) + .nl( + "each king which change every skyblock day you will get" + ) + .nl("the King Talisman.") + .nl() + .apd("Click to open HOTM", new char[] { '6', 'l' }) + .build(), + MapHandler.MapIconTypes.INFO, + "hotm" + ) + ); + } - private static void setupShopIcons() { - dwarvenIcons.add( - new MapHandler.MapIcon( - new Vector2f(4, 8), - new ResourceLocation("skyblockhud", "maps/icons/blacksmith.png"), - new ComponentBuilder() - .nl("Forge", new char[] { 'a', 'l' }) - .nl("Description", 'l') - .nl("The Forge is where you can go craft special items") - .nl("and fuel your drill.") - .nl("NPCS", new char[] { 'c', 'l' }) - .nl(" Forger - Allows you to forge special items") - .nl(" Jotraeline Greatforge - Allows you to refuel your drill.") - .nl() - .apd("Click to warp", new char[] { '6', 'l' }) - .build(), - MapHandler.MapIconTypes.SHOPS, - "warpforge" - ) - ); - } + private static void setupShopIcons() { + dwarvenIcons.add( + new MapHandler.MapIcon( + new Vector2f(4, 8), + new ResourceLocation( + "skyblockhud", + "maps/icons/blacksmith.png" + ), + new ComponentBuilder() + .nl("Forge", new char[] { 'a', 'l' }) + .nl("Description", 'l') + .nl("The Forge is where you can go craft special items") + .nl("and fuel your drill.") + .nl("NPCS", new char[] { 'c', 'l' }) + .nl(" Forger - Allows you to forge special items") + .nl( + " Jotraeline Greatforge - Allows you to refuel your drill." + ) + .nl() + .apd("Click to warp", new char[] { '6', 'l' }) + .build(), + MapHandler.MapIconTypes.SHOPS, + "warpforge" + ) + ); + } - private static void setupQuestIcons() { - dwarvenIcons.add( - new MapHandler.MapIcon( - new Vector2f(67, 204), - new ResourceLocation("skyblockhud", "maps/icons/special.png"), - new ComponentBuilder() - .nl("Royal Resident", new char[] { 'a', 'l' }) - .nl("The Royal Resident is a quest where you right") - .nl("click them for a bit to obtain and if you continue") - .nl("to right click them for about 7 hours it will give") - .apd("the achievement Royal Conversation.") - .build(), - MapHandler.MapIconTypes.QUEST - ) - ); - } + private static void setupQuestIcons() { + dwarvenIcons.add( + new MapHandler.MapIcon( + new Vector2f(67, 204), + new ResourceLocation("skyblockhud", "maps/icons/special.png"), + new ComponentBuilder() + .nl("Royal Resident", new char[] { 'a', 'l' }) + .nl("The Royal Resident is a quest where you right") + .nl("click them for a bit to obtain and if you continue") + .nl("to right click them for about 7 hours it will give") + .apd("the achievement Royal Conversation.") + .build(), + MapHandler.MapIconTypes.QUEST + ) + ); + } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/handlers/mapicons/HubIcons.java b/src/main/java/com/thatgravyboat/skyblockhud/handlers/mapicons/HubIcons.java index 7e510b9..2eafaec 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/handlers/mapicons/HubIcons.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/handlers/mapicons/HubIcons.java @@ -9,318 +9,333 @@ import net.minecraft.util.ResourceLocation; public class HubIcons { - public static List hubIcons = new ArrayList<>(); + public static List hubIcons = new ArrayList<>(); - static { - setupNpcIcons(); - setupMiscIcons(); - setupInfoIcons(); - setupShopIcons(); - setupQuestIcons(); - } + static { + setupNpcIcons(); + setupMiscIcons(); + setupInfoIcons(); + setupShopIcons(); + setupQuestIcons(); + } - private static void setupNpcIcons() { - hubIcons.add( - new MapHandler.MapIcon( - new Vector2f(-2, -34), - new ResourceLocation("skyblockhud", "maps/icons/special.png"), - new ComponentBuilder() - .nl("Event Hut", new char[] { 'a', 'l' }) - .nl("Description", 'l') - .nl("The Event Hut is where special event npcs") - .nl("are during some events.") - .nl("NPCS", new char[] { 'c', 'l' }) - .nl(" Baker - During New Years") - .nl(" Jerry - While Winter Island is opened") - .nl(" Fear Mongerer - During Spooky Festival") - .apd(" Oringo - During Traveling Zoo") - .build(), - MapHandler.MapIconTypes.NPC - ) - ); - hubIcons.add( - new MapHandler.MapIcon( - new Vector2f(135, 142), - new ResourceLocation("skyblockhud", "maps/icons/fairy.png"), - new ComponentBuilder() - .nl("Fairy", new char[] { 'a', 'l' }) - .nl("Description", 'l') - .nl("The Fairy is where you go when you find fairy souls") - .apd("to trade them in to get permanent stat upgrades.") - .build(), - MapHandler.MapIconTypes.NPC - ) - ); - } + private static void setupNpcIcons() { + hubIcons.add( + new MapHandler.MapIcon( + new Vector2f(-2, -34), + new ResourceLocation("skyblockhud", "maps/icons/special.png"), + new ComponentBuilder() + .nl("Event Hut", new char[] { 'a', 'l' }) + .nl("Description", 'l') + .nl("The Event Hut is where special event npcs") + .nl("are during some events.") + .nl("NPCS", new char[] { 'c', 'l' }) + .nl(" Baker - During New Years") + .nl(" Jerry - While Winter Island is opened") + .nl(" Fear Mongerer - During Spooky Festival") + .apd(" Oringo - During Traveling Zoo") + .build(), + MapHandler.MapIconTypes.NPC + ) + ); + hubIcons.add( + new MapHandler.MapIcon( + new Vector2f(135, 142), + new ResourceLocation("skyblockhud", "maps/icons/fairy.png"), + new ComponentBuilder() + .nl("Fairy", new char[] { 'a', 'l' }) + .nl("Description", 'l') + .nl("The Fairy is where you go when you find fairy souls") + .apd("to trade them in to get permanent stat upgrades.") + .build(), + MapHandler.MapIconTypes.NPC + ) + ); + } - private static void setupShopIcons() { - hubIcons.add( - new MapHandler.MapIcon( - new Vector2f(-50, -22), - new ResourceLocation("skyblockhud", "maps/icons/building.png"), - new ComponentBuilder() - .nl("Builder's House", new char[] { 'a', 'l' }) - .nl("NPCS", new char[] { 'c', 'l' }) - .nl(" Wool Weaver") - .nl(" Builder") - .apd(" Mad Redstone Engineer") - .build(), - MapHandler.MapIconTypes.SHOPS - ) - ); - hubIcons.add( - new MapHandler.MapIcon( - new Vector2f(-78, -46), - new ResourceLocation("skyblockhud", "maps/icons/bar.png"), - new ComponentBuilder() - .nl("Tavern", new char[] { 'a', 'l' }) - .nl("NPCS", new char[] { 'c', 'l' }) - .nl(" Bartender") - .nl(" Maddox the slayer") - .nl("Description", 'l') - .nl("The Tavern is where maddox the slayer is located you can") - .nl("start slayer quests with them to unlock") - .apd("new items the more slayer bosses you kill.") - .build(), - MapHandler.MapIconTypes.SHOPS - ) - ); - hubIcons.add( - new MapHandler.MapIcon( - new Vector2f(36, -82), - new ResourceLocation("skyblockhud", "maps/icons/vet.png"), - new ComponentBuilder() - .nl("Vet", new char[] { 'a', 'l' }) - .nl("NPCS", new char[] { 'c', 'l' }) - .nl(" Bea") - .nl(" Zog") - .nl(" Kat") - .nl(" George") - .nl("Description", 'l') - .nl("The Vet is where you go to upgrade your pet") - .nl("at Kat or to buy pet upgrade items from Zog") - .nl("or trade in your pet at George and if you're") - .apd("a new player you can buy a bee pet from Bea.") - .build(), - MapHandler.MapIconTypes.SHOPS - ) - ); - hubIcons.add( - new MapHandler.MapIcon( - new Vector2f(58, -73), - new ResourceLocation("skyblockhud", "maps/icons/fishing_merchant.png"), - new ComponentBuilder() - .nl("Fishing Merchant", new char[] { 'a', 'l' }) - .nl("Description", 'l') - .nl("The Fishing Merchant allows you to buy") - .nl("fishing related items and he has his friend") - .nl("joe whose in the house hes setup") - .apd("in front of who sells sponges.") - .build(), - MapHandler.MapIconTypes.SHOPS - ) - ); - hubIcons.add( - new MapHandler.MapIcon( - new Vector2f(46, -53), - new ResourceLocation("skyblockhud", "maps/icons/witch.png"), - new ComponentBuilder() - .nl("Alchemist", new char[] { 'a', 'l' }) - .nl("Description", 'l') - .nl("The Alchemist allows you to buy") - .apd("potion making related items") - .build(), - MapHandler.MapIconTypes.SHOPS - ) - ); - hubIcons.add( - new MapHandler.MapIcon( - new Vector2f(-4, -128), - new ResourceLocation("skyblockhud", "maps/icons/metal_merchants.png"), - new ComponentBuilder() - .nl("Blacksmith Merchants", new char[] { 'a', 'l' }) - .nl("Merchants", new char[] { 'c', 'l' }) - .nl(" Weaponsmith - Weapon Related Items") - .nl(" Armorsmith - Armor Related Items") - .apd(" Mine Merchant - Mining Related Items") - .build(), - MapHandler.MapIconTypes.SHOPS - ) - ); - hubIcons.add( - new MapHandler.MapIcon( - new Vector2f(-30, -120), - new ResourceLocation("skyblockhud", "maps/icons/blacksmith.png"), - new ComponentBuilder() - .nl("Blacksmith", new char[] { 'a', 'l' }) - .nl("NPCS", new char[] { 'c', 'l' }) - .nl(" Blacksmith") - .nl(" Dusk") - .nl(" Smithmonger") - .nl("Description", 'l') - .nl("The Blacksmith lets you reforge your items") - .nl("while the Smithmonger allows you to buy reforge stones") - .apd("and Dusk allows you to combine and apply runes.") - .build(), - MapHandler.MapIconTypes.SHOPS - ) - ); - hubIcons.add( - new MapHandler.MapIcon( - new Vector2f(124, 180), - new ResourceLocation("skyblockhud", "maps/icons/dark_bar.png"), - new ComponentBuilder() - .nl("Dark Bar", new char[] { 'a', 'l' }) - .nl("NPCS", new char[] { 'c', 'l' }) - .nl(" Shifty") - .nl(" Lucius") - .nl("Description", 'l') - .nl("The Dark Bar is where you can buy special") - .nl("brews from Shifty and you can buy special") - .nl("items from Lucius after buying a certain") - .apd("amount of items from the Dark Auction.") - .build(), - MapHandler.MapIconTypes.SHOPS - ) - ); - hubIcons.add( - new MapHandler.MapIcon( - new Vector2f(92, 185), - new ResourceLocation("skyblockhud", "maps/icons/dark_ah.png"), - new ComponentBuilder() - .nl("Dark Auction", new char[] { 'a', 'l' }) - .nl("Description", 'l') - .nl("The Dark Auction allows you to buy") - .nl("super special items from Sirius the") - .apd("auctioneer in a special auction.") - .build(), - MapHandler.MapIconTypes.SHOPS - ) - ); - hubIcons.add( - new MapHandler.MapIcon( - new Vector2f(-245, 52), - new ResourceLocation("skyblockhud", "maps/icons/scroll.png"), - new ComponentBuilder() - .nl("Lonely Philosopher", new char[] { 'a', 'l' }) - .nl("Shop", new char[] { '6', 'l' }) - .nl(" Travel Scroll to Hub Castle") - .nl() - .nl(" Cost") - .nl(" 150,000 Coins", '6') - .nl() - .apd(" Requires ") - .apd("MVP", 'b') - .apd("+", 'c') - .build(), - MapHandler.MapIconTypes.SHOPS - ) - ); - hubIcons.add( - new MapHandler.MapIcon( - new Vector2f(24, -38), - new ResourceLocation("skyblockhud", "maps/icons/tux.png"), - new ComponentBuilder() - .nl("Fashion Shop", new char[] { 'a', 'l' }) - .nl("NPCS", new char[] { 'c', 'l' }) - .nl(" Wool Weaver") - .nl(" Builder") - .apd(" Mad Redstone Engineer") - .build(), - MapHandler.MapIconTypes.SHOPS - ) - ); - } + private static void setupShopIcons() { + hubIcons.add( + new MapHandler.MapIcon( + new Vector2f(-50, -22), + new ResourceLocation("skyblockhud", "maps/icons/building.png"), + new ComponentBuilder() + .nl("Builder's House", new char[] { 'a', 'l' }) + .nl("NPCS", new char[] { 'c', 'l' }) + .nl(" Wool Weaver") + .nl(" Builder") + .apd(" Mad Redstone Engineer") + .build(), + MapHandler.MapIconTypes.SHOPS + ) + ); + hubIcons.add( + new MapHandler.MapIcon( + new Vector2f(-78, -46), + new ResourceLocation("skyblockhud", "maps/icons/bar.png"), + new ComponentBuilder() + .nl("Tavern", new char[] { 'a', 'l' }) + .nl("NPCS", new char[] { 'c', 'l' }) + .nl(" Bartender") + .nl(" Maddox the slayer") + .nl("Description", 'l') + .nl( + "The Tavern is where maddox the slayer is located you can" + ) + .nl("start slayer quests with them to unlock") + .apd("new items the more slayer bosses you kill.") + .build(), + MapHandler.MapIconTypes.SHOPS + ) + ); + hubIcons.add( + new MapHandler.MapIcon( + new Vector2f(36, -82), + new ResourceLocation("skyblockhud", "maps/icons/vet.png"), + new ComponentBuilder() + .nl("Vet", new char[] { 'a', 'l' }) + .nl("NPCS", new char[] { 'c', 'l' }) + .nl(" Bea") + .nl(" Zog") + .nl(" Kat") + .nl(" George") + .nl("Description", 'l') + .nl("The Vet is where you go to upgrade your pet") + .nl("at Kat or to buy pet upgrade items from Zog") + .nl("or trade in your pet at George and if you're") + .apd("a new player you can buy a bee pet from Bea.") + .build(), + MapHandler.MapIconTypes.SHOPS + ) + ); + hubIcons.add( + new MapHandler.MapIcon( + new Vector2f(58, -73), + new ResourceLocation( + "skyblockhud", + "maps/icons/fishing_merchant.png" + ), + new ComponentBuilder() + .nl("Fishing Merchant", new char[] { 'a', 'l' }) + .nl("Description", 'l') + .nl("The Fishing Merchant allows you to buy") + .nl("fishing related items and he has his friend") + .nl("joe whose in the house hes setup") + .apd("in front of who sells sponges.") + .build(), + MapHandler.MapIconTypes.SHOPS + ) + ); + hubIcons.add( + new MapHandler.MapIcon( + new Vector2f(46, -53), + new ResourceLocation("skyblockhud", "maps/icons/witch.png"), + new ComponentBuilder() + .nl("Alchemist", new char[] { 'a', 'l' }) + .nl("Description", 'l') + .nl("The Alchemist allows you to buy") + .apd("potion making related items") + .build(), + MapHandler.MapIconTypes.SHOPS + ) + ); + hubIcons.add( + new MapHandler.MapIcon( + new Vector2f(-4, -128), + new ResourceLocation( + "skyblockhud", + "maps/icons/metal_merchants.png" + ), + new ComponentBuilder() + .nl("Blacksmith Merchants", new char[] { 'a', 'l' }) + .nl("Merchants", new char[] { 'c', 'l' }) + .nl(" Weaponsmith - Weapon Related Items") + .nl(" Armorsmith - Armor Related Items") + .apd(" Mine Merchant - Mining Related Items") + .build(), + MapHandler.MapIconTypes.SHOPS + ) + ); + hubIcons.add( + new MapHandler.MapIcon( + new Vector2f(-30, -120), + new ResourceLocation( + "skyblockhud", + "maps/icons/blacksmith.png" + ), + new ComponentBuilder() + .nl("Blacksmith", new char[] { 'a', 'l' }) + .nl("NPCS", new char[] { 'c', 'l' }) + .nl(" Blacksmith") + .nl(" Dusk") + .nl(" Smithmonger") + .nl("Description", 'l') + .nl("The Blacksmith lets you reforge your items") + .nl( + "while the Smithmonger allows you to buy reforge stones" + ) + .apd("and Dusk allows you to combine and apply runes.") + .build(), + MapHandler.MapIconTypes.SHOPS + ) + ); + hubIcons.add( + new MapHandler.MapIcon( + new Vector2f(124, 180), + new ResourceLocation("skyblockhud", "maps/icons/dark_bar.png"), + new ComponentBuilder() + .nl("Dark Bar", new char[] { 'a', 'l' }) + .nl("NPCS", new char[] { 'c', 'l' }) + .nl(" Shifty") + .nl(" Lucius") + .nl("Description", 'l') + .nl("The Dark Bar is where you can buy special") + .nl("brews from Shifty and you can buy special") + .nl("items from Lucius after buying a certain") + .apd("amount of items from the Dark Auction.") + .build(), + MapHandler.MapIconTypes.SHOPS + ) + ); + hubIcons.add( + new MapHandler.MapIcon( + new Vector2f(92, 185), + new ResourceLocation("skyblockhud", "maps/icons/dark_ah.png"), + new ComponentBuilder() + .nl("Dark Auction", new char[] { 'a', 'l' }) + .nl("Description", 'l') + .nl("The Dark Auction allows you to buy") + .nl("super special items from Sirius the") + .apd("auctioneer in a special auction.") + .build(), + MapHandler.MapIconTypes.SHOPS + ) + ); + hubIcons.add( + new MapHandler.MapIcon( + new Vector2f(-245, 52), + new ResourceLocation("skyblockhud", "maps/icons/scroll.png"), + new ComponentBuilder() + .nl("Lonely Philosopher", new char[] { 'a', 'l' }) + .nl("Shop", new char[] { '6', 'l' }) + .nl(" Travel Scroll to Hub Castle") + .nl() + .nl(" Cost") + .nl(" 150,000 Coins", '6') + .nl() + .apd(" Requires ") + .apd("MVP", 'b') + .apd("+", 'c') + .build(), + MapHandler.MapIconTypes.SHOPS + ) + ); + hubIcons.add( + new MapHandler.MapIcon( + new Vector2f(24, -38), + new ResourceLocation("skyblockhud", "maps/icons/tux.png"), + new ComponentBuilder() + .nl("Fashion Shop", new char[] { 'a', 'l' }) + .nl("NPCS", new char[] { 'c', 'l' }) + .nl(" Wool Weaver") + .nl(" Builder") + .apd(" Mad Redstone Engineer") + .build(), + MapHandler.MapIconTypes.SHOPS + ) + ); + } - private static void setupMiscIcons() { - hubIcons.add( - new MapHandler.MapIcon( - new Vector2f(-24, -53), - new ResourceLocation("skyblockhud", "maps/icons/bank.png"), - new ComponentBuilder() - .nl("Bank", new char[] { 'a', 'l' }) - .nl("Description", 'l') - .nl("The Bank is where you can store your money on skyblock") - .apd("you can also store some items in the vault.") - .build(), - MapHandler.MapIconTypes.MISC - ) - ); - hubIcons.add( - new MapHandler.MapIcon( - new Vector2f(-26, -80), - new ResourceLocation("skyblockhud", "maps/icons/ah.png"), - new ComponentBuilder() - .nl("Auction House", new char[] { 'a', 'l' }) - .nl("Description", 'l') - .nl("The Auction House is where you can auction off your") - .apd("precious items in skyblock to make a profit.") - .build(), - MapHandler.MapIconTypes.MISC - ) - ); - hubIcons.add( - new MapHandler.MapIcon( - new Vector2f(-38, -66), - new ResourceLocation("skyblockhud", "maps/icons/bazaar.png"), - new ComponentBuilder() - .nl("Bazaar", new char[] { 'a', 'l' }) - .nl("Description", 'l') - .nl("The Bazaar is where you can sell specific items") - .nl("on a sort of stock market and request and") - .apd("sell items at a specific price.") - .build(), - MapHandler.MapIconTypes.MISC - ) - ); - } + private static void setupMiscIcons() { + hubIcons.add( + new MapHandler.MapIcon( + new Vector2f(-24, -53), + new ResourceLocation("skyblockhud", "maps/icons/bank.png"), + new ComponentBuilder() + .nl("Bank", new char[] { 'a', 'l' }) + .nl("Description", 'l') + .nl( + "The Bank is where you can store your money on skyblock" + ) + .apd("you can also store some items in the vault.") + .build(), + MapHandler.MapIconTypes.MISC + ) + ); + hubIcons.add( + new MapHandler.MapIcon( + new Vector2f(-26, -80), + new ResourceLocation("skyblockhud", "maps/icons/ah.png"), + new ComponentBuilder() + .nl("Auction House", new char[] { 'a', 'l' }) + .nl("Description", 'l') + .nl("The Auction House is where you can auction off your") + .apd("precious items in skyblock to make a profit.") + .build(), + MapHandler.MapIconTypes.MISC + ) + ); + hubIcons.add( + new MapHandler.MapIcon( + new Vector2f(-38, -66), + new ResourceLocation("skyblockhud", "maps/icons/bazaar.png"), + new ComponentBuilder() + .nl("Bazaar", new char[] { 'a', 'l' }) + .nl("Description", 'l') + .nl("The Bazaar is where you can sell specific items") + .nl("on a sort of stock market and request and") + .apd("sell items at a specific price.") + .build(), + MapHandler.MapIconTypes.MISC + ) + ); + } - private static void setupInfoIcons() { - hubIcons.add( - new MapHandler.MapIcon( - new Vector2f(8, -95), - new ResourceLocation("skyblockhud", "maps/icons/community.png"), - new ComponentBuilder() - .nl("Community Center", new char[] { 'a', 'l' }) - .nl("Description", 'l') - .nl("The Community Center is where you can vote") - .nl("for your favorite election candidate,") - .nl("access the community shop, upgrade your") - .apd("account, and help with city projects.") - .build(), - MapHandler.MapIconTypes.INFO - ) - ); - hubIcons.add( - new MapHandler.MapIcon( - new Vector2f(150, 45), - new ResourceLocation("skyblockhud", "maps/icons/fishing.png"), - new ComponentBuilder() - .nl("Fisherman's Hut", new char[] { 'a', 'l' }) - .nl("Description", 'l') - .nl("This is a spot where people regularly") - .nl("do their fishing, this is one") - .apd("of many spots.") - .build(), - MapHandler.MapIconTypes.INFO - ) - ); - } + private static void setupInfoIcons() { + hubIcons.add( + new MapHandler.MapIcon( + new Vector2f(8, -95), + new ResourceLocation("skyblockhud", "maps/icons/community.png"), + new ComponentBuilder() + .nl("Community Center", new char[] { 'a', 'l' }) + .nl("Description", 'l') + .nl("The Community Center is where you can vote") + .nl("for your favorite election candidate,") + .nl("access the community shop, upgrade your") + .apd("account, and help with city projects.") + .build(), + MapHandler.MapIconTypes.INFO + ) + ); + hubIcons.add( + new MapHandler.MapIcon( + new Vector2f(150, 45), + new ResourceLocation("skyblockhud", "maps/icons/fishing.png"), + new ComponentBuilder() + .nl("Fisherman's Hut", new char[] { 'a', 'l' }) + .nl("Description", 'l') + .nl("This is a spot where people regularly") + .nl("do their fishing, this is one") + .apd("of many spots.") + .build(), + MapHandler.MapIconTypes.INFO + ) + ); + } - private static void setupQuestIcons() { - hubIcons.add( - new MapHandler.MapIcon( - new Vector2f(-8, -10), - new ResourceLocation("skyblockhud", "maps/icons/painter.png"), - new ComponentBuilder() - .nl("Marco", new char[] { 'a', 'l' }) - .nl("Description", 'l') - .nl("Marco is an NPC that has no other uses") - .nl("besides giving you a spray can for") - .apd("completing a quest.") - .build(), - MapHandler.MapIconTypes.QUEST - ) - ); - } + private static void setupQuestIcons() { + hubIcons.add( + new MapHandler.MapIcon( + new Vector2f(-8, -10), + new ResourceLocation("skyblockhud", "maps/icons/painter.png"), + new ComponentBuilder() + .nl("Marco", new char[] { 'a', 'l' }) + .nl("Description", 'l') + .nl("Marco is an NPC that has no other uses") + .nl("besides giving you a spray can for") + .apd("completing a quest.") + .build(), + MapHandler.MapIconTypes.QUEST + ) + ); + } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/handlers/sbentities/EntityTypeHelper.java b/src/main/java/com/thatgravyboat/skyblockhud/handlers/sbentities/EntityTypeHelper.java index 158222c..f5e7c2f 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/handlers/sbentities/EntityTypeHelper.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/handlers/sbentities/EntityTypeHelper.java @@ -8,28 +8,28 @@ import net.minecraft.init.Blocks; public class EntityTypeHelper { - public static boolean isZealot(Entity entity) { - if (entity instanceof EntityEnderman) { - EntityEnderman enderman = ((EntityEnderman) entity); - double maxHealthBase = enderman - .getAttributeMap() - .getAttributeInstanceByName("generic.maxHealth") - .getBaseValue(); - if ( - maxHealthBase == 13000d || - ( - maxHealthBase == 2000d && - enderman - .getHeldBlockState() - .getBlock() - .equals(Blocks.end_portal_frame) - ) - ) { - return LocationHandler - .getCurrentLocation() - .equals(Locations.DRAGONSNEST); - } + public static boolean isZealot(Entity entity) { + if (entity instanceof EntityEnderman) { + EntityEnderman enderman = ((EntityEnderman) entity); + double maxHealthBase = enderman + .getAttributeMap() + .getAttributeInstanceByName("generic.maxHealth") + .getBaseValue(); + if ( + maxHealthBase == 13000d || + ( + maxHealthBase == 2000d && + enderman + .getHeldBlockState() + .getBlock() + .equals(Blocks.end_portal_frame) + ) + ) { + return LocationHandler + .getCurrentLocation() + .equals(Locations.DRAGONSNEST); + } + } + return false; } - return false; - } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/handlers/sbentities/EntityTypeRegistry.java b/src/main/java/com/thatgravyboat/skyblockhud/handlers/sbentities/EntityTypeRegistry.java index 254f61e..a2b70ef 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/handlers/sbentities/EntityTypeRegistry.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/handlers/sbentities/EntityTypeRegistry.java @@ -9,20 +9,22 @@ import net.minecraft.entity.monster.EntityEnderman; public class EntityTypeRegistry { - private static final Map, List> entities = Maps.newHashMap(); + private static final Map, List> entities = Maps.newHashMap(); - static { - entities.put( - EntityEnderman.class, - ImmutableList.of(SkyBlockEntity.of("zealot", EntityTypeHelper::isZealot)) - ); - } + static { + entities.put( + EntityEnderman.class, + ImmutableList.of( + SkyBlockEntity.of("zealot", EntityTypeHelper::isZealot) + ) + ); + } - public static String getEntityId(Entity entity) { - if (!entities.containsKey(entity.getClass())) return null; - for (SkyBlockEntity skyBlockEntity : entities.get(entity.getClass())) if ( - skyBlockEntity.isEntity(entity) - ) return skyBlockEntity.getName(); - return null; - } + public static String getEntityId(Entity entity) { + if (!entities.containsKey(entity.getClass())) return null; + for (SkyBlockEntity skyBlockEntity : entities.get( + entity.getClass() + )) if (skyBlockEntity.isEntity(entity)) return skyBlockEntity.getName(); + return null; + } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/handlers/sbentities/SkyBlockEntity.java b/src/main/java/com/thatgravyboat/skyblockhud/handlers/sbentities/SkyBlockEntity.java index 23a56e5..ee8c3a7 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/handlers/sbentities/SkyBlockEntity.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/handlers/sbentities/SkyBlockEntity.java @@ -5,23 +5,23 @@ import net.minecraft.entity.Entity; public class SkyBlockEntity { - private final String name; - private final Predicate predicate; + private final String name; + private final Predicate predicate; - public static SkyBlockEntity of(String name, Predicate predicate) { - return new SkyBlockEntity(name, predicate); - } + public static SkyBlockEntity of(String name, Predicate predicate) { + return new SkyBlockEntity(name, predicate); + } - private SkyBlockEntity(String name, Predicate predicate) { - this.name = name; - this.predicate = predicate; - } + private SkyBlockEntity(String name, Predicate predicate) { + this.name = name; + this.predicate = predicate; + } - public String getName() { - return name; - } + public String getName() { + return name; + } - public boolean isEntity(Entity entity) { - return predicate.test(entity); - } + public boolean isEntity(Entity entity) { + return predicate.test(entity); + } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/location/DwarvenMineHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/location/DwarvenMineHandler.java index 143c0af..c047767 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/location/DwarvenMineHandler.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/location/DwarvenMineHandler.java @@ -10,129 +10,136 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; public class DwarvenMineHandler { - public enum Event { - NONE(0, "Unknown"), - TICKET(107, "Raffle"), - GOBLIN(99, "Goblin Raid"); + public enum Event { + NONE(0, "Unknown"), + TICKET(107, "Raffle"), + GOBLIN(99, "Goblin Raid"); - public int x; - public String displayName; + public int x; + public String displayName; - Event(int x, String displayName) { - this.x = x; - this.displayName = displayName; + Event(int x, String displayName) { + this.x = x; + this.displayName = displayName; + } } - } - - public static int mithril; - public static int eventMax; - public static int eventProgress; - public static Event currentEvent; + public static int mithril; - private static final DecimalFormat formatter = new DecimalFormat( - "#,###", - DecimalFormatSymbols.getInstance(Locale.CANADA) - ); + public static int eventMax; + public static int eventProgress; + public static Event currentEvent; - public static String getMithrilFormatted() { - String output = formatter.format(mithril); - if (output.equals(".0")) output = "0.0"; else if ( - output.equals(",0") - ) output = "0,0"; - return output; - } + private static final DecimalFormat formatter = new DecimalFormat( + "#,###", + DecimalFormatSymbols.getInstance(Locale.CANADA) + ); - public static void parseMithril(String line) { - try { - mithril = - Integer.parseInt( - line.toLowerCase().replace("mithril powder:", "").trim() - ); - } catch (Exception ignored) {} - } - - @SubscribeEvent - public void onSidebarLineUpdate(SidebarLineUpdateEvent event) { - if (event.formattedLine.toLowerCase().contains("mithril")) { - try { - mithril = - Integer.parseInt( - event.formattedLine.toLowerCase().replace("mithril:", "").trim() - ); - } catch (Exception ignored) {} + public static String getMithrilFormatted() { + String output = formatter.format(mithril); + if (output.equals(".0")) output = "0.0"; else if ( + output.equals(",0") + ) output = "0,0"; + return output; } - if (event.formattedLine.toLowerCase().contains("event")) { - if (event.formattedLine.toLowerCase().contains("raffle")) { - DwarvenMineHandler.currentEvent = Event.TICKET; - } else if (event.formattedLine.toLowerCase().contains("goblin raid")) { - DwarvenMineHandler.currentEvent = Event.GOBLIN; - } + + public static void parseMithril(String line) { + try { + mithril = + Integer.parseInt( + line.toLowerCase().replace("mithril powder:", "").trim() + ); + } catch (Exception ignored) {} } - if (DwarvenMineHandler.currentEvent != Event.NONE) { - if ( - DwarvenMineHandler.currentEvent == Event.TICKET && - event.formattedLine.toLowerCase().contains("tickets:") - ) { - if (event.formattedLine.toLowerCase().contains("pool:")) { - try { - eventMax = - Integer.parseInt( - event.formattedLine - .toLowerCase() - .replace("pool:", "") - .trim() - .split("/")[0].trim() - ); - } catch (Exception ignored) {} - } else if (event.formattedLine.toLowerCase().contains("tickets:")) { - try { - eventProgress = - Integer.parseInt( - event.formattedLine - .toLowerCase() - .replace("tickets:", "") - .split("\\(")[0].trim() - ); - } catch (Exception ignored) {} + + @SubscribeEvent + public void onSidebarLineUpdate(SidebarLineUpdateEvent event) { + if (event.formattedLine.toLowerCase().contains("mithril")) { + try { + mithril = + Integer.parseInt( + event.formattedLine + .toLowerCase() + .replace("mithril:", "") + .trim() + ); + } catch (Exception ignored) {} + } + if (event.formattedLine.toLowerCase().contains("event")) { + if (event.formattedLine.toLowerCase().contains("raffle")) { + DwarvenMineHandler.currentEvent = Event.TICKET; + } else if ( + event.formattedLine.toLowerCase().contains("goblin raid") + ) { + DwarvenMineHandler.currentEvent = Event.GOBLIN; + } } - } else if (DwarvenMineHandler.currentEvent == Event.GOBLIN) { - if (event.formattedLine.toLowerCase().contains("remaining:")) { - try { - eventMax = - Integer.parseInt( - event.formattedLine - .toLowerCase() - .replace("goblins", "") - .replace("remaining:", "") - .trim() - ); - } catch (Exception ignored) {} - } else if ( - event.formattedLine.toLowerCase().contains("your kills:") && - !event.formattedLine.toLowerCase().contains("(") - ) { - try { - eventProgress = - Integer.parseInt( - event.formattedLine - .toLowerCase() - .replace("your kills:", "") - .trim() - ); - } catch (Exception ignored) {} + if (DwarvenMineHandler.currentEvent != Event.NONE) { + if ( + DwarvenMineHandler.currentEvent == Event.TICKET && + event.formattedLine.toLowerCase().contains("tickets:") + ) { + if (event.formattedLine.toLowerCase().contains("pool:")) { + try { + eventMax = + Integer.parseInt( + event.formattedLine + .toLowerCase() + .replace("pool:", "") + .trim() + .split("/")[0].trim() + ); + } catch (Exception ignored) {} + } else if ( + event.formattedLine.toLowerCase().contains("tickets:") + ) { + try { + eventProgress = + Integer.parseInt( + event.formattedLine + .toLowerCase() + .replace("tickets:", "") + .split("\\(")[0].trim() + ); + } catch (Exception ignored) {} + } + } else if (DwarvenMineHandler.currentEvent == Event.GOBLIN) { + if (event.formattedLine.toLowerCase().contains("remaining:")) { + try { + eventMax = + Integer.parseInt( + event.formattedLine + .toLowerCase() + .replace("goblins", "") + .replace("remaining:", "") + .trim() + ); + } catch (Exception ignored) {} + } else if ( + event.formattedLine.toLowerCase().contains("your kills:") && + !event.formattedLine.toLowerCase().contains("(") + ) { + try { + eventProgress = + Integer.parseInt( + event.formattedLine + .toLowerCase() + .replace("your kills:", "") + .trim() + ); + } catch (Exception ignored) {} + } + } } - } } - } - @SubscribeEvent - public void onSidebarPost(SidebarPostEvent event) { - String arrayString = Arrays.toString(event.arrayScores); - if (!arrayString.toLowerCase().contains("event:")) { - DwarvenMineHandler.currentEvent = Event.NONE; - DwarvenMineHandler.eventProgress = 0; - DwarvenMineHandler.eventMax = 0; + @SubscribeEvent + public void onSidebarPost(SidebarPostEvent event) { + String arrayString = Arrays.toString(event.arrayScores); + if (!arrayString.toLowerCase().contains("event:")) { + DwarvenMineHandler.currentEvent = Event.NONE; + DwarvenMineHandler.eventProgress = 0; + DwarvenMineHandler.eventMax = 0; + } } - } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/location/EndIslandHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/location/EndIslandHandler.java index 3eb87d4..51ea9d8 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/location/EndIslandHandler.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/location/EndIslandHandler.java @@ -2,58 +2,58 @@ package com.thatgravyboat.skyblockhud.location; public class EndIslandHandler { - public enum dragonTypes { - PROTECTOR("Protector Dragon", 9000000), - OLD("Old Dragon", 15000000), - WISE("Wise Dragon", 9000000), - UNSTABLE("Unstable Dragon", 9000000), - YOUNG("Young Dragon", 7500000), - STRONG("Strong Dragon", 9000000), - SUPERIOR("Superior Dragon", 12000000), - NODRAGON("", 0); - - private final String displayName; - private final int maxHealth; - - dragonTypes(String displayName, int maxHealth) { - this.displayName = displayName; - this.maxHealth = maxHealth; - } - - public String getDisplayName() { - return this.displayName; - } + public enum dragonTypes { + PROTECTOR("Protector Dragon", 9000000), + OLD("Old Dragon", 15000000), + WISE("Wise Dragon", 9000000), + UNSTABLE("Unstable Dragon", 9000000), + YOUNG("Young Dragon", 7500000), + STRONG("Strong Dragon", 9000000), + SUPERIOR("Superior Dragon", 12000000), + NODRAGON("", 0); + + private final String displayName; + private final int maxHealth; + + dragonTypes(String displayName, int maxHealth) { + this.displayName = displayName; + this.maxHealth = maxHealth; + } - public int getMaxHealth() { - return this.maxHealth; - } + public String getDisplayName() { + return this.displayName; + } - public static dragonTypes findDragon(String input) { - if (input.contains(" ")) { - try { - return dragonTypes.valueOf( - input - .toLowerCase() - .replace("dragon", "") - .replace(" ", "") - .toUpperCase() - ); - } catch (IllegalArgumentException ignored) { - return NODRAGON; + public int getMaxHealth() { + return this.maxHealth; } - } else { - try { - return dragonTypes.valueOf(input); - } catch (IllegalArgumentException ignored) { - return NODRAGON; + + public static dragonTypes findDragon(String input) { + if (input.contains(" ")) { + try { + return dragonTypes.valueOf( + input + .toLowerCase() + .replace("dragon", "") + .replace(" ", "") + .toUpperCase() + ); + } catch (IllegalArgumentException ignored) { + return NODRAGON; + } + } else { + try { + return dragonTypes.valueOf(input); + } catch (IllegalArgumentException ignored) { + return NODRAGON; + } + } } - } } - } - private static dragonTypes currentDragon = dragonTypes.NODRAGON; + private static dragonTypes currentDragon = dragonTypes.NODRAGON; - public static void setCurrentDragon(dragonTypes dragon) { - currentDragon = dragon; - } + public static void setCurrentDragon(dragonTypes dragon) { + currentDragon = dragon; + } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/location/FarmingIslandHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/location/FarmingIslandHandler.java index 083b575..8997fa4 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/location/FarmingIslandHandler.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/location/FarmingIslandHandler.java @@ -6,26 +6,30 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; public class FarmingIslandHandler { - public static Locations location = Locations.NONE; - public static int pelts; + public static Locations location = Locations.NONE; + public static int pelts; - @SubscribeEvent - public void onSidebarPost(SidebarPostEvent event) { - boolean isTracking = Arrays - .toString(event.arrayScores) - .toLowerCase() - .contains("tracker mob location:"); - if (isTracking && location == Locations.NONE) { - for (int i = 0; i < event.scores.size(); i++) { - String line = event.scores.get(i); - if (line.toLowerCase().contains("tracker mob location:") && i > 2) { - location = Locations.get(event.scores.get(i - 1).toLowerCase()); - break; + @SubscribeEvent + public void onSidebarPost(SidebarPostEvent event) { + boolean isTracking = Arrays + .toString(event.arrayScores) + .toLowerCase() + .contains("tracker mob location:"); + if (isTracking && location == Locations.NONE) { + for (int i = 0; i < event.scores.size(); i++) { + String line = event.scores.get(i); + if ( + line.toLowerCase().contains("tracker mob location:") && + i > 2 + ) { + location = + Locations.get(event.scores.get(i - 1).toLowerCase()); + break; + } + } + } + if (!isTracking && location != Locations.NONE) { + location = Locations.NONE; } - } - } - if (!isTracking && location != Locations.NONE) { - location = Locations.NONE; } - } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/location/IslandHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/location/IslandHandler.java index 9bd459a..a50358d 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/location/IslandHandler.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/location/IslandHandler.java @@ -10,79 +10,79 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; public class IslandHandler { - public static int flightTime; - public static boolean hadFlightTime; + public static int flightTime; + public static boolean hadFlightTime; - public static int redstone; - public static boolean hadRedstone; + public static int redstone; + public static boolean hadRedstone; - @SubscribeEvent - public void onSidebarLineUpdate(SidebarLineUpdateEvent event) { - hadFlightTime = checkFlightDuration(event.formattedLine); - hadRedstone = checkRestone(event.formattedLine); - } + @SubscribeEvent + public void onSidebarLineUpdate(SidebarLineUpdateEvent event) { + hadFlightTime = checkFlightDuration(event.formattedLine); + hadRedstone = checkRestone(event.formattedLine); + } - @SubscribeEvent - public void onProfileSwitch(ProfileSwitchedEvent event) { - flightTime = 0; - } + @SubscribeEvent + public void onProfileSwitch(ProfileSwitchedEvent event) { + flightTime = 0; + } - public static boolean checkFlightDuration(String formatedScoreboardLine) { - if ( - LocationHandler.getCurrentLocation() == Locations.YOURISLAND && - Utils - .removeColor(formatedScoreboardLine.toLowerCase().trim()) - .contains("flight duration:") - ) { - String timeString = formatedScoreboardLine - .toLowerCase() - .replace("flight duration:", "") - .replace(" ", ""); - String[] times = timeString.split(":"); - if (times.length == 2) { - int s = 0; - try { - s += Integer.parseInt(times[0]) * 60; - } catch (NumberFormatException ignored) {} - try { - s += Integer.parseInt(times[1]); - } catch (NumberFormatException ignored) {} - flightTime = s - 1; - } else if (times.length == 3) { - int s = 0; - try { - s += Integer.parseInt(times[0]) * 3600; - } catch (NumberFormatException ignored) {} - try { - s += Integer.parseInt(times[1]) * 60; - } catch (NumberFormatException ignored) {} - try { - s += Integer.parseInt(times[2]); - } catch (NumberFormatException ignored) {} - flightTime = s - 1; - } - return true; + public static boolean checkFlightDuration(String formatedScoreboardLine) { + if ( + LocationHandler.getCurrentLocation() == Locations.YOURISLAND && + Utils + .removeColor(formatedScoreboardLine.toLowerCase().trim()) + .contains("flight duration:") + ) { + String timeString = formatedScoreboardLine + .toLowerCase() + .replace("flight duration:", "") + .replace(" ", ""); + String[] times = timeString.split(":"); + if (times.length == 2) { + int s = 0; + try { + s += Integer.parseInt(times[0]) * 60; + } catch (NumberFormatException ignored) {} + try { + s += Integer.parseInt(times[1]); + } catch (NumberFormatException ignored) {} + flightTime = s - 1; + } else if (times.length == 3) { + int s = 0; + try { + s += Integer.parseInt(times[0]) * 3600; + } catch (NumberFormatException ignored) {} + try { + s += Integer.parseInt(times[1]) * 60; + } catch (NumberFormatException ignored) {} + try { + s += Integer.parseInt(times[2]); + } catch (NumberFormatException ignored) {} + flightTime = s - 1; + } + return true; + } + return false; } - return false; - } - public static boolean checkRestone(String formatedScoreboardLine) { - if (LocationHandler.getCurrentLocation() == Locations.YOURISLAND) { - if ( - formatedScoreboardLine.toLowerCase().contains("redstone:") - ) return true; - try { - redstone = - formatedScoreboardLine.toLowerCase().contains("redstone:") - ? Integer.parseInt( - Utils.removeWhiteSpaceAndRemoveWord( - formatedScoreboardLine, - "redstone:" - ) - ) - : 0; - } catch (Exception ignored) {} + public static boolean checkRestone(String formatedScoreboardLine) { + if (LocationHandler.getCurrentLocation() == Locations.YOURISLAND) { + if ( + formatedScoreboardLine.toLowerCase().contains("redstone:") + ) return true; + try { + redstone = + formatedScoreboardLine.toLowerCase().contains("redstone:") + ? Integer.parseInt( + Utils.removeWhiteSpaceAndRemoveWord( + formatedScoreboardLine, + "redstone:" + ) + ) + : 0; + } catch (Exception ignored) {} + } + return false; } - return false; - } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/location/LocationCategory.java b/src/main/java/com/thatgravyboat/skyblockhud/location/LocationCategory.java index 33462f1..a337f3d 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/location/LocationCategory.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/location/LocationCategory.java @@ -5,45 +5,45 @@ import static com.thatgravyboat.skyblockhud.handlers.MapHandler.Maps; import com.thatgravyboat.skyblockhud.handlers.MapHandler; public enum LocationCategory { - ERROR("error", 34), - ISLAND("island", 43), - HUB("hub", 34, Maps.HUB), - BARN("barn", 67, Maps.BARN), - MUSHROOMDESERT("mushroomdesert", 75, Maps.MUSHROOM), - GOLDMINE("gold_mine", 83), - DEEPCAVERNS("deepcaverns", 91), - SPIDERSDEN("spiders_den", 99, Maps.SPIDERS), - PARK("park", 51, Maps.PARK), - FORTRESS("fortress", 107, Maps.NETHER), - DUNGEONHUB("dungeonhub", 115), - JERRY("jerry", 59), - THEEND("the_end", 123), - DWARVENMINES("dwarven_mines", 131, Maps.DWARVEN), - CRYSTALHOLLOWS("crystal_hollows", 131); - - private final String name; - private final int texturePos; - private final MapHandler.Maps map; - - LocationCategory(String name, int texturePos) { - this(name, texturePos, null); - } - - LocationCategory(String name, int texturePos, MapHandler.Maps map) { - this.name = name; - this.texturePos = texturePos; - this.map = map; - } - - public String getName() { - return this.name; - } - - public int getTexturePos() { - return this.texturePos; - } - - public MapHandler.Maps getMap() { - return this.map; - } + ERROR("error", 34), + ISLAND("island", 43), + HUB("hub", 34, Maps.HUB), + BARN("barn", 67, Maps.BARN), + MUSHROOMDESERT("mushroomdesert", 75, Maps.MUSHROOM), + GOLDMINE("gold_mine", 83), + DEEPCAVERNS("deepcaverns", 91), + SPIDERSDEN("spiders_den", 99, Maps.SPIDERS), + PARK("park", 51, Maps.PARK), + FORTRESS("fortress", 107, Maps.NETHER), + DUNGEONHUB("dungeonhub", 115), + JERRY("jerry", 59), + THEEND("the_end", 123), + DWARVENMINES("dwarven_mines", 131, Maps.DWARVEN), + CRYSTALHOLLOWS("crystal_hollows", 131); + + private final String name; + private final int texturePos; + private final MapHandler.Maps map; + + LocationCategory(String name, int texturePos) { + this(name, texturePos, null); + } + + LocationCategory(String name, int texturePos, MapHandler.Maps map) { + this.name = name; + this.texturePos = texturePos; + this.map = map; + } + + public String getName() { + return this.name; + } + + public int getTexturePos() { + return this.texturePos; + } + + public MapHandler.Maps getMap() { + return this.map; + } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/location/LocationHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/location/LocationHandler.java index 86f0432..5cd006a 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/location/LocationHandler.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/location/LocationHandler.java @@ -8,49 +8,49 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; public class LocationHandler { - private static Locations currentLocation = Locations.NONE; - private static final List UndocumentedLocations = new ArrayList<>(); - - @SubscribeEvent - public void onSidebarLineUpdate(SidebarLineUpdateEvent event) { - if (event.rawLine.contains("\u23E3")) { - String objectiveName = event.objective - .getDisplayName() - .replaceAll("(?i)\\u00A7.", ""); - if (objectiveName.toLowerCase(Locale.ENGLISH).endsWith("guest")) { - LocationHandler.setCurrentLocation(Locations.GUESTISLAND); - } else { - LocationHandler.handleLocation(event.formattedLine); - } + private static Locations currentLocation = Locations.NONE; + private static final List UndocumentedLocations = new ArrayList<>(); + + @SubscribeEvent + public void onSidebarLineUpdate(SidebarLineUpdateEvent event) { + if (event.rawLine.contains("\u23E3")) { + String objectiveName = event.objective + .getDisplayName() + .replaceAll("(?i)\\u00A7.", ""); + if (objectiveName.toLowerCase(Locale.ENGLISH).endsWith("guest")) { + LocationHandler.setCurrentLocation(Locations.GUESTISLAND); + } else { + LocationHandler.handleLocation(event.formattedLine); + } + } } - } - - public static void setCurrentLocation(String location) { - currentLocation = Locations.get(location); - } - - public static void setCurrentLocation(Locations location) { - currentLocation = location; - } - - public static Locations getCurrentLocation() { - return currentLocation; - } - - public static void handleLocation(String locationLine) { - String location = locationLine - .replace(" ", "") - .toUpperCase(Locale.ENGLISH) - .trim(); - if (location.startsWith("THECATACOMBS")) { - currentLocation = Locations.CATACOMBS; - } else setCurrentLocation(location.replaceAll("[^A-Za-z0-9]", "")); - } - - public static void reportUndocumentedLocation(String locationId) { - if (!UndocumentedLocations.contains(locationId)) { - UndocumentedLocations.add(locationId); - System.out.println("Missing Location value for: " + locationId); + + public static void setCurrentLocation(String location) { + currentLocation = Locations.get(location); + } + + public static void setCurrentLocation(Locations location) { + currentLocation = location; + } + + public static Locations getCurrentLocation() { + return currentLocation; + } + + public static void handleLocation(String locationLine) { + String location = locationLine + .replace(" ", "") + .toUpperCase(Locale.ENGLISH) + .trim(); + if (location.startsWith("THECATACOMBS")) { + currentLocation = Locations.CATACOMBS; + } else setCurrentLocation(location.replaceAll("[^A-Za-z0-9]", "")); + } + + public static void reportUndocumentedLocation(String locationId) { + if (!UndocumentedLocations.contains(locationId)) { + UndocumentedLocations.add(locationId); + System.out.println("Missing Location value for: " + locationId); + } } - } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/location/Locations.java b/src/main/java/com/thatgravyboat/skyblockhud/location/Locations.java index 0b8bfa2..7669456 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/location/Locations.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/location/Locations.java @@ -1,254 +1,294 @@ package com.thatgravyboat.skyblockhud.location; public enum Locations { - //ERROR LOCATIONS - DEFAULT("unknown", "Error", LocationCategory.ERROR), - NONE("none", "Unknown", LocationCategory.ERROR), - //ISLAND - YOURISLAND("yourisland", "Your Island", LocationCategory.ISLAND), - GUESTISLAND("guestisland", "Guest Island", LocationCategory.ISLAND), - MOULBERRYSISLAND("moulberryisland", "Cool Dude Hub", LocationCategory.ISLAND), - //HUB - VILLAGE("village", "Village", LocationCategory.HUB), - AUCTIONHOUSE("auctionhouse", "Auction House", LocationCategory.HUB), - BAZAARALLEY("bazaaralley", "Bazaar Alley", LocationCategory.HUB), - BANK("bank", "Bank", LocationCategory.HUB), - FASHIONSHOP("fashionshop", "Fashion Shop", LocationCategory.HUB), - COLOSSEUM("colosseum", "Colosseum", LocationCategory.HUB), - COLOSSEUMARENA("colosseumarena", "Colosseum Arena", LocationCategory.HUB), - MOUNTAIN("mountain", "Mountain", LocationCategory.HUB), - HIGHLEVEL("highlevel", "High Level", LocationCategory.HUB), - WILDERNESS("wilderness", "Wilderness", LocationCategory.HUB), - FISHERMANSHUT("fishermanshut", "Fisherman's Hut", LocationCategory.HUB), - FLOWERHOUSE("flowerhouse", "Flower House", LocationCategory.HUB), - CANVASROOM("canvasroom", "Canvas Room", LocationCategory.HUB), - TAVERN("tavern", "Tavern", LocationCategory.HUB), - FOREST("forest", "Forest", LocationCategory.HUB), - RUINS("ruins", "Ruins", LocationCategory.HUB), - GRAVEYARD("graveyard", "Graveyard", LocationCategory.HUB), - COALMINE("coalmine", "Coal Mine", LocationCategory.HUB), - FARM("farm", "Farm", LocationCategory.HUB), - LIBRARY("library", "Library", LocationCategory.HUB), - COMMUNITYCENTER("communitycenter", "Community Center", LocationCategory.HUB), - ELECTIONROOM("electionroom", "Election Room", LocationCategory.HUB), - BUILDERSHOUSE("buildershouse", "Builder's House", LocationCategory.HUB), - BLACKSMITH("blacksmith", "Blacksmith", LocationCategory.HUB), - FARMHOUSE("farmhouse", "Farmhouse", LocationCategory.HUB), - WIZARDTOWER("wizardtower", "Wizard Tower", LocationCategory.HUB), - //THE BARN - THEBARN("thebarn", "The Barn", LocationCategory.BARN), - WINDMILL("windmill", "Windmill", LocationCategory.BARN), - //MUSHROOM DESERT - MUSHROOMDESERT( - "mushroomdesert", - "Mushroom Desert", - LocationCategory.MUSHROOMDESERT - ), - DESERTSETTLEMENT( - "desertsettlement", - "Desert Settlement", - LocationCategory.MUSHROOMDESERT - ), - OASIS("oasis", "Oasis", LocationCategory.MUSHROOMDESERT), - MUSHROOMGORGE( - "mushroomgorge", - "Mushroom Gorge", - LocationCategory.MUSHROOMDESERT - ), - SHEPHERDSKEEP( - "shepherdskeep", - "Shepherds Keep", - LocationCategory.MUSHROOMDESERT - ), - JAKESHOUSE("jakeshouse", "Jake's House", LocationCategory.MUSHROOMDESERT), - TREASUREHUNTERCAMP( - "treasurehuntercamp", - "Treasure Hunter Camp", - LocationCategory.MUSHROOMDESERT - ), - GLOWINGMUSHROOMCAVE( - "glowingmushroomcave", - "Glowing Mushroom Cave", - LocationCategory.MUSHROOMDESERT - ), - TRAPPERSDEN("trappersden", "Trappers Den", LocationCategory.MUSHROOMDESERT), - OVERGROWNMUSHROOMCAVE( - "overgrownmushroomcave", - "Overgrown Mushroom Cave", - LocationCategory.MUSHROOMDESERT - ), - //GOLD MINE - GOLDMINE("goldmine", "Gold Mine", LocationCategory.GOLDMINE), - //DEEP CAVERNS - DEEPCAVERNS("deepcaverns", "Deep Caverns", LocationCategory.DEEPCAVERNS), - GUNPOWDERMINES( - "gunpowdermines", - "Gunpowder Mines", - LocationCategory.DEEPCAVERNS - ), - LAPISQUARRY("lapisquarry", "Lapis Quarry", LocationCategory.DEEPCAVERNS), - PIGMANSDEN("pigmansden", "Pigman's Den", LocationCategory.DEEPCAVERNS), - SLIMEHILL("slimehill", "Slimehill", LocationCategory.DEEPCAVERNS), - DIAMONDRESERVE( - "diamondreserve", - "Diamond Reserve", - LocationCategory.DEEPCAVERNS - ), - OBSIDIANSANCTUARY( - "obsidiansanctuary", - "Obsidian Sanctuary", - LocationCategory.DEEPCAVERNS - ), - //SPIDERS DEN - SPIDERSDEN("spidersden", "Spider's Den", LocationCategory.SPIDERSDEN), + //ERROR LOCATIONS + DEFAULT("unknown", "Error", LocationCategory.ERROR), + NONE("none", "Unknown", LocationCategory.ERROR), + //ISLAND + YOURISLAND("yourisland", "Your Island", LocationCategory.ISLAND), + GUESTISLAND("guestisland", "Guest Island", LocationCategory.ISLAND), + MOULBERRYSISLAND( + "moulberryisland", + "Cool Dude Hub", + LocationCategory.ISLAND + ), + //HUB + VILLAGE("village", "Village", LocationCategory.HUB), + AUCTIONHOUSE("auctionhouse", "Auction House", LocationCategory.HUB), + BAZAARALLEY("bazaaralley", "Bazaar Alley", LocationCategory.HUB), + BANK("bank", "Bank", LocationCategory.HUB), + FASHIONSHOP("fashionshop", "Fashion Shop", LocationCategory.HUB), + COLOSSEUM("colosseum", "Colosseum", LocationCategory.HUB), + COLOSSEUMARENA("colosseumarena", "Colosseum Arena", LocationCategory.HUB), + MOUNTAIN("mountain", "Mountain", LocationCategory.HUB), + HIGHLEVEL("highlevel", "High Level", LocationCategory.HUB), + WILDERNESS("wilderness", "Wilderness", LocationCategory.HUB), + FISHERMANSHUT("fishermanshut", "Fisherman's Hut", LocationCategory.HUB), + FLOWERHOUSE("flowerhouse", "Flower House", LocationCategory.HUB), + CANVASROOM("canvasroom", "Canvas Room", LocationCategory.HUB), + TAVERN("tavern", "Tavern", LocationCategory.HUB), + FOREST("forest", "Forest", LocationCategory.HUB), + RUINS("ruins", "Ruins", LocationCategory.HUB), + GRAVEYARD("graveyard", "Graveyard", LocationCategory.HUB), + COALMINE("coalmine", "Coal Mine", LocationCategory.HUB), + FARM("farm", "Farm", LocationCategory.HUB), + LIBRARY("library", "Library", LocationCategory.HUB), + COMMUNITYCENTER( + "communitycenter", + "Community Center", + LocationCategory.HUB + ), + ELECTIONROOM("electionroom", "Election Room", LocationCategory.HUB), + BUILDERSHOUSE("buildershouse", "Builder's House", LocationCategory.HUB), + BLACKSMITH("blacksmith", "Blacksmith", LocationCategory.HUB), + FARMHOUSE("farmhouse", "Farmhouse", LocationCategory.HUB), + WIZARDTOWER("wizardtower", "Wizard Tower", LocationCategory.HUB), + //THE BARN + THEBARN("thebarn", "The Barn", LocationCategory.BARN), + WINDMILL("windmill", "Windmill", LocationCategory.BARN), + //MUSHROOM DESERT + MUSHROOMDESERT( + "mushroomdesert", + "Mushroom Desert", + LocationCategory.MUSHROOMDESERT + ), + DESERTSETTLEMENT( + "desertsettlement", + "Desert Settlement", + LocationCategory.MUSHROOMDESERT + ), + OASIS("oasis", "Oasis", LocationCategory.MUSHROOMDESERT), + MUSHROOMGORGE( + "mushroomgorge", + "Mushroom Gorge", + LocationCategory.MUSHROOMDESERT + ), + SHEPHERDSKEEP( + "shepherdskeep", + "Shepherds Keep", + LocationCategory.MUSHROOMDESERT + ), + JAKESHOUSE("jakeshouse", "Jake's House", LocationCategory.MUSHROOMDESERT), + TREASUREHUNTERCAMP( + "treasurehuntercamp", + "Treasure Hunter Camp", + LocationCategory.MUSHROOMDESERT + ), + GLOWINGMUSHROOMCAVE( + "glowingmushroomcave", + "Glowing Mushroom Cave", + LocationCategory.MUSHROOMDESERT + ), + TRAPPERSDEN("trappersden", "Trappers Den", LocationCategory.MUSHROOMDESERT), + OVERGROWNMUSHROOMCAVE( + "overgrownmushroomcave", + "Overgrown Mushroom Cave", + LocationCategory.MUSHROOMDESERT + ), + //GOLD MINE + GOLDMINE("goldmine", "Gold Mine", LocationCategory.GOLDMINE), + //DEEP CAVERNS + DEEPCAVERNS("deepcaverns", "Deep Caverns", LocationCategory.DEEPCAVERNS), + GUNPOWDERMINES( + "gunpowdermines", + "Gunpowder Mines", + LocationCategory.DEEPCAVERNS + ), + LAPISQUARRY("lapisquarry", "Lapis Quarry", LocationCategory.DEEPCAVERNS), + PIGMANSDEN("pigmansden", "Pigman's Den", LocationCategory.DEEPCAVERNS), + SLIMEHILL("slimehill", "Slimehill", LocationCategory.DEEPCAVERNS), + DIAMONDRESERVE( + "diamondreserve", + "Diamond Reserve", + LocationCategory.DEEPCAVERNS + ), + OBSIDIANSANCTUARY( + "obsidiansanctuary", + "Obsidian Sanctuary", + LocationCategory.DEEPCAVERNS + ), + //SPIDERS DEN + SPIDERSDEN("spidersden", "Spider's Den", LocationCategory.SPIDERSDEN), - //THE END - THEEND("theend", "The End", LocationCategory.THEEND), - DRAGONSNEST("dragonsnest", "Dragon's Nest", LocationCategory.THEEND), - VOIDSEPULTURE("voidsepulture", "Void Sepulture", LocationCategory.THEEND), - //PARK - HOWLINGCAVE("howlingcave", "Howling Cave", LocationCategory.PARK), - BIRCHPARK("birchpark", "Birch Park", LocationCategory.PARK), - SPRUCEWOODS("sprucewoods", "Spruce Woods", LocationCategory.PARK), - DARKTHICKET("darkthicket", "Dark Thicket", LocationCategory.PARK), - SAVANNAWOODLAND("savannawoodland", "Savanna Woodland", LocationCategory.PARK), - JUNGLEISLAND("jungleisland", "Jungle Island", LocationCategory.PARK), - //BLAZING FORTRESS - BLAZINGFORTRESS( - "blazingfortress", - "Blazing Fortress", - LocationCategory.FORTRESS - ), - //DUNGEONS - DUNGEONHUB("dungeonhub", "Dungeon Hub", LocationCategory.DUNGEONHUB), - CATACOMBS("catacombs", "The Catacombs", LocationCategory.DUNGEONHUB), - CATACOMBSENTRANCE( - "catacombsentrance", - "Catacombs Entrance", - LocationCategory.DUNGEONHUB - ), - //JERRYISLAND - JERRYSWORKSHOP("jerrysworkshop", "Jerry's Workshop", LocationCategory.JERRY), - JERRYPOND("jerrypond", "Jerry Pond", LocationCategory.JERRY), - //DWARVENMINES - THELIFT("thelift", "The Lift", LocationCategory.DWARVENMINES), - DWARVENVILLAGE( - "dwarvenvillage", - "Dwarven Village", - LocationCategory.DWARVENMINES - ), - DWARVENMINES("dwarvenmines", "Dwarven Mines", LocationCategory.DWARVENMINES), - LAVASPRINGS("lavasprings", "Lava Springs", LocationCategory.DWARVENMINES), - PALACEBRIDGE("palacebridge", "Palace Bridge", LocationCategory.DWARVENMINES), - ROYALPALACE("royalpalace", "Royal Palace", LocationCategory.DWARVENMINES), - GRANDLIBRARY("grandlibrary", "Grand Library", LocationCategory.DWARVENMINES), - ROYALQUARTERS( - "royalquarters", - "Royal Quarters", - LocationCategory.DWARVENMINES - ), - BARRACKSOFHEROES( - "barracksofheroes", - "Barracks of Heroes", - LocationCategory.DWARVENMINES - ), - HANGINGCOURT("hangingcourt", "Hanging Court", LocationCategory.DWARVENMINES), - GREATICEWALL("greaticewall", "Great Ice Wall", LocationCategory.DWARVENMINES), - GOBLINBURROWS( - "goblinburrows", - "Goblin Burrows", - LocationCategory.DWARVENMINES - ), - FARRESERVE("farreserve", "Far Reserve", LocationCategory.DWARVENMINES), - CCMINECARTSCO("ccminecartco", "Minecart Co.", LocationCategory.DWARVENMINES), - UPPERMINES("uppermines", "Upper Mines", LocationCategory.DWARVENMINES), - RAMPARTSQUARRY( - "rampartsquarry", - "Ramparts Quarry", - LocationCategory.DWARVENMINES - ), - GATESTOTHEMINES( - "gatestothemines", - "Gates to The Mines", - LocationCategory.DWARVENMINES - ), - FORGEBASIN("forgebasin", "Forge Basin", LocationCategory.DWARVENMINES), - THEFORGE("theforge", "The Forge", LocationCategory.DWARVENMINES), - CLIFFSIDEVEINS( - "cliffsideveins", - "Cliffside Veins", - LocationCategory.DWARVENMINES - ), - DIVANSGATEWAY( - "divansgateway", - "Divan's Gateway", - LocationCategory.DWARVENMINES - ), - THEMIST("themist", "The Mist", LocationCategory.DWARVENMINES), - ROYALMINES("royalmines", "Royal Mines", LocationCategory.DWARVENMINES), - ARISTOCRATPASSAGE( - "aristocratpassage", - "Aristocrat Passage", - LocationCategory.DWARVENMINES - ), - MINERSGUILD("minersguild", "Miner's Guild", LocationCategory.DWARVENMINES), - //CRYSTALHOLLOWS - JUNGLE("jungle", "Jungle", LocationCategory.CRYSTALHOLLOWS), - MAMGAFIELDS("magmafields", "Magma Fields", LocationCategory.CRYSTALHOLLOWS), - GOBLINHOLDOUT( - "goblinholdout", - "Goblin Holdout", - LocationCategory.CRYSTALHOLLOWS - ), - CRYSTALNUCLEUS( - "crystalnucleus", - "Crystal Nucleus", - LocationCategory.CRYSTALHOLLOWS - ), - PERCURSORREMNANTS( - "precursorremnants", - "Precursor Remnants", - LocationCategory.CRYSTALHOLLOWS - ), - MITHRILDEPOSITS( - "mithrildeposits", - "Mithril Deposits", - LocationCategory.CRYSTALHOLLOWS - ); + //THE END + THEEND("theend", "The End", LocationCategory.THEEND), + DRAGONSNEST("dragonsnest", "Dragon's Nest", LocationCategory.THEEND), + VOIDSEPULTURE("voidsepulture", "Void Sepulture", LocationCategory.THEEND), + //PARK + HOWLINGCAVE("howlingcave", "Howling Cave", LocationCategory.PARK), + BIRCHPARK("birchpark", "Birch Park", LocationCategory.PARK), + SPRUCEWOODS("sprucewoods", "Spruce Woods", LocationCategory.PARK), + DARKTHICKET("darkthicket", "Dark Thicket", LocationCategory.PARK), + SAVANNAWOODLAND( + "savannawoodland", + "Savanna Woodland", + LocationCategory.PARK + ), + JUNGLEISLAND("jungleisland", "Jungle Island", LocationCategory.PARK), + //BLAZING FORTRESS + BLAZINGFORTRESS( + "blazingfortress", + "Blazing Fortress", + LocationCategory.FORTRESS + ), + //DUNGEONS + DUNGEONHUB("dungeonhub", "Dungeon Hub", LocationCategory.DUNGEONHUB), + CATACOMBS("catacombs", "The Catacombs", LocationCategory.DUNGEONHUB), + CATACOMBSENTRANCE( + "catacombsentrance", + "Catacombs Entrance", + LocationCategory.DUNGEONHUB + ), + //JERRYISLAND + JERRYSWORKSHOP( + "jerrysworkshop", + "Jerry's Workshop", + LocationCategory.JERRY + ), + JERRYPOND("jerrypond", "Jerry Pond", LocationCategory.JERRY), + //DWARVENMINES + THELIFT("thelift", "The Lift", LocationCategory.DWARVENMINES), + DWARVENVILLAGE( + "dwarvenvillage", + "Dwarven Village", + LocationCategory.DWARVENMINES + ), + DWARVENMINES( + "dwarvenmines", + "Dwarven Mines", + LocationCategory.DWARVENMINES + ), + LAVASPRINGS("lavasprings", "Lava Springs", LocationCategory.DWARVENMINES), + PALACEBRIDGE( + "palacebridge", + "Palace Bridge", + LocationCategory.DWARVENMINES + ), + ROYALPALACE("royalpalace", "Royal Palace", LocationCategory.DWARVENMINES), + GRANDLIBRARY( + "grandlibrary", + "Grand Library", + LocationCategory.DWARVENMINES + ), + ROYALQUARTERS( + "royalquarters", + "Royal Quarters", + LocationCategory.DWARVENMINES + ), + BARRACKSOFHEROES( + "barracksofheroes", + "Barracks of Heroes", + LocationCategory.DWARVENMINES + ), + HANGINGCOURT( + "hangingcourt", + "Hanging Court", + LocationCategory.DWARVENMINES + ), + GREATICEWALL( + "greaticewall", + "Great Ice Wall", + LocationCategory.DWARVENMINES + ), + GOBLINBURROWS( + "goblinburrows", + "Goblin Burrows", + LocationCategory.DWARVENMINES + ), + FARRESERVE("farreserve", "Far Reserve", LocationCategory.DWARVENMINES), + CCMINECARTSCO( + "ccminecartco", + "Minecart Co.", + LocationCategory.DWARVENMINES + ), + UPPERMINES("uppermines", "Upper Mines", LocationCategory.DWARVENMINES), + RAMPARTSQUARRY( + "rampartsquarry", + "Ramparts Quarry", + LocationCategory.DWARVENMINES + ), + GATESTOTHEMINES( + "gatestothemines", + "Gates to The Mines", + LocationCategory.DWARVENMINES + ), + FORGEBASIN("forgebasin", "Forge Basin", LocationCategory.DWARVENMINES), + THEFORGE("theforge", "The Forge", LocationCategory.DWARVENMINES), + CLIFFSIDEVEINS( + "cliffsideveins", + "Cliffside Veins", + LocationCategory.DWARVENMINES + ), + DIVANSGATEWAY( + "divansgateway", + "Divan's Gateway", + LocationCategory.DWARVENMINES + ), + THEMIST("themist", "The Mist", LocationCategory.DWARVENMINES), + ROYALMINES("royalmines", "Royal Mines", LocationCategory.DWARVENMINES), + ARISTOCRATPASSAGE( + "aristocratpassage", + "Aristocrat Passage", + LocationCategory.DWARVENMINES + ), + MINERSGUILD("minersguild", "Miner's Guild", LocationCategory.DWARVENMINES), + //CRYSTALHOLLOWS + JUNGLE("jungle", "Jungle", LocationCategory.CRYSTALHOLLOWS), + MAMGAFIELDS("magmafields", "Magma Fields", LocationCategory.CRYSTALHOLLOWS), + GOBLINHOLDOUT( + "goblinholdout", + "Goblin Holdout", + LocationCategory.CRYSTALHOLLOWS + ), + CRYSTALNUCLEUS( + "crystalnucleus", + "Crystal Nucleus", + LocationCategory.CRYSTALHOLLOWS + ), + PERCURSORREMNANTS( + "precursorremnants", + "Precursor Remnants", + LocationCategory.CRYSTALHOLLOWS + ), + MITHRILDEPOSITS( + "mithrildeposits", + "Mithril Deposits", + LocationCategory.CRYSTALHOLLOWS + ); - private final String name; - private final String displayName; - private final LocationCategory category; + private final String name; + private final String displayName; + private final LocationCategory category; - Locations(String name, String displayName, LocationCategory category) { - this.name = name; - this.displayName = displayName; - this.category = category; - } + Locations(String name, String displayName, LocationCategory category) { + this.name = name; + this.displayName = displayName; + this.category = category; + } - public String getName() { - return this.name; - } + public String getName() { + return this.name; + } - public String getDisplayName() { - return this.displayName; - } + public String getDisplayName() { + return this.displayName; + } - public LocationCategory getCategory() { - return this.category; - } + public LocationCategory getCategory() { + return this.category; + } - public static Locations get(String id) { - try { - return Locations.valueOf(id.replace(" ", "").toUpperCase()); - } catch (IllegalArgumentException ex) { - LocationHandler.reportUndocumentedLocation(id); - return DEFAULT; + public static Locations get(String id) { + try { + return Locations.valueOf(id.replace(" ", "").toUpperCase()); + } catch (IllegalArgumentException ex) { + LocationHandler.reportUndocumentedLocation(id); + return DEFAULT; + } } - } - @Override - public String toString() { - return this.name; - } + @Override + public String toString() { + return this.name; + } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/location/ParkIslandHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/location/ParkIslandHandler.java index 7fa0d19..5d5f756 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/location/ParkIslandHandler.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/location/ParkIslandHandler.java @@ -4,26 +4,28 @@ import javax.annotation.Nullable; public class ParkIslandHandler { - private static boolean isRaining = false; - private static String rainTime = ""; + private static boolean isRaining = false; + private static String rainTime = ""; - public static void parseRain(@Nullable String tabLine) { - if (tabLine == null) { - isRaining = false; - rainTime = ""; - } else if (tabLine.toLowerCase().contains("rain:")) { - if (tabLine.toLowerCase().contains("no rain")) isRaining = false; else { - rainTime = tabLine.toLowerCase().replace("rain:", "").replace(" ", ""); - isRaining = true; - } + public static void parseRain(@Nullable String tabLine) { + if (tabLine == null) { + isRaining = false; + rainTime = ""; + } else if (tabLine.toLowerCase().contains("rain:")) { + if (tabLine.toLowerCase().contains("no rain")) isRaining = + false; else { + rainTime = + tabLine.toLowerCase().replace("rain:", "").replace(" ", ""); + isRaining = true; + } + } } - } - public static String getRainTime() { - return rainTime; - } + public static String getRainTime() { + return rainTime; + } - public static boolean isRaining() { - return isRaining; - } + public static boolean isRaining() { + return isRaining; + } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinEndermanRenderer.java b/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinEndermanRenderer.java index 07853d3..d29b6f5 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinEndermanRenderer.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinEndermanRenderer.java @@ -14,29 +14,29 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(RenderEnderman.class) public class MixinEndermanRenderer { - @Inject( - method = "doRender(Lnet/minecraft/entity/monster/EntityEnderman;DDDFF)V", - at = @At("HEAD") - ) - public void onRender( - EntityEnderman entity, - double x, - double y, - double z, - float entityYaw, - float partialTicks, - CallbackInfo ci - ) { - if (EntityTypeHelper.isZealot(entity)) { - Color color = new Color( - SpecialColour.specialToChromaRGB("255:255:0:48:255") - ); - GlStateManager.color( - color.getRed() / 255f, - color.getGreen() / 255f, - color.getBlue() / 255f, - 255f - ); + @Inject( + method = "doRender(Lnet/minecraft/entity/monster/EntityEnderman;DDDFF)V", + at = @At("HEAD") + ) + public void onRender( + EntityEnderman entity, + double x, + double y, + double z, + float entityYaw, + float partialTicks, + CallbackInfo ci + ) { + if (EntityTypeHelper.isZealot(entity)) { + Color color = new Color( + SpecialColour.specialToChromaRGB("255:255:0:48:255") + ); + GlStateManager.color( + color.getRed() / 255f, + color.getGreen() / 255f, + color.getBlue() / 255f, + 255f + ); + } } - } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinEntityArrow.java b/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinEntityArrow.java index 57ea2dc..3641876 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinEntityArrow.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinEntityArrow.java @@ -13,21 +13,23 @@ import org.spongepowered.asm.mixin.injection.ModifyVariable; @Mixin(EntityArrow.class) public class MixinEntityArrow { - //Disabled as kill tracker stuff not fully added yet. - @Shadow - public Entity shootingEntity; + //Disabled as kill tracker stuff not fully added yet. + @Shadow + public Entity shootingEntity; - @ModifyVariable(method = "onUpdate", at = @At(value = "STORE", ordinal = 1)) - public MovingObjectPosition onUpdate(MovingObjectPosition position) { - if ( - position != null && - position.entityHit != null && - this.shootingEntity != null && - this.shootingEntity.getUniqueID() - .equals(Minecraft.getMinecraft().thePlayer.getUniqueID()) - ) { - KillTrackerHandler.attackedEntities.add(position.entityHit.getUniqueID()); + @ModifyVariable(method = "onUpdate", at = @At(value = "STORE", ordinal = 1)) + public MovingObjectPosition onUpdate(MovingObjectPosition position) { + if ( + position != null && + position.entityHit != null && + this.shootingEntity != null && + this.shootingEntity.getUniqueID() + .equals(Minecraft.getMinecraft().thePlayer.getUniqueID()) + ) { + KillTrackerHandler.attackedEntities.add( + position.entityHit.getUniqueID() + ); + } + return position; } - return position; - } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinGuiIngameForge.java b/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinGuiIngameForge.java index 1d20f02..d6e0ac6 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinGuiIngameForge.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinGuiIngameForge.java @@ -15,136 +15,137 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(GuiIngameForge.class) public class MixinGuiIngameForge { - @Shadow(remap = false) - private RenderGameOverlayEvent eventParent; + @Shadow(remap = false) + private RenderGameOverlayEvent eventParent; - @Inject( - method = "renderArmor", - at = @At("HEAD"), - cancellable = true, - remap = false - ) - public void onRenderArmor(int width, int height, CallbackInfo ci) { - if ( - SkyblockHud.config.renderer.hideArmor && - SkyblockHud.hasSkyblockScoreboard() - ) { - ci.cancel(); - if (pre(ARMOR)) return; - post(ARMOR); + @Inject( + method = "renderArmor", + at = @At("HEAD"), + cancellable = true, + remap = false + ) + public void onRenderArmor(int width, int height, CallbackInfo ci) { + if ( + SkyblockHud.config.renderer.hideArmor && + SkyblockHud.hasSkyblockScoreboard() + ) { + ci.cancel(); + if (pre(ARMOR)) return; + post(ARMOR); + } } - } - @Inject( - method = "renderHealth", - at = @At("HEAD"), - cancellable = true, - remap = false - ) - public void onRenderHealth(int width, int height, CallbackInfo ci) { - if ( - SkyblockHud.config.renderer.hideHearts && - SkyblockHud.hasSkyblockScoreboard() - ) { - ci.cancel(); - if (pre(HEALTH)) return; - post(HEALTH); + @Inject( + method = "renderHealth", + at = @At("HEAD"), + cancellable = true, + remap = false + ) + public void onRenderHealth(int width, int height, CallbackInfo ci) { + if ( + SkyblockHud.config.renderer.hideHearts && + SkyblockHud.hasSkyblockScoreboard() + ) { + ci.cancel(); + if (pre(HEALTH)) return; + post(HEALTH); + } } - } - @Inject( - method = "renderAir", - at = @At("HEAD"), - cancellable = true, - remap = false - ) - public void onRenderAir(int width, int height, CallbackInfo ci) { - if ( - SkyblockHud.config.renderer.hideAir && SkyblockHud.hasSkyblockScoreboard() - ) { - ci.cancel(); - if (pre(AIR)) return; - post(AIR); + @Inject( + method = "renderAir", + at = @At("HEAD"), + cancellable = true, + remap = false + ) + public void onRenderAir(int width, int height, CallbackInfo ci) { + if ( + SkyblockHud.config.renderer.hideAir && + SkyblockHud.hasSkyblockScoreboard() + ) { + ci.cancel(); + if (pre(AIR)) return; + post(AIR); + } } - } - @Inject( - method = "renderHealthMount", - at = @At("HEAD"), - cancellable = true, - remap = false - ) - public void onRenderHealthMount(int width, int height, CallbackInfo ci) { - if ( - SkyblockHud.config.renderer.hideAnimalHearts && - SkyblockHud.hasSkyblockScoreboard() - ) { - ci.cancel(); - if (pre(HEALTHMOUNT)) return; - post(HEALTHMOUNT); + @Inject( + method = "renderHealthMount", + at = @At("HEAD"), + cancellable = true, + remap = false + ) + public void onRenderHealthMount(int width, int height, CallbackInfo ci) { + if ( + SkyblockHud.config.renderer.hideAnimalHearts && + SkyblockHud.hasSkyblockScoreboard() + ) { + ci.cancel(); + if (pre(HEALTHMOUNT)) return; + post(HEALTHMOUNT); + } } - } - @Inject( - method = "renderExperience", - at = @At("HEAD"), - cancellable = true, - remap = false - ) - public void onRenderExperience(int width, int height, CallbackInfo ci) { - if ( - SkyblockHud.config.renderer.hideXpBar && - SkyblockHud.hasSkyblockScoreboard() - ) { - ci.cancel(); - if (pre(EXPERIENCE)) return; - post(EXPERIENCE); + @Inject( + method = "renderExperience", + at = @At("HEAD"), + cancellable = true, + remap = false + ) + public void onRenderExperience(int width, int height, CallbackInfo ci) { + if ( + SkyblockHud.config.renderer.hideXpBar && + SkyblockHud.hasSkyblockScoreboard() + ) { + ci.cancel(); + if (pre(EXPERIENCE)) return; + post(EXPERIENCE); + } } - } - @Inject( - method = "renderJumpBar", - at = @At("HEAD"), - cancellable = true, - remap = false - ) - public void onRenderJumpBar(int width, int height, CallbackInfo ci) { - if ( - SkyblockHud.config.renderer.hideXpBar && - SkyblockHud.hasSkyblockScoreboard() - ) { - ci.cancel(); - if (pre(JUMPBAR)) return; - post(JUMPBAR); + @Inject( + method = "renderJumpBar", + at = @At("HEAD"), + cancellable = true, + remap = false + ) + public void onRenderJumpBar(int width, int height, CallbackInfo ci) { + if ( + SkyblockHud.config.renderer.hideXpBar && + SkyblockHud.hasSkyblockScoreboard() + ) { + ci.cancel(); + if (pre(JUMPBAR)) return; + post(JUMPBAR); + } } - } - @Inject( - method = "renderFood", - at = @At("HEAD"), - cancellable = true, - remap = false - ) - public void onRenderFood(int width, int height, CallbackInfo ci) { - if ( - SkyblockHud.config.renderer.hideFood && - SkyblockHud.hasSkyblockScoreboard() - ) { - ci.cancel(); - if (pre(FOOD)) return; - post(FOOD); + @Inject( + method = "renderFood", + at = @At("HEAD"), + cancellable = true, + remap = false + ) + public void onRenderFood(int width, int height, CallbackInfo ci) { + if ( + SkyblockHud.config.renderer.hideFood && + SkyblockHud.hasSkyblockScoreboard() + ) { + ci.cancel(); + if (pre(FOOD)) return; + post(FOOD); + } } - } - private boolean pre(RenderGameOverlayEvent.ElementType type) { - return MinecraftForge.EVENT_BUS.post( - new RenderGameOverlayEvent.Pre(eventParent, type) - ); - } + private boolean pre(RenderGameOverlayEvent.ElementType type) { + return MinecraftForge.EVENT_BUS.post( + new RenderGameOverlayEvent.Pre(eventParent, type) + ); + } - private void post(RenderGameOverlayEvent.ElementType type) { - MinecraftForge.EVENT_BUS.post( - new RenderGameOverlayEvent.Post(eventParent, type) - ); - } + private void post(RenderGameOverlayEvent.ElementType type) { + MinecraftForge.EVENT_BUS.post( + new RenderGameOverlayEvent.Post(eventParent, type) + ); + } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinNetHandlerPlayClient.java b/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinNetHandlerPlayClient.java index 759089b..5cb4036 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinNetHandlerPlayClient.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinNetHandlerPlayClient.java @@ -12,7 +12,7 @@ import org.spongepowered.asm.mixin.injection.callback.LocalCapture; @Mixin(NetHandlerPlayClient.class) public class MixinNetHandlerPlayClient { - /* DISABLE UNTIL NEW SYSTEM + /* DISABLE UNTIL NEW SYSTEM @Inject(method = "handleSetSlot", at = @At("HEAD")) public void onHandleSetSlot(S2FPacketSetSlot packetIn, CallbackInfo ci){ if (SkyblockHud.hasSkyblockScoreboard()) { @@ -44,26 +44,26 @@ public class MixinNetHandlerPlayClient { } */ - @Inject( - method = "handleTeams", - locals = LocalCapture.CAPTURE_FAILHARD, - at = @At( - value = "INVOKE", - target = "Lnet/minecraft/network/play/server/S3EPacketTeams;getAction()I", - ordinal = 0, - shift = At.Shift.BEFORE - ), - cancellable = true - ) - public void handleTeams( - S3EPacketTeams packetIn, - CallbackInfo ci, - Scoreboard scoreboard - ) { - //This stops Hypixel from being stupid and spamming our logs because they dont have different ids for things. - if ( - scoreboard.getTeam(packetIn.getName()) != null && - packetIn.getAction() == 0 - ) ci.cancel(); - } + @Inject( + method = "handleTeams", + locals = LocalCapture.CAPTURE_FAILHARD, + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/network/play/server/S3EPacketTeams;getAction()I", + ordinal = 0, + shift = At.Shift.BEFORE + ), + cancellable = true + ) + public void handleTeams( + S3EPacketTeams packetIn, + CallbackInfo ci, + Scoreboard scoreboard + ) { + //This stops Hypixel from being stupid and spamming our logs because they dont have different ids for things. + if ( + scoreboard.getTeam(packetIn.getName()) != null && + packetIn.getAction() == 0 + ) ci.cancel(); + } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/overlay/DungeonOverlay.java b/src/main/java/com/thatgravyboat/skyblockhud/overlay/DungeonOverlay.java index d5602ed..9d8556d 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/overlay/DungeonOverlay.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/overlay/DungeonOverlay.java @@ -24,322 +24,335 @@ 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; + 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); + 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); + 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); - - 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++ + @SubscribeEvent + public void renderOverlay(RenderGameOverlayEvent.Post event) { + Minecraft mc = Minecraft.getMinecraft(); + if ( + Utils.overlayShouldRender( + event.type, + SkyblockHud.hasSkyblockScoreboard(), + LocationHandler.getCurrentLocation().equals(Locations.CATACOMBS) + ) ) { - 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 - ); + 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 + ); } - } - 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 8cff166..45fd243 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/overlay/GenericOverlays.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/overlay/GenericOverlays.java @@ -10,75 +10,93 @@ import net.minecraft.client.renderer.GlStateManager; 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 1b0614d..cba60eb 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/overlay/OverlayHud.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/overlay/OverlayHud.java @@ -25,709 +25,731 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; public class OverlayHud extends Gui { - private static final FontRenderer font = Minecraft.getMinecraft() - .fontRendererObj; + private static final FontRenderer font = Minecraft.getMinecraft() + .fontRendererObj; - //STATS - private static boolean eventToggle; + //STATS + private static boolean eventToggle; - public static boolean bossBarVisible = false; + public static boolean bossBarVisible = false; - 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"); - - 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 - ); - - //PURSE - drawPurseAndBits(width, offset, mc); - - //SEASON/DATE - drawSeasonAndDate(width, offset, mc); - - //REDSTONE PERCENT - drawRedstone(width, offset, mc); - - // LOCATION - drawLocation(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); - } - } - - 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 - ); - } + 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"); - 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 - ); - } - } + 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 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; + //PURSE + drawPurseAndBits(width, offset, mc); - //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; + //SEASON/DATE + drawSeasonAndDate(width, offset, mc); - //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; - } + //REDSTONE PERCENT + drawRedstone(width, offset, mc); - drawTexturedModalRect( - xPos, - offset + (bossBarVisible ? 35 : 18), - 252, - 34, - 4, - 14 - ); - } + // LOCATION + drawLocation(width, offset, mc); - 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 - ); + //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 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 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 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) { + public void drawLocation(int width, int offset, Minecraft mc) { 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 + (width / 2) - + 33 - + ( + font.getStringWidth( + LocationHandler.getCurrentLocation().getDisplayName() + ) + ), + offset + (bossBarVisible ? 20 : 3), + 0, + 34, + 2, + 14 ); drawTexturedModalRect( - ((width / 2) - 33 - (font.getStringWidth(text))) + 2, - offset + (bossBarVisible ? 35 : 18), - 2, - 34, - font.getStringWidth(text) + 14, - 14 + ( + (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(text))) + 4, - offset + (bossBarVisible ? 38 : 21), - slayerType.getX(), - 24, - 8, - 8 + ( + (width / 2) - + 33 - + ( + font.getStringWidth( + LocationHandler.getCurrentLocation().getDisplayName() + ) + ) + ) + + 4, + offset + (bossBarVisible ? 23 : 6), + LocationHandler.getCurrentLocation().getCategory().getTexturePos(), + 8, + 8, + 8 ); drawString( - font, - text, - (width / 2) - 19 - (font.getStringWidth(text)), - offset + (bossBarVisible ? 38 : 21), - 0xFFFFFF + font, + LocationHandler.getCurrentLocation().getDisplayName(), + (width / 2) - + 19 - + ( + font.getStringWidth( + LocationHandler.getCurrentLocation().getDisplayName() + ) + ), + offset + (bossBarVisible ? 23 : 6), + 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 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 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 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 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; + //COINS drawTexturedModalRect( - (width / 2) - 33 - (font.getStringWidth(duration)), - offset + (bossBarVisible ? 35 : 18), - 0, - 34, - 2, - 14 + xPos, + offset + (bossBarVisible ? 35 : 18), + 2, + 34, + font.getStringWidth(CurrencyHandler.getCoinsFormatted()) + 11, + 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 + xPos + 1, + offset + (bossBarVisible ? 37 : 20), + 34, + 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 + 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; + } + drawTexturedModalRect( - ((width / 2) - 33 - (font.getStringWidth(text))) + 4, - offset + (bossBarVisible ? 38 : 21), - DwarvenMineHandler.currentEvent.x, - 0, - 8, - 8 + xPos, + offset + (bossBarVisible ? 35 : 18), + 252, + 34, + 4, + 14 ); - drawString( - font, - text, - (width / 2) - 19 - (font.getStringWidth(text)), - offset + (bossBarVisible ? 38 : 21), - 0xFFFFFF - ); - } } - } - @SubscribeEvent - public void renderOverlay(RenderGameOverlayEvent.Post event) { - if ( - Utils.overlayShouldRender(event.type, SkyblockHud.hasSkyblockScoreboard()) + 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 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 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 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 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 + ); + } + } + } + + @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 ) { - 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.scale(factor, factor, 1); + drawCenteredString( + font, + text, + (int) (x / factor), + (int) (y / factor), + color ); - } - GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + GlStateManager.scale(1 / factor, 1 / factor, 1); } - } - - 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 5a7409e..885ff7a 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/overlay/RPGHud.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/overlay/RPGHud.java @@ -17,175 +17,188 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; 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 - ) + 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( + "#.##" ); - 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 + + 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 + ) ); - } - 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(); + 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(); + } } - } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/playerstats/ActionBarParsing.java b/src/main/java/com/thatgravyboat/skyblockhud/playerstats/ActionBarParsing.java index a67535f..a37726f 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/playerstats/ActionBarParsing.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/playerstats/ActionBarParsing.java @@ -14,161 +14,175 @@ import net.minecraftforge.fml.common.gameevent.TickEvent; public class ActionBarParsing { - private static String lastActionBar = ""; - private static String lastLowActionBar = ""; - private static IChatComponent lastLowEditedActionBar = null; + private static String lastActionBar = ""; + private static String lastLowActionBar = ""; + private static IChatComponent lastLowEditedActionBar = null; - private static final Pattern HealthRegex = Pattern.compile( - "([0-9]+)/([0-9]+)\u2764" - ); - private static final Pattern HealingRegex = Pattern.compile( - "\\+([0-9]+)[\u2586\u2585\u2584\u2583\u2582\u2581]" - ); - private static final Pattern DefenseRegex = Pattern.compile( - "([0-9]+)\u2748 Defense" - ); - private static final Pattern ManaRegex = Pattern.compile( - "([0-9]+)/([0-9]+)\u270E Mana" - ); - private static final Pattern ManaOverflowRegex = Pattern.compile( - "([0-9]+)/([0-9]+)\u270E ([0-9]+)\u02AC" - ); - private static final Pattern ManaDecreaseRegex = Pattern.compile( - "-([0-9]+) Mana \\(" - ); - private static final Pattern XpGainRegex = Pattern.compile( - "\\+(\\d*\\.?\\d*) (Farming|Mining|Combat|Foraging|Fishing|Enchanting|Alchemy|Carpentry|Runecrafting) \\((\\d*\\.?\\d*)%\\)" - ); + private static final Pattern HealthRegex = Pattern.compile( + "([0-9]+)/([0-9]+)\u2764" + ); + private static final Pattern HealingRegex = Pattern.compile( + "\\+([0-9]+)[\u2586\u2585\u2584\u2583\u2582\u2581]" + ); + private static final Pattern DefenseRegex = Pattern.compile( + "([0-9]+)\u2748 Defense" + ); + private static final Pattern ManaRegex = Pattern.compile( + "([0-9]+)/([0-9]+)\u270E Mana" + ); + private static final Pattern ManaOverflowRegex = Pattern.compile( + "([0-9]+)/([0-9]+)\u270E ([0-9]+)\u02AC" + ); + private static final Pattern ManaDecreaseRegex = Pattern.compile( + "-([0-9]+) Mana \\(" + ); + private static final Pattern XpGainRegex = Pattern.compile( + "\\+(\\d*\\.?\\d*) (Farming|Mining|Combat|Foraging|Fishing|Enchanting|Alchemy|Carpentry|Runecrafting) \\((\\d*\\.?\\d*)%\\)" + ); - private static final Pattern HealthReplaceRegex = Pattern.compile( - "\u00A7c([0-9]+)/([0-9]+)\u2764" - ); - private static final Pattern HealingReplaceRegex = Pattern.compile( - "\\+\u00A7c([0-9]+)[\u2586\u2585\u2584\u2583\u2582\u2581]" - ); - private static final Pattern HealthAbsorptionReplaceRegex = Pattern.compile( - "\u00A76([0-9]+)/([0-9]+)\u2764" - ); - private static final Pattern DefenseReplaceRegex = Pattern.compile( - "\u00A7a([0-9]+)\u00A7a\u2748 Defense" - ); - private static final Pattern ManaReplaceRegex = Pattern.compile( - "\u00A7b([0-9]+)/([0-9]+)\u270E Mana" - ); - private static final Pattern ManaOverflowReplaceRegex = Pattern.compile( - "\u00A7b([0-9]+)/([0-9]+)\u270E \u00A73([0-9]+)\u02AC" - ); + private static final Pattern HealthReplaceRegex = Pattern.compile( + "\u00A7c([0-9]+)/([0-9]+)\u2764" + ); + private static final Pattern HealingReplaceRegex = Pattern.compile( + "\\+\u00A7c([0-9]+)[\u2586\u2585\u2584\u2583\u2582\u2581]" + ); + private static final Pattern HealthAbsorptionReplaceRegex = Pattern.compile( + "\u00A76([0-9]+)/([0-9]+)\u2764" + ); + private static final Pattern DefenseReplaceRegex = Pattern.compile( + "\u00A7a([0-9]+)\u00A7a\u2748 Defense" + ); + private static final Pattern ManaReplaceRegex = Pattern.compile( + "\u00A7b([0-9]+)/([0-9]+)\u270E Mana" + ); + private static final Pattern ManaOverflowReplaceRegex = Pattern.compile( + "\u00A7b([0-9]+)/([0-9]+)\u270E \u00A73([0-9]+)\u02AC" + ); - private static int ticksSinceLastPrediction = 0; - private static boolean predict = false; + private static int ticksSinceLastPrediction = 0; + private static boolean predict = false; - @SubscribeEvent - public void tick(TickEvent.ClientTickEvent event) { - if (predict) { - ticksSinceLastPrediction++; - if (ticksSinceLastPrediction == 20 && SkyblockHud.config.rpg.showRpgHud) { - ticksSinceLastPrediction = 0; - RPGHud.manaPredictionUpdate(true, 0); - } + @SubscribeEvent + public void tick(TickEvent.ClientTickEvent event) { + if (predict) { + ticksSinceLastPrediction++; + if ( + ticksSinceLastPrediction == 20 && + SkyblockHud.config.rpg.showRpgHud + ) { + ticksSinceLastPrediction = 0; + RPGHud.manaPredictionUpdate(true, 0); + } + } } - } - @SubscribeEvent(priority = EventPriority.HIGHEST) - public void onStatusBarHigh(ClientChatReceivedEvent event) { - if ( - event.type == 2 && - SkyblockHud.hasSkyblockScoreboard() && - SkyblockHud.config.rpg.showRpgHud - ) { - parseActionBar(event.message.getUnformattedText()); + @SubscribeEvent(priority = EventPriority.HIGHEST) + public void onStatusBarHigh(ClientChatReceivedEvent event) { + if ( + event.type == 2 && + SkyblockHud.hasSkyblockScoreboard() && + SkyblockHud.config.rpg.showRpgHud + ) { + parseActionBar(event.message.getUnformattedText()); + } } - } - @SubscribeEvent(priority = EventPriority.LOW) - public void onStatusBarLow(ClientChatReceivedEvent event) { - if ( - event.type == 2 && - SkyblockHud.hasSkyblockScoreboard() && - SkyblockHud.config.rpg.showRpgHud - ) { - String message = event.message.getUnformattedText(); - if (lastLowEditedActionBar == null || !lastLowActionBar.equals(message)) { - lastLowActionBar = message; - message = HealthReplaceRegex.matcher(message).replaceAll(""); - message = HealthAbsorptionReplaceRegex.matcher(message).replaceAll(""); - message = DefenseReplaceRegex.matcher(message).replaceAll(""); - message = ManaReplaceRegex.matcher(message).replaceAll(""); - message = ManaOverflowReplaceRegex.matcher(message).replaceAll(""); + @SubscribeEvent(priority = EventPriority.LOW) + public void onStatusBarLow(ClientChatReceivedEvent event) { + if ( + event.type == 2 && + SkyblockHud.hasSkyblockScoreboard() && + SkyblockHud.config.rpg.showRpgHud + ) { + String message = event.message.getUnformattedText(); + if ( + lastLowEditedActionBar == null || + !lastLowActionBar.equals(message) + ) { + lastLowActionBar = message; + message = HealthReplaceRegex.matcher(message).replaceAll(""); + message = + HealthAbsorptionReplaceRegex + .matcher(message) + .replaceAll(""); + message = DefenseReplaceRegex.matcher(message).replaceAll(""); + message = ManaReplaceRegex.matcher(message).replaceAll(""); + message = + ManaOverflowReplaceRegex.matcher(message).replaceAll(""); - lastLowEditedActionBar = new ChatComponentText(message.trim()); - } - event.message = lastLowEditedActionBar; + lastLowEditedActionBar = new ChatComponentText(message.trim()); + } + event.message = lastLowEditedActionBar; + } } - } - public static void parseActionBar(String input) { - if (!lastActionBar.equals(input)) { - lastActionBar = input; - String bar = Utils.removeColor(input); + public static void parseActionBar(String input) { + if (!lastActionBar.equals(input)) { + lastActionBar = input; + String bar = Utils.removeColor(input); - Matcher HealthMatcher = HealthRegex.matcher(bar); - Matcher DefenseMatcher = DefenseRegex.matcher(bar); - Matcher ManaMatcher = ManaRegex.matcher(bar); - Matcher ManaUseMatcher = ManaDecreaseRegex.matcher(bar); - Matcher ManaOverflowMatcher = ManaOverflowRegex.matcher(bar); - Matcher XpGainMatcher = XpGainRegex.matcher(bar); + Matcher HealthMatcher = HealthRegex.matcher(bar); + Matcher DefenseMatcher = DefenseRegex.matcher(bar); + Matcher ManaMatcher = ManaRegex.matcher(bar); + Matcher ManaUseMatcher = ManaDecreaseRegex.matcher(bar); + Matcher ManaOverflowMatcher = ManaOverflowRegex.matcher(bar); + Matcher XpGainMatcher = XpGainRegex.matcher(bar); - boolean healthFound = HealthMatcher.find(); - boolean defenseFound = DefenseMatcher.find(); - boolean manaFound = ManaMatcher.find(); - boolean manaUseFound = ManaUseMatcher.find(); - boolean manaOverflowFound = ManaOverflowMatcher.find(); - boolean xpFound = XpGainMatcher.find(); + boolean healthFound = HealthMatcher.find(); + boolean defenseFound = DefenseMatcher.find(); + boolean manaFound = ManaMatcher.find(); + boolean manaUseFound = ManaUseMatcher.find(); + boolean manaOverflowFound = ManaOverflowMatcher.find(); + boolean xpFound = XpGainMatcher.find(); - if (healthFound) { - try { - RPGHud.updateHealth( - Integer.parseInt(HealthMatcher.group(1)), - Integer.parseInt(HealthMatcher.group(2)) - ); - } catch (Exception ignored) {} - } - if (defenseFound) { - try { - RPGHud.updateDefense(Integer.parseInt(DefenseMatcher.group(1))); - } catch (Exception ignored) {} - } else if (!xpFound && !manaUseFound) { - RPGHud.updateDefense(0); - } - if (manaFound) { - try { - RPGHud.updateMana( - Integer.parseInt(ManaMatcher.group(1)), - Integer.parseInt(ManaMatcher.group(2)) - ); - } catch (Exception ignored) {} - } - if (!manaFound && manaOverflowFound) { - try { - RPGHud.updateMana( - Integer.parseInt(ManaOverflowMatcher.group(1)), - Integer.parseInt(ManaOverflowMatcher.group(2)) - ); - RPGHud.updateOverflow(Integer.parseInt(ManaOverflowMatcher.group(3))); - } catch (Exception ignored) {} - } - if (!manaFound) { - if (manaUseFound) { - try { - RPGHud.manaPredictionUpdate( - false, - Integer.parseInt(ManaUseMatcher.group(1)) - ); - } catch (Exception ignored) {} + if (healthFound) { + try { + RPGHud.updateHealth( + Integer.parseInt(HealthMatcher.group(1)), + Integer.parseInt(HealthMatcher.group(2)) + ); + } catch (Exception ignored) {} + } + if (defenseFound) { + try { + RPGHud.updateDefense( + Integer.parseInt(DefenseMatcher.group(1)) + ); + } catch (Exception ignored) {} + } else if (!xpFound && !manaUseFound) { + RPGHud.updateDefense(0); + } + if (manaFound) { + try { + RPGHud.updateMana( + Integer.parseInt(ManaMatcher.group(1)), + Integer.parseInt(ManaMatcher.group(2)) + ); + } catch (Exception ignored) {} + } + if (!manaFound && manaOverflowFound) { + try { + RPGHud.updateMana( + Integer.parseInt(ManaOverflowMatcher.group(1)), + Integer.parseInt(ManaOverflowMatcher.group(2)) + ); + RPGHud.updateOverflow( + Integer.parseInt(ManaOverflowMatcher.group(3)) + ); + } catch (Exception ignored) {} + } + if (!manaFound) { + if (manaUseFound) { + try { + RPGHud.manaPredictionUpdate( + false, + Integer.parseInt(ManaUseMatcher.group(1)) + ); + } catch (Exception ignored) {} + } + RPGHud.manaPredictionUpdate(true, 0); + } + predict = !manaFound; } - RPGHud.manaPredictionUpdate(true, 0); - } - predict = !manaFound; } - } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/seasons/Season.java b/src/main/java/com/thatgravyboat/skyblockhud/seasons/Season.java index 61524ee..da14204 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/seasons/Season.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/seasons/Season.java @@ -1,53 +1,53 @@ package com.thatgravyboat.skyblockhud.seasons; public enum Season { - EARLYSPRING("earlyspring", "Early Spring", 34, 0), - SPRING("spring", "Spring", 34, 31), - LATESPRING("latespring", "Late Spring", 34, 62), - EARLYSUMMER("earlysummer", "Early Summer", 42, 93), - SUMMER("summer", "Summer", 42, 124), - LATESUMMER("latesummer", "Late Summer", 42, 155), - EARLYAUTUMN("earlyautumn", "Early Autumn", 50, 186), - AUTUMN("autumn", "Autumn", 50, 217), - LATEAUTUMN("lateautumn", "Late Autumn", 50, 248), - EARLYWINTER("earlywinter", "Early Winter", 58, 279), - WINTER("winter", "Winter", 58, 310), - LATEWINTER("latewinter", "Late Winter", 58, 341), - ERROR("error", "Error", 0, -1); - - private final String name; - private final String displayName; - private final int textureX; - private final int yearStartDay; - - Season(String name, String displayName, int textureX, int yearStartDay) { - this.name = name; - this.displayName = displayName; - this.textureX = textureX; - this.yearStartDay = yearStartDay; - } - - public String getName() { - return this.name; - } - - public String getDisplayName() { - return this.displayName; - } - - public int getTextureX() { - return this.textureX; - } - - public int getYearStartDay() { - return yearStartDay; - } - - public static Season get(String id) { - try { - return Season.valueOf(id); - } catch (IllegalArgumentException ex) { - return ERROR; + EARLYSPRING("earlyspring", "Early Spring", 34, 0), + SPRING("spring", "Spring", 34, 31), + LATESPRING("latespring", "Late Spring", 34, 62), + EARLYSUMMER("earlysummer", "Early Summer", 42, 93), + SUMMER("summer", "Summer", 42, 124), + LATESUMMER("latesummer", "Late Summer", 42, 155), + EARLYAUTUMN("earlyautumn", "Early Autumn", 50, 186), + AUTUMN("autumn", "Autumn", 50, 217), + LATEAUTUMN("lateautumn", "Late Autumn", 50, 248), + EARLYWINTER("earlywinter", "Early Winter", 58, 279), + WINTER("winter", "Winter", 58, 310), + LATEWINTER("latewinter", "Late Winter", 58, 341), + ERROR("error", "Error", 0, -1); + + private final String name; + private final String displayName; + private final int textureX; + private final int yearStartDay; + + Season(String name, String displayName, int textureX, int yearStartDay) { + this.name = name; + this.displayName = displayName; + this.textureX = textureX; + this.yearStartDay = yearStartDay; + } + + public String getName() { + return this.name; + } + + public String getDisplayName() { + return this.displayName; + } + + public int getTextureX() { + return this.textureX; + } + + public int getYearStartDay() { + return yearStartDay; + } + + public static Season get(String id) { + try { + return Season.valueOf(id); + } catch (IllegalArgumentException ex) { + return ERROR; + } } - } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/seasons/SeasonDateHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/seasons/SeasonDateHandler.java index 06b7009..609b3b7 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/seasons/SeasonDateHandler.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/seasons/SeasonDateHandler.java @@ -7,99 +7,101 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; public class SeasonDateHandler { - private static Season currentSeason = Season.ERROR; - private static int currentDate = 1; - private static String currentEvent = ""; - private static String eventTime = ""; + private static Season currentSeason = Season.ERROR; + private static int currentDate = 1; + private static String currentEvent = ""; + private static String eventTime = ""; - @SubscribeEvent - public void onSidebarLineUpdate(SidebarLineUpdateEvent event) { - if ( - Season.get( - SeasonDateHandler - .removeDate(event.formattedLine.toLowerCase()) - .toUpperCase() - ) != - Season.ERROR - ) { - SeasonDateHandler.setCurrentDateAndSeason( - SeasonDateHandler.removeSeason( - Utils.removeColor(event.formattedLine.toLowerCase().trim()) - ), - SeasonDateHandler - .removeDate( - Utils.removeColor(event.formattedLine.toLowerCase().trim()) - ) - .toUpperCase() - ); + @SubscribeEvent + public void onSidebarLineUpdate(SidebarLineUpdateEvent event) { + if ( + Season.get( + SeasonDateHandler + .removeDate(event.formattedLine.toLowerCase()) + .toUpperCase() + ) != + Season.ERROR + ) { + SeasonDateHandler.setCurrentDateAndSeason( + SeasonDateHandler.removeSeason( + Utils.removeColor(event.formattedLine.toLowerCase().trim()) + ), + SeasonDateHandler + .removeDate( + Utils.removeColor( + event.formattedLine.toLowerCase().trim() + ) + ) + .toUpperCase() + ); + } } - } - public static void setCurrentDateAndSeason(int date, String season) { - currentDate = date; - currentSeason = Season.get(season); - } + public static void setCurrentDateAndSeason(int date, String season) { + currentDate = date; + currentSeason = Season.get(season); + } - public static void setCurrentEvent(String event, String time) { - currentEvent = event; - eventTime = time; - } + public static void setCurrentEvent(String event, String time) { + currentEvent = event; + eventTime = time; + } - public static Season getCurrentSeason() { - return currentSeason; - } + public static Season getCurrentSeason() { + return currentSeason; + } - public static int getCurrentDate() { - return currentDate; - } + public static int getCurrentDate() { + return currentDate; + } - private static String getDataSuffix(int date) { - if (date > 10 && date < 14) return "th"; - switch (date % 10) { - case 1: - return "st"; - case 2: - return "nd"; - case 3: - return "rd"; - default: - return "th"; + private static String getDataSuffix(int date) { + if (date > 10 && date < 14) return "th"; + switch (date % 10) { + case 1: + return "st"; + case 2: + return "nd"; + case 3: + return "rd"; + default: + return "th"; + } } - } - public static String getFancySeasonAndDate() { - return ( - currentSeason.getDisplayName() + - " " + - currentDate + - getDataSuffix(currentDate) - ); - } + public static String getFancySeasonAndDate() { + return ( + currentSeason.getDisplayName() + + " " + + currentDate + + getDataSuffix(currentDate) + ); + } - public static String getCurrentEvent() { - return currentEvent; - } + public static String getCurrentEvent() { + return currentEvent; + } - public static String getCurrentEventTime() { - return eventTime; - } + public static String getCurrentEventTime() { + return eventTime; + } - public static String removeDate(String seasonDate) { - return Pattern - .compile("[^a-zA-Z]") - .matcher(seasonDate.toLowerCase()) - .replaceAll("") - .replaceAll("st|nd|rd|th", "") - .trim(); - } + public static String removeDate(String seasonDate) { + return Pattern + .compile("[^a-zA-Z]") + .matcher(seasonDate.toLowerCase()) + .replaceAll("") + .replaceAll("st|nd|rd|th", "") + .trim(); + } - public static int removeSeason(String seasonDate) { - return Integer.parseInt( - Pattern - .compile("[^0-9]") - .matcher(seasonDate.toLowerCase()) - .replaceAll("") - .trim() - ); - } + public static int removeSeason(String seasonDate) { + return Integer.parseInt( + Pattern + .compile("[^0-9]") + .matcher(seasonDate.toLowerCase()) + .replaceAll("") + .trim() + ); + } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/tracker/KillTrackerHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/tracker/KillTrackerHandler.java index d82a521..552837b 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/tracker/KillTrackerHandler.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/tracker/KillTrackerHandler.java @@ -13,72 +13,74 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; public class KillTrackerHandler { - public static final Set attackedEntities = new HashSet<>(); + public static final Set attackedEntities = new HashSet<>(); - @SubscribeEvent - public void onAttack(AttackEntityEvent event) { - if (event.target != null) { - attackedEntities.add(event.target.getUniqueID()); + @SubscribeEvent + public void onAttack(AttackEntityEvent event) { + if (event.target != null) { + attackedEntities.add(event.target.getUniqueID()); + } } - } - @SubscribeEvent - public void onDeath(LivingDeathEvent event) { - if (false) { - //Used for testing - System.out.println( - "----------------------------------------------------------------------------------------------------------------" - ); - System.out.println("Name : " + event.entity.getName()); - System.out.println("UUID : " + event.entity.getUniqueID()); - NBTTagCompound tag = new NBTTagCompound(); - event.entity.writeToNBT(tag); - System.out.println("Tag : " + tag); - System.out.println("Damage : " + getDamageSourceString(event.source)); - System.out.println( - "----------------------------------------------------------------------------------------------------------------" - ); - } + @SubscribeEvent + public void onDeath(LivingDeathEvent event) { + if (false) { + //Used for testing + System.out.println( + "----------------------------------------------------------------------------------------------------------------" + ); + System.out.println("Name : " + event.entity.getName()); + System.out.println("UUID : " + event.entity.getUniqueID()); + NBTTagCompound tag = new NBTTagCompound(); + event.entity.writeToNBT(tag); + System.out.println("Tag : " + tag); + System.out.println( + "Damage : " + getDamageSourceString(event.source) + ); + System.out.println( + "----------------------------------------------------------------------------------------------------------------" + ); + } - attackedEntities.remove(event.entity.getUniqueID()); - } + attackedEntities.remove(event.entity.getUniqueID()); + } - public static String getDamageSourceString(DamageSource source) { - return ( - "{ " + - source.getDamageType() + - ", " + - source.isDamageAbsolute() + - ", " + - source.isDifficultyScaled() + - ", " + - source.isFireDamage() + - ", " + - source.isProjectile() + - ", " + - source.isUnblockable() + - ", " + - source.isExplosion() + - ", " + - source.isMagicDamage() + - ", " + - source.isCreativePlayer() + - ", " + - source.getSourceOfDamage() + - " }" - ); - } + public static String getDamageSourceString(DamageSource source) { + return ( + "{ " + + source.getDamageType() + + ", " + + source.isDamageAbsolute() + + ", " + + source.isDifficultyScaled() + + ", " + + source.isFireDamage() + + ", " + + source.isProjectile() + + ", " + + source.isUnblockable() + + ", " + + source.isExplosion() + + ", " + + source.isMagicDamage() + + ", " + + source.isCreativePlayer() + + ", " + + source.getSourceOfDamage() + + " }" + ); + } - @SubscribeEvent - public void onWorldChange(EntityJoinWorldEvent event) { - if (event.entity != null) { - if ( - event.entity - .getUniqueID() - .equals(Minecraft.getMinecraft().thePlayer.getUniqueID()) - ) { - attackedEntities.clear(); - } + @SubscribeEvent + public void onWorldChange(EntityJoinWorldEvent event) { + if (event.entity != null) { + if ( + event.entity + .getUniqueID() + .equals(Minecraft.getMinecraft().thePlayer.getUniqueID()) + ) { + attackedEntities.clear(); + } + } } - } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/tracker/TrackerFileLoader.java b/src/main/java/com/thatgravyboat/skyblockhud/tracker/TrackerFileLoader.java index 4accb25..7035fee 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/tracker/TrackerFileLoader.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/tracker/TrackerFileLoader.java @@ -18,224 +18,237 @@ import net.minecraft.util.ResourceLocation; public class TrackerFileLoader { - private static final Gson gson = new GsonBuilder().create(); - - public static ItemStack getDisplayItem(JsonObject jsonObject) { - int meta = jsonObject.get("meta").getAsInt(); - String displayItemId = jsonObject.get("item").getAsString(); - Item item = Item.itemRegistry.getObject( - new ResourceLocation(displayItemId) - ); - ItemStack stack = new ItemStack(item, 0, meta); - if ( - jsonObject.has("skullData") && - displayItemId.equals("minecraft:skull") && - meta == 3 - ) { - stack.setTagInfo( - "SkullOwner", - getSkullTag(jsonObject.getAsJsonObject("skullData")) - ); - } - if ( - jsonObject.has("enchanted") && jsonObject.get("enchanted").getAsBoolean() - ) stack.setTagInfo("ench", new NBTTagList()); - return stack; - } - - public static NBTBase getSkullTag(JsonObject skullObject) { - NBTTagCompound skullOwner = new NBTTagCompound(); - NBTTagCompound properties = new NBTTagCompound(); - NBTTagList textures = new NBTTagList(); - NBTTagCompound value = new NBTTagCompound(); - - skullOwner.setString("Id", skullObject.get("id").getAsString()); - - value.setString("Value", skullObject.get("texture").getAsString()); - textures.appendTag(value); - - properties.setTag("textures", textures); - - skullOwner.setTag("Properties", properties); - return skullOwner; - } - - private static void loadTrackers(JsonObject object) { - for (JsonElement element : object.get("trackers").getAsJsonArray()) { - JsonObject tracker = element.getAsJsonObject(); - StringBuilder builder = new StringBuilder(); - tracker - .get("location") - .getAsJsonArray() - .forEach(loc -> builder.append(loc.getAsString())); - String location = builder.toString(); - - Map stacks = new HashMap<>(); - for (JsonElement drop : tracker.get("drops").getAsJsonArray()) { - JsonObject dropObject = drop.getAsJsonObject(); - - //Display Item Creation - ItemStack stack = getDisplayItem( - dropObject.getAsJsonObject("displayItem") + private static final Gson gson = new GsonBuilder().create(); + + public static ItemStack getDisplayItem(JsonObject jsonObject) { + int meta = jsonObject.get("meta").getAsInt(); + String displayItemId = jsonObject.get("item").getAsString(); + Item item = Item.itemRegistry.getObject( + new ResourceLocation(displayItemId) ); - String itemId = dropObject.get("id").getAsString(); + ItemStack stack = new ItemStack(item, 0, meta); + if ( + jsonObject.has("skullData") && + displayItemId.equals("minecraft:skull") && + meta == 3 + ) { + stack.setTagInfo( + "SkullOwner", + getSkullTag(jsonObject.getAsJsonObject("skullData")) + ); + } + if ( + jsonObject.has("enchanted") && + jsonObject.get("enchanted").getAsBoolean() + ) stack.setTagInfo("ench", new NBTTagList()); + return stack; + } - stacks.put(itemId, stack); - } + public static NBTBase getSkullTag(JsonObject skullObject) { + NBTTagCompound skullOwner = new NBTTagCompound(); + NBTTagCompound properties = new NBTTagCompound(); + NBTTagList textures = new NBTTagList(); + NBTTagCompound value = new NBTTagCompound(); - String event = tracker.has("event") - ? tracker.get("event").getAsString() - : null; + skullOwner.setString("Id", skullObject.get("id").getAsString()); - Map> events = new HashMap<>(); - events.put(event, stacks); + value.setString("Value", skullObject.get("texture").getAsString()); + textures.appendTag(value); - if (TrackerHandler.trackers.containsKey(location)) { - TrackerHandler.trackers.get(location).dropTrackers.put(event, stacks); - } else { - TrackerHandler.trackers.putIfAbsent( - location, - new TrackerHandler.TrackerData(events) - ); - } - - tracker - .get("location") - .getAsJsonArray() - .forEach( - loc -> - TrackerHandler.trackerIds.put( - Locations.get(loc.getAsString()), - location - ) + properties.setTag("textures", textures); + + skullOwner.setTag("Properties", properties); + return skullOwner; + } + + private static void loadTrackers(JsonObject object) { + for (JsonElement element : object.get("trackers").getAsJsonArray()) { + JsonObject tracker = element.getAsJsonObject(); + StringBuilder builder = new StringBuilder(); + tracker + .get("location") + .getAsJsonArray() + .forEach(loc -> builder.append(loc.getAsString())); + String location = builder.toString(); + + Map stacks = new HashMap<>(); + for (JsonElement drop : tracker.get("drops").getAsJsonArray()) { + JsonObject dropObject = drop.getAsJsonObject(); + + //Display Item Creation + ItemStack stack = getDisplayItem( + dropObject.getAsJsonObject("displayItem") + ); + String itemId = dropObject.get("id").getAsString(); + + stacks.put(itemId, stack); + } + + String event = tracker.has("event") + ? tracker.get("event").getAsString() + : null; + + Map> events = new HashMap<>(); + events.put(event, stacks); + + if (TrackerHandler.trackers.containsKey(location)) { + TrackerHandler.trackers + .get(location) + .dropTrackers.put(event, stacks); + } else { + TrackerHandler.trackers.putIfAbsent( + location, + new TrackerHandler.TrackerData(events) + ); + } + + tracker + .get("location") + .getAsJsonArray() + .forEach( + loc -> + TrackerHandler.trackerIds.put( + Locations.get(loc.getAsString()), + location + ) + ); + } + } + + private static JsonElement getTrackerFile() { + List trackerStats = new ArrayList<>(); + TrackerHandler.trackers.forEach( + (locations, trackerData) -> + trackerData.dropTrackers.forEach( + (event, drops) -> { + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("location", locations); + + if (event == null) jsonObject.add( + "event", + new JsonNull() + ); else jsonObject.addProperty("event", event); + + JsonObject dropsData = new JsonObject(); + drops.forEach( + (s, stack) -> + dropsData.addProperty(s, stack.stackSize) + ); + jsonObject.add("drops", dropsData); + trackerStats.add(jsonObject); + } + ) ); + JsonArray stats = new JsonArray(); + trackerStats.forEach(stats::add); + return stats; } - } - - private static JsonElement getTrackerFile() { - List trackerStats = new ArrayList<>(); - TrackerHandler.trackers.forEach( - (locations, trackerData) -> - trackerData.dropTrackers.forEach( - (event, drops) -> { - JsonObject jsonObject = new JsonObject(); - jsonObject.addProperty("location", locations); - - if (event == null) jsonObject.add( - "event", - new JsonNull() - ); else jsonObject.addProperty("event", event); - - JsonObject dropsData = new JsonObject(); - drops.forEach( - (s, stack) -> dropsData.addProperty(s, stack.stackSize) + + public static void loadTrackersFile() { + try { + ResourceLocation trackers = new ResourceLocation( + "skyblockhud:data/trackers.json" ); - jsonObject.add("drops", dropsData); - trackerStats.add(jsonObject); - } - ) - ); - JsonArray stats = new JsonArray(); - trackerStats.forEach(stats::add); - return stats; - } - - public static void loadTrackersFile() { - try { - ResourceLocation trackers = new ResourceLocation( - "skyblockhud:data/trackers.json" - ); - InputStream is = Minecraft - .getMinecraft() - .getResourceManager() - .getResource(trackers) - .getInputStream(); - - try ( - BufferedReader reader = new BufferedReader( - new InputStreamReader(is, StandardCharsets.UTF_8) - ) - ) { - loadTrackers(gson.fromJson(reader, JsonObject.class)); - } - } catch (Exception ignored) {} - } - - public static boolean loadTrackerStatsFile(File configDirectory) { - File configFile = new File(configDirectory, "sbh-trackers-stats.json"); - - try { - if (configFile.createNewFile()) { - return true; - } - - try ( - BufferedReader reader = new BufferedReader( - new InputStreamReader( - new FileInputStream(configFile), - StandardCharsets.UTF_8 - ) - ) - ) { - JsonObject json = gson.fromJson(reader, JsonObject.class); - if (json.has("trackerStats")) { - json - .getAsJsonArray("trackerStats") - .forEach( - element -> { - if (element.isJsonObject()) { - JsonObject object = element.getAsJsonObject(); - String location = object.get("location").getAsString(); - Map> trackers = TrackerHandler.trackers.get( - location - ) - .dropTrackers; - - JsonElement event = object.get("event"); - String eventString = event == null || event.isJsonNull() - ? null - : event.getAsString(); - Map drops = trackers.get(eventString); - - if (drops != null) { - for (Map.Entry drop : object - .getAsJsonObject("drops") - .entrySet()) { - if (drops.containsKey(drop.getKey())) { - drops.get(drop.getKey()).stackSize = - drop.getValue().getAsInt(); - } - } - drops = TrackerHandler.sortTrackers(drops); - trackers.put(eventString, drops); - } + InputStream is = Minecraft + .getMinecraft() + .getResourceManager() + .getResource(trackers) + .getInputStream(); + + try ( + BufferedReader reader = new BufferedReader( + new InputStreamReader(is, StandardCharsets.UTF_8) + ) + ) { + loadTrackers(gson.fromJson(reader, JsonObject.class)); + } + } catch (Exception ignored) {} + } + + public static boolean loadTrackerStatsFile(File configDirectory) { + File configFile = new File(configDirectory, "sbh-trackers-stats.json"); + + try { + if (configFile.createNewFile()) { + return true; + } + + try ( + BufferedReader reader = new BufferedReader( + new InputStreamReader( + new FileInputStream(configFile), + StandardCharsets.UTF_8 + ) + ) + ) { + JsonObject json = gson.fromJson(reader, JsonObject.class); + if (json.has("trackerStats")) { + json + .getAsJsonArray("trackerStats") + .forEach( + element -> { + if (element.isJsonObject()) { + JsonObject object = element.getAsJsonObject(); + String location = object + .get("location") + .getAsString(); + Map> trackers = TrackerHandler.trackers.get( + location + ) + .dropTrackers; + + JsonElement event = object.get("event"); + String eventString = event == null || + event.isJsonNull() + ? null + : event.getAsString(); + Map drops = trackers.get( + eventString + ); + + if (drops != null) { + for (Map.Entry drop : object + .getAsJsonObject("drops") + .entrySet()) { + if ( + drops.containsKey(drop.getKey()) + ) { + drops.get(drop.getKey()) + .stackSize = + drop.getValue().getAsInt(); + } + } + drops = + TrackerHandler.sortTrackers(drops); + trackers.put(eventString, drops); + } + } + } + ); } - } - ); - } - } - } catch (Exception ignored) {} - return false; - } - - public static void saveTrackerStatsFile(File configDirectory) { - File configFile = new File(configDirectory, "sbh-trackers-stats.json"); - - try { - configFile.createNewFile(); - - try ( - BufferedWriter writer = new BufferedWriter( - new OutputStreamWriter( - new FileOutputStream(configFile), - StandardCharsets.UTF_8 - ) - ) - ) { - JsonObject json = new JsonObject(); - json.add("trackerStats", getTrackerFile()); - writer.write(gson.toJson(json)); - } - } catch (IOException ignored) {} - } + } + } catch (Exception ignored) {} + return false; + } + + public static void saveTrackerStatsFile(File configDirectory) { + File configFile = new File(configDirectory, "sbh-trackers-stats.json"); + + try { + configFile.createNewFile(); + + try ( + BufferedWriter writer = new BufferedWriter( + new OutputStreamWriter( + new FileOutputStream(configFile), + StandardCharsets.UTF_8 + ) + ) + ) { + JsonObject json = new JsonObject(); + json.add("trackerStats", getTrackerFile()); + writer.write(gson.toJson(json)); + } + } catch (IOException ignored) {} + } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/tracker/TrackerHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/tracker/TrackerHandler.java index 1d1e33c..8c8a521 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/tracker/TrackerHandler.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/tracker/TrackerHandler.java @@ -18,164 +18,175 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; public class TrackerHandler { - public static class TrackerData { + public static class TrackerData { - public Map> dropTrackers; + public Map> dropTrackers; - public TrackerData(Map> trackers) { - this.dropTrackers = trackers; - } + public TrackerData(Map> trackers) { + this.dropTrackers = trackers; + } - public String getDropId(String event) { - if ( - event == null || - event.isEmpty() || - !eventGoing() || - !dropTrackers.containsKey(event.toLowerCase().trim()) - ) return null; - return event.toLowerCase().trim(); - } + public String getDropId(String event) { + if ( + event == null || + event.isEmpty() || + !eventGoing() || + !dropTrackers.containsKey(event.toLowerCase().trim()) + ) return null; + return event.toLowerCase().trim(); + } - private boolean eventGoing() { - return SeasonDateHandler - .getCurrentEventTime() - .trim() - .toLowerCase() - .contains("ends in"); - } - } - - public static Map trackers = new HashMap<>(); - public static Map trackerIds = new HashMap<>(); - - public static Map sortTrackers( - Map map - ) { - List> list = new ArrayList<>(map.entrySet()); - list.sort( - (entry1, entry2) -> - Integer.compare( - entry2.getValue().stackSize, - entry1.getValue().stackSize - ) - ); - - Map result = new LinkedHashMap<>(); - for (Map.Entry entry : list) { - result.put(entry.getKey(), entry.getValue()); + private boolean eventGoing() { + return SeasonDateHandler + .getCurrentEventTime() + .trim() + .toLowerCase() + .contains("ends in"); + } } - return result; - } - - public static void onItemAdded( - String id, - int amount, - String enchant, - int level - ) { - if ( - SkyblockHud.hasSkyblockScoreboard() && - trackerIds.containsKey(LocationHandler.getCurrentLocation()) - ) { - String trackerId = trackerIds.get(LocationHandler.getCurrentLocation()); - TrackerData tracked = trackers.get(trackerId); - String dropTrackerId = tracked.getDropId( - SeasonDateHandler.getCurrentEvent() - ); - Map tracker = tracked.dropTrackers.get(dropTrackerId); - String dropId = id; - if (enchant != null) { - dropId = enchant.toUpperCase() + ";" + level; - } - - if (tracker != null && tracker.containsKey(dropId)) { - ItemStack stack = tracker.get(dropId); - stack.stackSize += amount; - tracked.dropTrackers.put(dropTrackerId, sortTrackers(tracker)); - } - } - } - - public static void drawItemStack(ItemStack stack, int x, int y) { - if (stack == null) return; - RenderItem itemRender = Minecraft.getMinecraft().getRenderItem(); - RenderHelper.enableGUIStandardItemLighting(); - itemRender.zLevel = -145; - itemRender.renderItemAndEffectIntoGUI(stack, x, y); - itemRender.zLevel = 0; - RenderHelper.disableStandardItemLighting(); - } - - @SubscribeEvent - public void renderOverlay(RenderGameOverlayEvent.Post event) { - if ( - Utils.overlayShouldRender( - event.type, - SkyblockHud.hasSkyblockScoreboard(), - trackerIds.containsKey(LocationHandler.getCurrentLocation()), - !SkyblockHud.config.trackers.hideTracker - ) + public static Map trackers = new HashMap<>(); + public static Map trackerIds = new HashMap<>(); + + public static Map sortTrackers( + Map map ) { - String trackerId = trackerIds.get(LocationHandler.getCurrentLocation()); - Minecraft mc = Minecraft.getMinecraft(); - TrackerData tracked = trackers.get(trackerId); - - Map tracker = tracked.dropTrackers.get( - tracked.getDropId(SeasonDateHandler.getCurrentEvent()) - ); - if (tracker != null) { - Position pos = SkyblockHud.config.trackers.trackerPosition; - int startPos = pos.getAbsX( - event.resolution, - (tracker.size() >= 6 ? 120 : tracker.size() * 20) + List> list = new ArrayList<>( + map.entrySet() ); - int y = pos.getAbsY( - event.resolution, - (int) (10 + Math.ceil(tracker.size() / 5d) * 20) + list.sort( + (entry1, entry2) -> + Integer.compare( + entry2.getValue().stackSize, + entry1.getValue().stackSize + ) ); - Gui.drawRect(startPos, y, startPos + 120, y + 10, -1072689136); - mc.fontRendererObj.drawString( - "Tracker", - startPos + 4, - y + 1, - 0xffffff, - false - ); - y += 10; - Gui.drawRect( - startPos, - y, - startPos + (tracker.size() >= 6 ? 120 : tracker.size() * 20), - (int) (y + (Math.ceil(tracker.size() / 5d) * 20)), - 1610612736 - ); - int x = startPos; - for (ItemStack stack : tracker.values()) { - String s = String.valueOf(stack.stackSize); - GlStateManager.disableLighting(); - GlStateManager.enableDepth(); - drawItemStack(stack, x, y); - GlStateManager.disableDepth(); - GlStateManager.disableBlend(); - mc.fontRendererObj.drawStringWithShadow( - s, - (float) (x + 19 - 2 - mc.fontRendererObj.getStringWidth(s)), - (float) (y + 9), - stack.stackSize < 1 ? 16733525 : 16777215 - ); - GlStateManager.enableBlend(); - GlStateManager.enableDepth(); - - if ((x - startPos) / 20 == 5) { - x = startPos; - y += 20; - } else { - x += 20; - } + Map result = new LinkedHashMap<>(); + for (Map.Entry entry : list) { + result.put(entry.getKey(), entry.getValue()); + } + + return result; + } + + public static void onItemAdded( + String id, + int amount, + String enchant, + int level + ) { + if ( + SkyblockHud.hasSkyblockScoreboard() && + trackerIds.containsKey(LocationHandler.getCurrentLocation()) + ) { + String trackerId = trackerIds.get( + LocationHandler.getCurrentLocation() + ); + TrackerData tracked = trackers.get(trackerId); + String dropTrackerId = tracked.getDropId( + SeasonDateHandler.getCurrentEvent() + ); + Map tracker = tracked.dropTrackers.get( + dropTrackerId + ); + String dropId = id; + if (enchant != null) { + dropId = enchant.toUpperCase() + ";" + level; + } + + if (tracker != null && tracker.containsKey(dropId)) { + ItemStack stack = tracker.get(dropId); + stack.stackSize += amount; + tracked.dropTrackers.put(dropTrackerId, sortTrackers(tracker)); + } + } + } + + public static void drawItemStack(ItemStack stack, int x, int y) { + if (stack == null) return; + RenderItem itemRender = Minecraft.getMinecraft().getRenderItem(); + RenderHelper.enableGUIStandardItemLighting(); + itemRender.zLevel = -145; + itemRender.renderItemAndEffectIntoGUI(stack, x, y); + itemRender.zLevel = 0; + RenderHelper.disableStandardItemLighting(); + } + + @SubscribeEvent + public void renderOverlay(RenderGameOverlayEvent.Post event) { + if ( + Utils.overlayShouldRender( + event.type, + SkyblockHud.hasSkyblockScoreboard(), + trackerIds.containsKey(LocationHandler.getCurrentLocation()), + !SkyblockHud.config.trackers.hideTracker + ) + ) { + String trackerId = trackerIds.get( + LocationHandler.getCurrentLocation() + ); + Minecraft mc = Minecraft.getMinecraft(); + TrackerData tracked = trackers.get(trackerId); + + Map tracker = tracked.dropTrackers.get( + tracked.getDropId(SeasonDateHandler.getCurrentEvent()) + ); + if (tracker != null) { + Position pos = SkyblockHud.config.trackers.trackerPosition; + int startPos = pos.getAbsX( + event.resolution, + (tracker.size() >= 6 ? 120 : tracker.size() * 20) + ); + int y = pos.getAbsY( + event.resolution, + (int) (10 + Math.ceil(tracker.size() / 5d) * 20) + ); + + Gui.drawRect(startPos, y, startPos + 120, y + 10, -1072689136); + mc.fontRendererObj.drawString( + "Tracker", + startPos + 4, + y + 1, + 0xffffff, + false + ); + y += 10; + Gui.drawRect( + startPos, + y, + startPos + + (tracker.size() >= 6 ? 120 : tracker.size() * 20), + (int) (y + (Math.ceil(tracker.size() / 5d) * 20)), + 1610612736 + ); + int x = startPos; + for (ItemStack stack : tracker.values()) { + String s = String.valueOf(stack.stackSize); + GlStateManager.disableLighting(); + GlStateManager.enableDepth(); + drawItemStack(stack, x, y); + GlStateManager.disableDepth(); + GlStateManager.disableBlend(); + mc.fontRendererObj.drawStringWithShadow( + s, + (float) ( + x + 19 - 2 - mc.fontRendererObj.getStringWidth(s) + ), + (float) (y + 9), + stack.stackSize < 1 ? 16733525 : 16777215 + ); + GlStateManager.enableBlend(); + GlStateManager.enableDepth(); + + if ((x - startPos) / 20 == 5) { + x = startPos; + y += 20; + } else { + x += 20; + } + } + } } - } } - } } -- cgit From c04ca523f9fb9f7adefa74587db61f76deeae9f0 Mon Sep 17 00:00:00 2001 From: TymanWasTaken Date: Tue, 6 Jul 2021 17:20:49 -0400 Subject: Increase line width --- .prettierrc.yml | 3 +- .../skyblockhud/ComponentBuilder.java | 7 +- .../skyblockhud/ComponentHandler.java | 174 ++------ .../com/thatgravyboat/skyblockhud/GuiTextures.java | 65 +-- .../com/thatgravyboat/skyblockhud/SkyblockHud.java | 40 +- .../thatgravyboat/skyblockhud/SpecialColour.java | 40 +- .../java/com/thatgravyboat/skyblockhud/Utils.java | 134 +----- .../skyblockhud/api/LeaderboardGetter.java | 53 +-- .../skyblockhud/api/events/SidebarPostEvent.java | 6 +- .../skyblockhud/commands/Commands.java | 36 +- .../skyblockhud/commands/SimpleCommand.java | 32 +- .../skyblockhud/config/KeyBindings.java | 6 +- .../skyblockhud/config/SBHConfig.java | 158 ++----- .../skyblockhud/config/SBHConfigEditor.java | 458 ++++----------------- .../skyblockhud/core/BackgroundBlur.java | 88 +--- .../skyblockhud/core/ChromaColour.java | 40 +- .../skyblockhud/core/GlScissorStack.java | 19 +- .../skyblockhud/core/GuiElementBoolean.java | 29 +- .../skyblockhud/core/GuiElementColour.java | 350 +++------------- .../skyblockhud/core/GuiElementTextField.java | 302 +++----------- .../skyblockhud/core/GuiScreenElementWrapper.java | 7 +- .../skyblockhud/core/config/Position.java | 22 +- .../core/config/gui/GuiOptionEditor.java | 42 +- .../core/config/gui/GuiOptionEditorAccordion.java | 29 +- .../core/config/gui/GuiOptionEditorBoolean.java | 9 +- .../core/config/gui/GuiOptionEditorButton.java | 11 +- .../core/config/gui/GuiOptionEditorColour.java | 19 +- .../config/gui/GuiOptionEditorDraggableList.java | 101 +---- .../core/config/gui/GuiOptionEditorDropdown.java | 72 +--- .../core/config/gui/GuiOptionEditorSlider.java | 44 +- .../core/config/gui/GuiOptionEditorText.java | 26 +- .../core/config/gui/GuiPositionEditor.java | 113 +---- .../core/config/struct/ConfigProcessor.java | 127 ++---- .../skyblockhud/core/util/GuiElementSlider.java | 87 +--- .../skyblockhud/core/util/MiscUtils.java | 41 +- .../skyblockhud/core/util/StringUtils.java | 5 +- .../skyblockhud/core/util/lerp/LerpUtils.java | 6 +- .../skyblockhud/core/util/lerp/LerpingFloat.java | 3 +- .../skyblockhud/core/util/lerp/LerpingInteger.java | 3 +- .../skyblockhud/core/util/render/RenderUtils.java | 193 ++------- .../core/util/render/TextRenderUtils.java | 69 +--- .../skyblockhud/dungeons/Classes.java | 4 +- .../skyblockhud/dungeons/DungeonHandler.java | 54 +-- .../skyblockhud/dungeons/DungeonPlayer.java | 7 +- .../skyblockhud/handlers/BossbarHandler.java | 12 +- .../skyblockhud/handlers/CurrencyHandler.java | 65 +-- .../skyblockhud/handlers/HeldItemHandler.java | 24 +- .../skyblockhud/handlers/MapHandler.java | 168 ++------ .../skyblockhud/handlers/SlayerHandler.java | 44 +- .../skyblockhud/handlers/TimeHandler.java | 27 +- .../handlers/mapicons/DwarvenIcons.java | 21 +- .../skyblockhud/handlers/mapicons/HubIcons.java | 27 +- .../handlers/sbentities/EntityTypeHelper.java | 12 +- .../handlers/sbentities/EntityTypeRegistry.java | 13 +- .../skyblockhud/location/DwarvenMineHandler.java | 43 +- .../skyblockhud/location/EndIslandHandler.java | 6 +- .../skyblockhud/location/FarmingIslandHandler.java | 13 +- .../skyblockhud/location/IslandHandler.java | 20 +- .../skyblockhud/location/LocationHandler.java | 9 +- .../skyblockhud/location/Locations.java | 210 ++-------- .../skyblockhud/location/ParkIslandHandler.java | 6 +- .../skyblockhud/mixins/MixinEndermanRenderer.java | 16 +- .../skyblockhud/mixins/MixinEntityArrow.java | 7 +- .../skyblockhud/mixins/MixinGuiIngameForge.java | 92 +---- .../mixins/MixinNetHandlerPlayClient.java | 11 +- .../skyblockhud/overlay/DungeonOverlay.java | 129 +----- .../skyblockhud/overlay/GenericOverlays.java | 44 +- .../skyblockhud/overlay/OverlayHud.java | 262 ++---------- .../thatgravyboat/skyblockhud/overlay/RPGHud.java | 59 +-- .../skyblockhud/playerstats/ActionBarParsing.java | 88 +--- .../skyblockhud/seasons/SeasonDateHandler.java | 36 +- .../skyblockhud/tracker/KillTrackerHandler.java | 10 +- .../skyblockhud/tracker/TrackerFileLoader.java | 116 ++---- .../skyblockhud/tracker/TrackerHandler.java | 75 +--- 74 files changed, 869 insertions(+), 3930 deletions(-) (limited to 'src/main/java/com/thatgravyboat/skyblockhud/overlay/DungeonOverlay.java') diff --git a/.prettierrc.yml b/.prettierrc.yml index 6001ba5..38071d1 100644 --- a/.prettierrc.yml +++ b/.prettierrc.yml @@ -5,4 +5,5 @@ overrides: useTabs: false trailingComma: none tabWidth: 4 - endOfLine: lf \ No newline at end of file + endOfLine: lf + printWidth: 120 \ No newline at end of file diff --git a/src/main/java/com/thatgravyboat/skyblockhud/ComponentBuilder.java b/src/main/java/com/thatgravyboat/skyblockhud/ComponentBuilder.java index 28c5485..b0c17be 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/ComponentBuilder.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/ComponentBuilder.java @@ -21,12 +21,7 @@ public class ComponentBuilder { } public ComponentBuilder apd(String text, char color) { - builder - .append("\u00A7") - .append(color) - .append(text) - .append("\u00A7") - .append('r'); + builder.append("\u00A7").append(color).append(text).append("\u00A7").append('r'); return this; } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/ComponentHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/ComponentHandler.java index ef2028d..0f4713f 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/ComponentHandler.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/ComponentHandler.java @@ -22,12 +22,8 @@ import net.minecraftforge.fml.relauncher.SideOnly; public class ComponentHandler { - public static final Pattern SCOREBOARD_CHARACTERS = Pattern.compile( - "[^]\\[a-z A-Z:0-9/'.()+\\d-§?]" - ); - private static final Ordering sortingList = Ordering.from( - new PlayerComparator() - ); + public static final Pattern SCOREBOARD_CHARACTERS = Pattern.compile("[^]\\[a-z A-Z:0-9/'.()+\\d-§?]"); + private static final Ordering sortingList = Ordering.from(new PlayerComparator()); private static int ticksExisted = 0; @SubscribeEvent @@ -36,65 +32,31 @@ public class ComponentHandler { ticksExisted++; boolean eventPass = false; if (mc.theWorld != null) { - List players = sortingList.sortedCopy( - mc.thePlayer.sendQueue.getPlayerInfoMap() - ); + List players = sortingList.sortedCopy(mc.thePlayer.sendQueue.getPlayerInfoMap()); GuiIngameForge.renderObjective = - !SkyblockHud.hasSkyblockScoreboard() || - !SkyblockHud.config.misc.hideScoreboard; + !SkyblockHud.hasSkyblockScoreboard() || !SkyblockHud.config.misc.hideScoreboard; if (players != null && SkyblockHud.hasSkyblockScoreboard()) { if (ticksExisted % 60 == 0) { for (NetworkPlayerInfo player : players) { if (player.getDisplayName() != null) { String formattedTabListPlayer = SCOREBOARD_CHARACTERS - .matcher( - Utils.removeColor( - player - .getDisplayName() - .getFormattedText() - ) - ) + .matcher(Utils.removeColor(player.getDisplayName().getFormattedText())) .replaceAll(""); - if ( - LocationHandler - .getCurrentLocation() - .equals(Locations.CATACOMBS) - ) { + if (LocationHandler.getCurrentLocation().equals(Locations.CATACOMBS)) { if ( - formattedTabListPlayer - .toLowerCase() - .contains("secrets found:") - ) DungeonHandler.parseTotalSecrets( - formattedTabListPlayer - ); + formattedTabListPlayer.toLowerCase().contains("secrets found:") + ) DungeonHandler.parseTotalSecrets(formattedTabListPlayer); if ( - formattedTabListPlayer - .toLowerCase() - .contains("deaths:") - ) DungeonHandler.parseDeaths( - formattedTabListPlayer - ); + formattedTabListPlayer.toLowerCase().contains("deaths:") + ) DungeonHandler.parseDeaths(formattedTabListPlayer); if ( - formattedTabListPlayer - .toLowerCase() - .contains("crypts:") - ) DungeonHandler.parseCrypts( - formattedTabListPlayer - ); + formattedTabListPlayer.toLowerCase().contains("crypts:") + ) DungeonHandler.parseCrypts(formattedTabListPlayer); } else if ( - LocationHandler - .getCurrentLocation() - .getCategory() - .equals(LocationCategory.DWARVENMINES) + LocationHandler.getCurrentLocation().getCategory().equals(LocationCategory.DWARVENMINES) ) { - if ( - formattedTabListPlayer - .toLowerCase() - .contains("mithril powder:") - ) { - DwarvenMineHandler.parseMithril( - formattedTabListPlayer - ); + if (formattedTabListPlayer.toLowerCase().contains("mithril powder:")) { + DwarvenMineHandler.parseMithril(formattedTabListPlayer); } } else if ( LocationHandler @@ -102,18 +64,11 @@ public class ComponentHandler { .getCategory() .equals(LocationCategory.MUSHROOMDESERT) ) { - if ( - formattedTabListPlayer - .toLowerCase() - .contains("pelts:") - ) { + if (formattedTabListPlayer.toLowerCase().contains("pelts:")) { try { FarmingIslandHandler.pelts = Integer.parseInt( - formattedTabListPlayer - .toLowerCase() - .replace("pelts:", "") - .trim() + formattedTabListPlayer.toLowerCase().replace("pelts:", "").trim() ); } catch (Exception ignored) {} } @@ -124,42 +79,20 @@ public class ComponentHandler { for (int i = 61; i <= 80; i++) { if (players.get(i).getDisplayName() != null) { String formattedTabListPlayer = SCOREBOARD_CHARACTERS - .matcher( - Utils.removeColor( - players - .get(i) - .getDisplayName() - .getFormattedText() - ) - ) + .matcher(Utils.removeColor(players.get(i).getDisplayName().getFormattedText())) .replaceAll(""); - if ( - formattedTabListPlayer - .toLowerCase() - .contains("event:") - ) { + if (formattedTabListPlayer.toLowerCase().contains("event:")) { if (i < 80) { - if ( - players - .get(i + 1) - .getDisplayName() != - null - ) { + if (players.get(i + 1).getDisplayName() != null) { String secondLine = SCOREBOARD_CHARACTERS .matcher( Utils.removeColor( - players - .get(i + 1) - .getDisplayName() - .getFormattedText() + players.get(i + 1).getDisplayName().getFormattedText() ) ) .replaceAll(""); SeasonDateHandler.setCurrentEvent( - formattedTabListPlayer.replace( - "Event:", - "" - ), + formattedTabListPlayer.replace("Event:", ""), secondLine ); eventPass = true; @@ -173,39 +106,16 @@ public class ComponentHandler { } } } - if ( - LocationHandler - .getCurrentLocation() - .getCategory() - .equals(LocationCategory.PARK) - ) { + if (LocationHandler.getCurrentLocation().getCategory().equals(LocationCategory.PARK)) { if (players.size() >= 80) { for (int i = 41; i <= 60; i++) { if (players.get(i).getDisplayName() != null) { String formattedTabListPlayer = SCOREBOARD_CHARACTERS - .matcher( - Utils.removeColor( - players - .get(i) - .getDisplayName() - .getFormattedText() - ) - ) + .matcher(Utils.removeColor(players.get(i).getDisplayName().getFormattedText())) .replaceAll(""); - if ( - LocationHandler - .getCurrentLocation() - .getCategory() - .equals(LocationCategory.PARK) - ) { - if ( - formattedTabListPlayer - .toLowerCase() - .contains("rain:") - ) { - ParkIslandHandler.parseRain( - formattedTabListPlayer.toLowerCase() - ); + if (LocationHandler.getCurrentLocation().getCategory().equals(LocationCategory.PARK)) { + if (formattedTabListPlayer.toLowerCase().contains("rain:")) { + ParkIslandHandler.parseRain(formattedTabListPlayer.toLowerCase()); } } } @@ -221,9 +131,9 @@ public class ComponentHandler { @SubscribeEvent(priority = EventPriority.HIGHEST) public void onStatusBar(ClientChatReceivedEvent event) { if (event.type == 2) { - if ( - LocationHandler.getCurrentLocation().equals(Locations.CATACOMBS) - ) DungeonHandler.parseSecrets(event.message.getFormattedText()); + if (LocationHandler.getCurrentLocation().equals(Locations.CATACOMBS)) DungeonHandler.parseSecrets( + event.message.getFormattedText() + ); } } @@ -232,32 +142,20 @@ public class ComponentHandler { private PlayerComparator() {} - public int compare( - NetworkPlayerInfo p_compare_1_, - NetworkPlayerInfo p_compare_2_ - ) { + public int compare(NetworkPlayerInfo p_compare_1_, NetworkPlayerInfo p_compare_2_) { ScorePlayerTeam scoreplayerteam = p_compare_1_.getPlayerTeam(); ScorePlayerTeam scoreplayerteam1 = p_compare_2_.getPlayerTeam(); return ComparisonChain .start() .compareTrueFirst( - p_compare_1_.getGameType() != - WorldSettings.GameType.SPECTATOR, - p_compare_2_.getGameType() != - WorldSettings.GameType.SPECTATOR - ) - .compare( - scoreplayerteam != null - ? scoreplayerteam.getRegisteredName() - : "", - scoreplayerteam1 != null - ? scoreplayerteam1.getRegisteredName() - : "" + p_compare_1_.getGameType() != WorldSettings.GameType.SPECTATOR, + p_compare_2_.getGameType() != WorldSettings.GameType.SPECTATOR ) .compare( - p_compare_1_.getGameProfile().getName(), - p_compare_2_.getGameProfile().getName() + scoreplayerteam != null ? scoreplayerteam.getRegisteredName() : "", + scoreplayerteam1 != null ? scoreplayerteam1.getRegisteredName() : "" ) + .compare(p_compare_1_.getGameProfile().getName(), p_compare_2_.getGameProfile().getName()) .result(); } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/GuiTextures.java b/src/main/java/com/thatgravyboat/skyblockhud/GuiTextures.java index d7c2513..af6b49c 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/GuiTextures.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/GuiTextures.java @@ -6,39 +6,19 @@ public class GuiTextures { private GuiTextures() {} - public static final ResourceLocation DISCORD = new ResourceLocation( - "skyblockhud:discord.png" - ); - public static final ResourceLocation TWITTER = new ResourceLocation( - "skyblockhud:twitter.png" - ); + public static final ResourceLocation DISCORD = new ResourceLocation("skyblockhud:discord.png"); + public static final ResourceLocation TWITTER = new ResourceLocation("skyblockhud:twitter.png"); - public static final ResourceLocation button_tex = new ResourceLocation( - "skyblockhud:button.png" - ); + public static final ResourceLocation button_tex = new ResourceLocation("skyblockhud:button.png"); - public static final ResourceLocation button_white = new ResourceLocation( - "skyblockhud:button_white.png" - ); + public static final ResourceLocation button_white = new ResourceLocation("skyblockhud:button_white.png"); - public static final ResourceLocation BAR = new ResourceLocation( - "skyblockhud:core/bar.png" - ); - public static final ResourceLocation OFF = new ResourceLocation( - "skyblockhud:core/toggle_off.png" - ); - public static final ResourceLocation ONE = new ResourceLocation( - "skyblockhud:core/toggle_1.png" - ); - public static final ResourceLocation TWO = new ResourceLocation( - "skyblockhud:core/toggle_2.png" - ); - public static final ResourceLocation THREE = new ResourceLocation( - "skyblockhud:core/toggle_3.png" - ); - public static final ResourceLocation ON = new ResourceLocation( - "skyblockhud:core/toggle_on.png" - ); + public static final ResourceLocation BAR = new ResourceLocation("skyblockhud:core/bar.png"); + public static final ResourceLocation OFF = new ResourceLocation("skyblockhud:core/toggle_off.png"); + public static final ResourceLocation ONE = new ResourceLocation("skyblockhud:core/toggle_1.png"); + public static final ResourceLocation TWO = new ResourceLocation("skyblockhud:core/toggle_2.png"); + public static final ResourceLocation THREE = new ResourceLocation("skyblockhud:core/toggle_3.png"); + public static final ResourceLocation ON = new ResourceLocation("skyblockhud:core/toggle_on.png"); public static final ResourceLocation slider_off_cap = new ResourceLocation( "skyblockhud:core/slider/slider_off_cap.png" @@ -62,24 +42,9 @@ public class GuiTextures { "skyblockhud:core/slider/slider_button.png" ); - public static final ResourceLocation overlay = new ResourceLocation( - "skyblockhud", - "stats.png" - ); - public static final ResourceLocation dungeon = new ResourceLocation( - "skyblockhud", - "dungeon.png" - ); - public static final ResourceLocation playerStat = new ResourceLocation( - "skyblockhud", - "playerstats.png" - ); - public static final ResourceLocation bars = new ResourceLocation( - "skyblockhud", - "bars.png" - ); - public static final ResourceLocation mapOverlay = new ResourceLocation( - "skyblockhud", - "maps/map_overlay.png" - ); + public static final ResourceLocation overlay = new ResourceLocation("skyblockhud", "stats.png"); + public static final ResourceLocation dungeon = new ResourceLocation("skyblockhud", "dungeon.png"); + public static final ResourceLocation playerStat = new ResourceLocation("skyblockhud", "playerstats.png"); + public static final ResourceLocation bars = new ResourceLocation("skyblockhud", "bars.png"); + public static final ResourceLocation mapOverlay = new ResourceLocation("skyblockhud", "maps/map_overlay.png"); } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/SkyblockHud.java b/src/main/java/com/thatgravyboat/skyblockhud/SkyblockHud.java index dae040c..8cd8baf 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/SkyblockHud.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/SkyblockHud.java @@ -56,10 +56,7 @@ public class SkyblockHud { "\u7A7A\u5C9B\u751F\u5B58" ); - private final Gson gson = new GsonBuilder() - .setPrettyPrinting() - .excludeFieldsWithoutExposeAnnotation() - .create(); + private final Gson gson = new GsonBuilder().setPrettyPrinting().excludeFieldsWithoutExposeAnnotation().create(); private static File configDirectory; @@ -89,16 +86,12 @@ public class SkyblockHud { MinecraftForge.EVENT_BUS.register(new ActionBarParsing()); Commands.init(); - configFile = - new File(event.getModConfigurationDirectory(), "sbh-config.json"); + configFile = new File(event.getModConfigurationDirectory(), "sbh-config.json"); if (configFile.exists()) { try ( BufferedReader reader = new BufferedReader( - new InputStreamReader( - new FileInputStream(configFile), - StandardCharsets.UTF_8 - ) + new InputStreamReader(new FileInputStream(configFile), StandardCharsets.UTF_8) ) ) { config = gson.fromJson(reader, SBHConfig.class); @@ -122,10 +115,7 @@ public class SkyblockHud { try ( BufferedWriter writer = new BufferedWriter( - new OutputStreamWriter( - new FileOutputStream(configFile), - StandardCharsets.UTF_8 - ) + new OutputStreamWriter(new FileOutputStream(configFile), StandardCharsets.UTF_8) ) ) { writer.write(gson.toJson(config)); @@ -165,13 +155,9 @@ public class SkyblockHud { if (mc != null && mc.theWorld != null) { Scoreboard scoreboard = mc.theWorld.getScoreboard(); - ScoreObjective sidebarObjective = scoreboard.getObjectiveInDisplaySlot( - 1 - ); + ScoreObjective sidebarObjective = scoreboard.getObjectiveInDisplaySlot(1); if (sidebarObjective != null) { - String objectiveName = sidebarObjective - .getDisplayName() - .replaceAll("(?i)\\u00A7.", ""); + String objectiveName = sidebarObjective.getDisplayName().replaceAll("(?i)\\u00A7.", ""); for (String skyblock : SKYBLOCK_IN_ALL_LANGUAGES) { if (objectiveName.startsWith(skyblock)) { return true; @@ -185,18 +171,10 @@ public class SkyblockHud { @SubscribeEvent public void onTooltip(ItemTooltipEvent event) { - if ( - event.itemStack != null && - Keyboard.isKeyDown(Keyboard.KEY_BACKSLASH) - ) { + if (event.itemStack != null && Keyboard.isKeyDown(Keyboard.KEY_BACKSLASH)) { try { - StringSelection clipboard = new StringSelection( - event.itemStack.serializeNBT().toString() - ); - Toolkit - .getDefaultToolkit() - .getSystemClipboard() - .setContents(clipboard, clipboard); + StringSelection clipboard = new StringSelection(event.itemStack.serializeNBT().toString()); + Toolkit.getDefaultToolkit().getSystemClipboard().setContents(clipboard, clipboard); } catch (Exception ignored) {} } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/SpecialColour.java b/src/main/java/com/thatgravyboat/skyblockhud/SpecialColour.java index f675778..38a48cc 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/SpecialColour.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/SpecialColour.java @@ -5,24 +5,12 @@ import java.awt.*; public class SpecialColour { public static String special(int chromaSpeed, int alpha, int rgb) { - return special( - chromaSpeed, - alpha, - (rgb & 0xFF0000) >> 16, - (rgb & 0x00FF00) >> 8, - (rgb & 0x0000FF) - ); + return special(chromaSpeed, alpha, (rgb & 0xFF0000) >> 16, (rgb & 0x00FF00) >> 8, (rgb & 0x0000FF)); } private static final int RADIX = 10; - public static String special( - int chromaSpeed, - int alpha, - int r, - int g, - int b - ) { + public static String special(int chromaSpeed, int alpha, int r, int g, int b) { StringBuilder sb = new StringBuilder(); sb.append(Integer.toString(chromaSpeed, RADIX)).append(":"); sb.append(Integer.toString(alpha, RADIX)).append(":"); @@ -51,9 +39,7 @@ public class SpecialColour { int a = d[3]; int chr = d[4]; - return ( - (a & 0xFF) << 24 | (r & 0xFF) << 16 | (g & 0xFF) << 8 | (b & 0xFF) - ); + return ((a & 0xFF) << 24 | (r & 0xFF) << 16 | (g & 0xFF) << 8 | (b & 0xFF)); } public static int getSpeed(String special) { @@ -61,12 +47,7 @@ public class SpecialColour { } public static float getSecondsForSpeed(int speed) { - return ( - (255 - speed) / - 254f * - (MAX_CHROMA_SECS - MIN_CHROMA_SECS) + - MIN_CHROMA_SECS - ); + return ((255 - speed) / 254f * (MAX_CHROMA_SECS - MIN_CHROMA_SECS) + MIN_CHROMA_SECS); } private static final int MIN_CHROMA_SECS = 1; @@ -88,16 +69,12 @@ public class SpecialColour { if (chr > 0) { float seconds = getSecondsForSpeed(chr); - hsv[0] += - (System.currentTimeMillis() - startTime) / 1000f / seconds; + hsv[0] += (System.currentTimeMillis() - startTime) / 1000f / seconds; hsv[0] %= 1; if (hsv[0] < 0) hsv[0] += 1; } - return ( - (a & 0xFF) << 24 | - (Color.HSBtoRGB(hsv[0], hsv[1], hsv[2]) & 0x00FFFFFF) - ); + return ((a & 0xFF) << 24 | (Color.HSBtoRGB(hsv[0], hsv[1], hsv[2]) & 0x00FFFFFF)); } public static int rotateHue(int argb, int degrees) { @@ -111,9 +88,6 @@ public class SpecialColour { hsv[0] += degrees / 360f; hsv[0] %= 1; - return ( - (a & 0xFF) << 24 | - (Color.HSBtoRGB(hsv[0], hsv[1], hsv[2]) & 0x00FFFFFF) - ); + return ((a & 0xFF) << 24 | (Color.HSBtoRGB(hsv[0], hsv[1], hsv[2]) & 0x00FFFFFF)); } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/Utils.java b/src/main/java/com/thatgravyboat/skyblockhud/Utils.java index 9f6712c..f03c6c0 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/Utils.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/Utils.java @@ -23,25 +23,16 @@ import org.lwjgl.opengl.GL14; public class Utils { private static LinkedList guiScales = new LinkedList<>(); - private static ScaledResolution lastScale = new ScaledResolution( - Minecraft.getMinecraft() - ); + private static ScaledResolution lastScale = new ScaledResolution(Minecraft.getMinecraft()); //Labymod compatibility - private static FloatBuffer projectionMatrixOld = BufferUtils.createFloatBuffer( - 16 - ); - private static FloatBuffer modelviewMatrixOld = BufferUtils.createFloatBuffer( - 16 - ); + private static FloatBuffer projectionMatrixOld = BufferUtils.createFloatBuffer(16); + private static FloatBuffer modelviewMatrixOld = BufferUtils.createFloatBuffer(16); public static String removeColor(String input) { return input.replaceAll("(?i)\\u00A7.", ""); } - public static String removeWhiteSpaceAndRemoveWord( - String input, - String replace - ) { + public static String removeWhiteSpaceAndRemoveWord(String input, String replace) { return input.toLowerCase().replace(" ", "").replace(replace, ""); } @@ -55,9 +46,7 @@ public class Utils { Item.getByNameOrId("minecraft:redstone_torch") ) ); - if (player.getHeldItem() != null) return redstoneItems.contains( - player.getHeldItem().getItem() - ); + if (player.getHeldItem() != null) return redstoneItems.contains(player.getHeldItem().getItem()); return false; } @@ -119,16 +108,8 @@ public class Utils { } } - public static boolean overlayShouldRender( - RenderGameOverlayEvent.ElementType type, - boolean... booleans - ) { - return overlayShouldRender( - false, - type, - RenderGameOverlayEvent.ElementType.HOTBAR, - booleans - ); + public static boolean overlayShouldRender(RenderGameOverlayEvent.ElementType type, boolean... booleans) { + return overlayShouldRender(false, type, RenderGameOverlayEvent.ElementType.HOTBAR, booleans); } public static boolean overlayShouldRender( @@ -148,22 +129,13 @@ public class Utils { mc.gameSettings.showDebugInfo || ( mc.gameSettings.keyBindPlayerList.isKeyDown() && - ( - !mc.isIntegratedServerRunning() || - mc.thePlayer.sendQueue.getPlayerInfoMap().size() > 1 - ) + (!mc.isIntegratedServerRunning() || mc.thePlayer.sendQueue.getPlayerInfoMap().size() > 1) ) ) { return false; } } - return ( - shouldRender && - ( - (type == null && Loader.isModLoaded("labymod")) || - type == checkType - ) - ); + return (shouldRender && ((type == null && Loader.isModLoaded("labymod")) || type == checkType)); } public static void drawStringScaledMaxWidth( @@ -209,15 +181,7 @@ public class Utils { float factor = len / (float) strLen; float fontHeight = 8 * factor; - drawStringScaled( - str, - fr, - x - len / 2f, - y - fontHeight / 2f, - shadow, - colour, - factor - ); + drawStringScaled(str, fr, x - len / 2f, y - fontHeight / 2f, shadow, colour, factor); } public static void drawTexturedRect( @@ -240,59 +204,29 @@ public class Utils { GL11.GL_ONE_MINUS_SRC_ALPHA ); - GL11.glTexParameteri( - GL11.GL_TEXTURE_2D, - GL11.GL_TEXTURE_MIN_FILTER, - filter - ); - GL11.glTexParameteri( - GL11.GL_TEXTURE_2D, - GL11.GL_TEXTURE_MAG_FILTER, - filter - ); + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, filter); + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, filter); Tessellator tessellator = Tessellator.getInstance(); WorldRenderer worldrenderer = tessellator.getWorldRenderer(); worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX); worldrenderer.pos(x, y + height, 0.0D).tex(uMin, vMax).endVertex(); - worldrenderer - .pos(x + width, y + height, 0.0D) - .tex(uMax, vMax) - .endVertex(); + worldrenderer.pos(x + width, y + height, 0.0D).tex(uMax, vMax).endVertex(); worldrenderer.pos(x + width, y, 0.0D).tex(uMax, vMin).endVertex(); worldrenderer.pos(x, y, 0.0D).tex(uMin, vMin).endVertex(); tessellator.draw(); - GL11.glTexParameteri( - GL11.GL_TEXTURE_2D, - GL11.GL_TEXTURE_MIN_FILTER, - GL11.GL_NEAREST - ); - GL11.glTexParameteri( - GL11.GL_TEXTURE_2D, - GL11.GL_TEXTURE_MAG_FILTER, - GL11.GL_NEAREST - ); + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST); + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST); GlStateManager.disableBlend(); } - public static void drawTexturedRect( - float x, - float y, - float width, - float height - ) { + public static void drawTexturedRect(float x, float y, float width, float height) { drawTexturedRect(x, y, width, height, 0, 1, 0, 1); } - public static void drawTexturedRect( - float x, - float y, - float width, - float height, - int filter - ) { + public static void drawTexturedRect(float x, float y, float width, float height, int filter) { drawTexturedRect(x, y, width, height, 0, 1, 0, 1, filter); } @@ -306,17 +240,7 @@ public class Utils { float vMin, float vMax ) { - drawTexturedRect( - x, - y, - width, - height, - uMin, - uMax, - vMin, - vMax, - GL11.GL_LINEAR - ); + drawTexturedRect(x, y, width, height, uMin, uMax, vMin, vMax, GL11.GL_LINEAR); } public static void resetGuiScale() { @@ -350,14 +274,11 @@ public class Utils { int newScale = guiScales.size() > 0 ? Math.max(0, Math.min(4, guiScales.peek())) : Minecraft.getMinecraft().gameSettings.guiScale; - if (newScale == 0) newScale = - Minecraft.getMinecraft().gameSettings.guiScale; + if (newScale == 0) newScale = Minecraft.getMinecraft().gameSettings.guiScale; int oldScale = Minecraft.getMinecraft().gameSettings.guiScale; Minecraft.getMinecraft().gameSettings.guiScale = newScale; - ScaledResolution scaledresolution = new ScaledResolution( - Minecraft.getMinecraft() - ); + ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft()); Minecraft.getMinecraft().gameSettings.guiScale = oldScale; if (guiScales.size() > 0) { @@ -381,11 +302,7 @@ public class Utils { GlStateManager.loadIdentity(); GlStateManager.translate(0.0F, 0.0F, -2000.0F); } else { - if ( - Loader.isModLoaded("labymod") && - projectionMatrixOld.limit() > 0 && - modelviewMatrixOld.limit() > 0 - ) { + if (Loader.isModLoaded("labymod") && projectionMatrixOld.limit() > 0 && modelviewMatrixOld.limit() > 0) { GlStateManager.matrixMode(GL11.GL_PROJECTION); GL11.glLoadMatrix(projectionMatrixOld); GlStateManager.matrixMode(GL11.GL_MODELVIEW); @@ -411,14 +328,7 @@ public class Utils { return scaledresolution; } - public static void drawStringCentered( - String str, - FontRenderer fr, - float x, - float y, - boolean shadow, - int colour - ) { + public static void drawStringCentered(String str, FontRenderer fr, float x, float y, boolean shadow, int colour) { int strLen = fr.getStringWidth(str); float x2 = x - strLen / 2f; diff --git a/src/main/java/com/thatgravyboat/skyblockhud/api/LeaderboardGetter.java b/src/main/java/com/thatgravyboat/skyblockhud/api/LeaderboardGetter.java index b722df1..8d6002b 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/api/LeaderboardGetter.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/api/LeaderboardGetter.java @@ -33,39 +33,25 @@ public class LeaderboardGetter { Minecraft mc = Minecraft.getMinecraft(); if (mc.theWorld != null) { Scoreboard scoreboard = mc.theWorld.getScoreboard(); - ScoreObjective sidebarObjective = scoreboard.getObjectiveInDisplaySlot( - 1 - ); + ScoreObjective sidebarObjective = scoreboard.getObjectiveInDisplaySlot(1); if ( sidebarObjective != null && - !MinecraftForge.EVENT_BUS.post( - new SidebarPreGetEvent(scoreboard, sidebarObjective) - ) + !MinecraftForge.EVENT_BUS.post(new SidebarPreGetEvent(scoreboard, sidebarObjective)) ) { - Collection scoreList = sidebarObjective - .getScoreboard() - .getSortedScores(sidebarObjective); + Collection scoreList = sidebarObjective.getScoreboard().getSortedScores(sidebarObjective); Map scores = scoreList .stream() - .collect( - Collectors.toMap(Score::getScorePoints, this::getLine) - ); + .collect(Collectors.toMap(Score::getScorePoints, this::getLine)); if (!cachedScores.equals(scores)) { scores.forEach( (score, name) -> { - if ( - cachedScores.get(score) == null || - !cachedScores.get(score).equals(name) - ) { + if (cachedScores.get(score) == null || !cachedScores.get(score).equals(name)) { MinecraftForge.EVENT_BUS.post( new SidebarLineUpdateEvent( name, - SCOREBOARD_CHARACTERS - .matcher(name) - .replaceAll("") - .trim(), + SCOREBOARD_CHARACTERS.matcher(name).replaceAll("").trim(), score, scores.size(), scoreboard, @@ -80,35 +66,16 @@ public class LeaderboardGetter { scores .values() .stream() - .map( - name -> - SCOREBOARD_CHARACTERS - .matcher(name) - .replaceAll("") - .trim() - ) + .map(name -> SCOREBOARD_CHARACTERS.matcher(name).replaceAll("").trim()) .collect(Collectors.toList()); } - MinecraftForge.EVENT_BUS.post( - new SidebarPostEvent( - scoreboard, - sidebarObjective, - cachedScoresList - ) - ); + MinecraftForge.EVENT_BUS.post(new SidebarPostEvent(scoreboard, sidebarObjective, cachedScoresList)); } } } public String getLine(Score score) { - ScorePlayerTeam scorePlayerTeam = score - .getScoreScoreboard() - .getPlayersTeam(score.getPlayerName()); - return Utils.removeColor( - ScorePlayerTeam.formatPlayerName( - scorePlayerTeam, - score.getPlayerName() - ) - ); + ScorePlayerTeam scorePlayerTeam = score.getScoreScoreboard().getPlayersTeam(score.getPlayerName()); + return Utils.removeColor(ScorePlayerTeam.formatPlayerName(scorePlayerTeam, score.getPlayerName())); } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/api/events/SidebarPostEvent.java b/src/main/java/com/thatgravyboat/skyblockhud/api/events/SidebarPostEvent.java index 92ed25e..34d27e6 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/api/events/SidebarPostEvent.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/api/events/SidebarPostEvent.java @@ -12,11 +12,7 @@ public class SidebarPostEvent extends Event { public List scores; public String[] arrayScores; - public SidebarPostEvent( - Scoreboard scoreboard, - ScoreObjective objective, - List scores - ) { + public SidebarPostEvent(Scoreboard scoreboard, ScoreObjective objective, List scores) { this.scoreboard = scoreboard; this.objective = objective; this.scores = scores; diff --git a/src/main/java/com/thatgravyboat/skyblockhud/commands/Commands.java b/src/main/java/com/thatgravyboat/skyblockhud/commands/Commands.java index e09f324..8304906 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/commands/Commands.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/commands/Commands.java @@ -16,45 +16,23 @@ public class Commands { public void processCommand(ICommandSender sender, String[] args) { if (args.length > 0) { SkyblockHud.screenToOpen = - new GuiScreenElementWrapper( - new SBHConfigEditor( - SkyblockHud.config, - StringUtils.join(args, " ") - ) - ); + new GuiScreenElementWrapper(new SBHConfigEditor(SkyblockHud.config, StringUtils.join(args, " "))); } else { - SkyblockHud.screenToOpen = - new GuiScreenElementWrapper( - new SBHConfigEditor(SkyblockHud.config) - ); + SkyblockHud.screenToOpen = new GuiScreenElementWrapper(new SBHConfigEditor(SkyblockHud.config)); } } }; - private static final SimpleCommand settingsCommand = new SimpleCommand( - "sbh", - settingsRunnable - ); - private static final SimpleCommand settingsCommand2 = new SimpleCommand( - "sbhsettings", - settingsRunnable - ); - private static final SimpleCommand settingsCommand3 = new SimpleCommand( - "sbhud", - settingsRunnable - ); + private static final SimpleCommand settingsCommand = new SimpleCommand("sbh", settingsRunnable); + private static final SimpleCommand settingsCommand2 = new SimpleCommand("sbhsettings", settingsRunnable); + private static final SimpleCommand settingsCommand3 = new SimpleCommand("sbhud", settingsRunnable); private static final SimpleCommand mapCommand = new SimpleCommand( "sbhmap", new SimpleCommand.ProcessCommandRunnable() { public void processCommand(ICommandSender sender, String[] args) { - if ( - LocationHandler - .getCurrentLocation() - .getCategory() - .getMap() != - null - ) SkyblockHud.screenToOpen = new MapHandler.MapScreen(); + if (LocationHandler.getCurrentLocation().getCategory().getMap() != null) SkyblockHud.screenToOpen = + new MapHandler.MapScreen(); } } ); diff --git a/src/main/java/com/thatgravyboat/skyblockhud/commands/SimpleCommand.java b/src/main/java/com/thatgravyboat/skyblockhud/commands/SimpleCommand.java index 358ebe0..db23b8e 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/commands/SimpleCommand.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/commands/SimpleCommand.java @@ -20,11 +20,7 @@ public class SimpleCommand extends CommandBase { this.runnable = runnable; } - public SimpleCommand( - String commandName, - ProcessCommandRunnable runnable, - TabCompleteRunnable tabRunnable - ) { + public SimpleCommand(String commandName, ProcessCommandRunnable runnable, TabCompleteRunnable tabRunnable) { this.commandName = commandName; this.runnable = runnable; this.tabRunnable = tabRunnable; @@ -32,19 +28,12 @@ public class SimpleCommand extends CommandBase { public abstract static class ProcessCommandRunnable { - public abstract void processCommand( - ICommandSender sender, - String[] args - ); + public abstract void processCommand(ICommandSender sender, String[] args); } public abstract static class TabCompleteRunnable { - public abstract List tabComplete( - ICommandSender sender, - String[] args, - BlockPos pos - ); + public abstract List tabComplete(ICommandSender sender, String[] args, BlockPos pos); } public boolean canCommandSenderUseCommand(ICommandSender sender) { @@ -59,21 +48,12 @@ public class SimpleCommand extends CommandBase { return "/" + commandName; } - public void processCommand(ICommandSender sender, String[] args) - throws CommandException { + public void processCommand(ICommandSender sender, String[] args) throws CommandException { runnable.processCommand(sender, args); } - public List addTabCompletionOptions( - ICommandSender sender, - String[] args, - BlockPos pos - ) { - if (tabRunnable != null) return tabRunnable.tabComplete( - sender, - args, - pos - ); + public List addTabCompletionOptions(ICommandSender sender, String[] args, BlockPos pos) { + if (tabRunnable != null) return tabRunnable.tabComplete(sender, args, pos); return null; } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/config/KeyBindings.java b/src/main/java/com/thatgravyboat/skyblockhud/config/KeyBindings.java index 044bab9..9ffd352 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/config/KeyBindings.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/config/KeyBindings.java @@ -4,9 +4,5 @@ import net.minecraft.client.settings.KeyBinding; public class KeyBindings { - public static KeyBinding map = new KeyBinding( - "Opens the big map.", - 50, - "SkyblockHud" - ); + public static KeyBinding map = new KeyBinding("Opens the big map.", 50, "SkyblockHud"); } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/config/SBHConfig.java b/src/main/java/com/thatgravyboat/skyblockhud/config/SBHConfig.java index 52272b7..84e5483 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/config/SBHConfig.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/config/SBHConfig.java @@ -11,12 +11,7 @@ import net.minecraft.client.Minecraft; public class SBHConfig extends Config { - private void editOverlay( - String activeConfig, - int width, - int height, - Position position - ) { + private void editOverlay(String activeConfig, int width, int height, Position position) { Minecraft .getMinecraft() .displayGuiScreen( @@ -28,12 +23,7 @@ public class SBHConfig extends Config { () -> {}, () -> SkyblockHud.screenToOpen = - new GuiScreenElementWrapper( - new SBHConfigEditor( - SkyblockHud.config, - activeConfig - ) - ) + new GuiScreenElementWrapper(new SBHConfigEditor(SkyblockHud.config, activeConfig)) ) ); } @@ -41,17 +31,10 @@ public class SBHConfig extends Config { @Override public void executeRunnable(String runnableId) { String activeConfigCategory = null; - if ( - Minecraft.getMinecraft() - .currentScreen instanceof GuiScreenElementWrapper - ) { - GuiScreenElementWrapper wrapper = (GuiScreenElementWrapper) Minecraft.getMinecraft() - .currentScreen; + if (Minecraft.getMinecraft().currentScreen instanceof GuiScreenElementWrapper) { + GuiScreenElementWrapper wrapper = (GuiScreenElementWrapper) Minecraft.getMinecraft().currentScreen; if (wrapper.element instanceof SBHConfigEditor) { - activeConfigCategory = - ( - (SBHConfigEditor) wrapper.element - ).getSelectedCategoryName(); + activeConfigCategory = ((SBHConfigEditor) wrapper.element).getSelectedCategoryName(); } } @@ -60,36 +43,16 @@ public class SBHConfig extends Config { editOverlay(activeConfigCategory, 120, 47, rpg.rpgHudPosition); return; case "d1": - editOverlay( - activeConfigCategory, - 120, - 32, - dungeon.dungeonPlayer1 - ); + editOverlay(activeConfigCategory, 120, 32, dungeon.dungeonPlayer1); return; case "d2": - editOverlay( - activeConfigCategory, - 120, - 32, - dungeon.dungeonPlayer2 - ); + editOverlay(activeConfigCategory, 120, 32, dungeon.dungeonPlayer2); return; case "d3": - editOverlay( - activeConfigCategory, - 120, - 32, - dungeon.dungeonPlayer3 - ); + editOverlay(activeConfigCategory, 120, 32, dungeon.dungeonPlayer3); return; case "d4": - editOverlay( - activeConfigCategory, - 120, - 32, - dungeon.dungeonPlayer4 - ); + editOverlay(activeConfigCategory, 120, 32, dungeon.dungeonPlayer4); return; case "main": editOverlay(activeConfigCategory, 1000, 34, main.mainHudPos); @@ -101,12 +64,7 @@ public class SBHConfig extends Config { editOverlay(activeConfigCategory, 72, 72, map.miniMapPosition); return; case "tracker": - editOverlay( - activeConfigCategory, - 120, - 70, - trackers.trackerPosition - ); + editOverlay(activeConfigCategory, 120, 70, trackers.trackerPosition); return; } } @@ -142,10 +100,7 @@ public class SBHConfig extends Config { public static class Misc { @Expose - @ConfigOption( - name = "Hide Scoreboard", - desc = "Hides the scoreboard when in skyblock." - ) + @ConfigOption(name = "Hide Scoreboard", desc = "Hides the scoreboard when in skyblock.") @ConfigEditorBoolean public boolean hideScoreboard = false; } @@ -166,10 +121,7 @@ public class SBHConfig extends Config { public boolean twelveHourClock = false; @Expose - @ConfigOption( - name = "Shift hud with boss", - desc = "Shifts the hud when bossbar is visible." - ) + @ConfigOption(name = "Shift hud with boss", desc = "Shifts the hud when bossbar is visible.") @ConfigEditorBoolean public boolean bossShiftHud = true; @@ -185,18 +137,12 @@ public class SBHConfig extends Config { public static class RPGHud { @Expose - @ConfigOption( - name = "Show RPG Hud", - desc = "Allows you to show or hide the RPG Hud." - ) + @ConfigOption(name = "Show RPG Hud", desc = "Allows you to show or hide the RPG Hud.") @ConfigEditorBoolean public boolean showRpgHud = true; @Expose - @ConfigOption( - name = "RPG Hud Position", - desc = "Allows you to change the position of the RPG Hud." - ) + @ConfigOption(name = "RPG Hud Position", desc = "Allows you to change the position of the RPG Hud.") @ConfigEditorButton(runnableId = "rpg", buttonText = "Edit") public Position rpgHudPosition = new Position(1, 1); } @@ -209,48 +155,32 @@ public class SBHConfig extends Config { public boolean ultimateBar = false; @Expose - @ConfigOption( - name = "Hide Ultimate Bar", - desc = "Hides the custom ultimate bar." - ) + @ConfigOption(name = "Hide Ultimate Bar", desc = "Hides the custom ultimate bar.") @ConfigEditorBoolean @ConfigAccordionId(id = 2) public boolean hideUltimateBar = false; @Expose - @ConfigOption( - name = "Bar Position", - desc = "Change the position of the bar." - ) + @ConfigOption(name = "Bar Position", desc = "Change the position of the bar.") @ConfigEditorButton(runnableId = "ultimate", buttonText = "Edit") @ConfigAccordionId(id = 2) public Position barPosition = new Position(0, 50, true, false); @Expose - @ConfigOption( - name = "Bar Loading Color", - desc = "The color of the bar when its loading." - ) + @ConfigOption(name = "Bar Loading Color", desc = "The color of the bar when its loading.") @ConfigEditorColour @ConfigAccordionId(id = 2) public String barLoadColor = "159:0:0:0:255"; @Expose - @ConfigOption( - name = "Bar Full Color", - desc = "The color of the bar when its full." - ) + @ConfigOption(name = "Bar Full Color", desc = "The color of the bar when its full.") @ConfigEditorColour @ConfigAccordionId(id = 2) public String barFullColor = "255:0:0:0:255"; @Expose @ConfigOption(name = "Bar Style", desc = "Change the style of the bar") - @ConfigEditorDropdown( - values = { - "No Notch", "6 Notch", "10 Notch", "12 Notch", "20 Notch" - } - ) + @ConfigEditorDropdown(values = { "No Notch", "6 Notch", "10 Notch", "12 Notch", "20 Notch" }) @ConfigAccordionId(id = 2) public int barStyle = 2; @@ -260,10 +190,7 @@ public class SBHConfig extends Config { public boolean dungeonPlayerAccordion = false; @Expose - @ConfigOption( - name = "Hide Dungeon Players", - desc = "Allows you to hide the dungeon player hud" - ) + @ConfigOption(name = "Hide Dungeon Players", desc = "Allows you to hide the dungeon player hud") @ConfigEditorBoolean @ConfigAccordionId(id = 1) public boolean hideDungeonPlayers = false; @@ -278,46 +205,31 @@ public class SBHConfig extends Config { public int dungeonPlayerOpacity = 0; @Expose - @ConfigOption( - name = "Hide Dead Players", - desc = "Allows you to hide players that are dead or have left." - ) + @ConfigOption(name = "Hide Dead Players", desc = "Allows you to hide players that are dead or have left.") @ConfigEditorBoolean @ConfigAccordionId(id = 1) public boolean hideDeadDungeonPlayers = false; @Expose - @ConfigOption( - name = "Player Position 1", - desc = "Change the position of this dungeon player." - ) + @ConfigOption(name = "Player Position 1", desc = "Change the position of this dungeon player.") @ConfigEditorButton(runnableId = "d1", buttonText = "Edit") @ConfigAccordionId(id = 1) public Position dungeonPlayer1 = new Position(5, 5); @Expose - @ConfigOption( - name = "Player Position 2", - desc = "Change the position of this dungeon player." - ) + @ConfigOption(name = "Player Position 2", desc = "Change the position of this dungeon player.") @ConfigEditorButton(runnableId = "d2", buttonText = "Edit") @ConfigAccordionId(id = 1) public Position dungeonPlayer2 = new Position(5, 42); @Expose - @ConfigOption( - name = "Player Position 3", - desc = "Change the position of this dungeon player." - ) + @ConfigOption(name = "Player Position 3", desc = "Change the position of this dungeon player.") @ConfigEditorButton(runnableId = "d3", buttonText = "Edit") @ConfigAccordionId(id = 1) public Position dungeonPlayer3 = new Position(5, 79); @Expose - @ConfigOption( - name = "Player Position 4", - desc = "Change the position of this dungeon player." - ) + @ConfigOption(name = "Player Position 4", desc = "Change the position of this dungeon player.") @ConfigEditorButton(runnableId = "d4", buttonText = "Edit") @ConfigAccordionId(id = 1) public Position dungeonPlayer4 = new Position(5, 116); @@ -359,10 +271,7 @@ public class SBHConfig extends Config { public boolean hideArmor = true; @Expose - @ConfigOption( - name = "Hide Animal Hearts", - desc = "Hides Animal Hearts." - ) + @ConfigOption(name = "Hide Animal Hearts", desc = "Hides Animal Hearts.") @ConfigEditorBoolean public boolean hideAnimalHearts = true; } @@ -386,10 +295,7 @@ public class SBHConfig extends Config { public boolean showMiniMap = false; @Expose - @ConfigOption( - name = "Mini-Map Position", - desc = "Allows you to change the position of the Mini-Map." - ) + @ConfigOption(name = "Mini-Map Position", desc = "Allows you to change the position of the Mini-Map.") @ConfigEditorButton(runnableId = "map", buttonText = "Edit") public Position miniMapPosition = new Position(0, 100, false, false); @@ -432,18 +338,12 @@ public class SBHConfig extends Config { public static class Trackers { @Expose - @ConfigOption( - name = "Tracker Position", - desc = "Allows you to change the position of the Trackers." - ) + @ConfigOption(name = "Tracker Position", desc = "Allows you to change the position of the Trackers.") @ConfigEditorButton(runnableId = "tracker", buttonText = "Edit") public Position trackerPosition = new Position(-1, 200); @Expose - @ConfigOption( - name = "Hide Tracker", - desc = "It will still track the data just in case." - ) + @ConfigOption(name = "Hide Tracker", desc = "It will still track the data just in case.") @ConfigEditorBoolean public boolean hideTracker = false; } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/config/SBHConfigEditor.java b/src/main/java/com/thatgravyboat/skyblockhud/config/SBHConfigEditor.java index 0407607..3bac8ac 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/config/SBHConfigEditor.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/config/SBHConfigEditor.java @@ -29,10 +29,7 @@ import org.lwjgl.opengl.GL11; public class SBHConfigEditor extends GuiElement { - private static final ResourceLocation[] socialsIco = new ResourceLocation[] { - DISCORD, - TWITTER - }; + private static final ResourceLocation[] socialsIco = new ResourceLocation[] { DISCORD, TWITTER }; private static final String[] socialsLink = new String[] { "https://discord.gg/moulberry", "https://twitter.com/thatgravytboat/" @@ -71,12 +68,7 @@ public class SBHConfigEditor extends GuiElement { } if (selectedCategory == null) { for (Map.Entry category : processedConfig.entrySet()) { - if ( - category - .getValue() - .name.toLowerCase() - .startsWith(categoryOpen.toLowerCase()) - ) { + if (category.getValue().name.toLowerCase().startsWith(categoryOpen.toLowerCase())) { selectedCategory = category.getKey(); break; } @@ -84,12 +76,7 @@ public class SBHConfigEditor extends GuiElement { } if (selectedCategory == null) { for (Map.Entry category : processedConfig.entrySet()) { - if ( - category - .getValue() - .name.toLowerCase() - .contains(categoryOpen.toLowerCase()) - ) { + if (category.getValue().name.toLowerCase().contains(categoryOpen.toLowerCase())) { selectedCategory = category.getKey(); break; } @@ -130,19 +117,11 @@ public class SBHConfigEditor extends GuiElement { long currentTime = System.currentTimeMillis(); long delta = currentTime - openedMillis; - ScaledResolution scaledResolution = new ScaledResolution( - Minecraft.getMinecraft() - ); + ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); int width = scaledResolution.getScaledWidth(); int height = scaledResolution.getScaledHeight(); - int mouseX = - Mouse.getX() * width / Minecraft.getMinecraft().displayWidth; - int mouseY = - height - - Mouse.getY() * - height / - Minecraft.getMinecraft().displayHeight - - 1; + int mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth; + int mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1; float opacityFactor = LerpUtils.sigmoidZeroOne(delta / 500f); RenderUtils.drawGradientRect( @@ -155,18 +134,8 @@ public class SBHConfigEditor extends GuiElement { (int) (0x90 * opacityFactor) << 24 | 0x101010 ); - int xSize = Math.min( - scaledResolution.getScaledWidth() - - 100 / - scaledResolution.getScaleFactor(), - 500 - ); - int ySize = Math.min( - scaledResolution.getScaledHeight() - - 100 / - scaledResolution.getScaleFactor(), - 400 - ); + int xSize = Math.min(scaledResolution.getScaledWidth() - 100 / scaledResolution.getScaleFactor(), 500); + int ySize = Math.min(scaledResolution.getScaledHeight() - 100 / scaledResolution.getScaleFactor(), 400); int x = (scaledResolution.getScaledWidth() - xSize) / 2; int y = (scaledResolution.getScaledHeight() - ySize) / 2; @@ -215,62 +184,20 @@ public class SBHConfigEditor extends GuiElement { 0xa0a0a0 ); - RenderUtils.drawFloatingRectDark( - x + 4, - y + 49 - 20, - 140, - ySize - 54 + 20, - false - ); + RenderUtils.drawFloatingRectDark(x + 4, y + 49 - 20, 140, ySize - 54 + 20, false); int innerPadding = 20 / adjScaleFactor; int innerLeft = x + 4 + innerPadding; int innerRight = x + 144 - innerPadding; int innerTop = y + 49 + innerPadding; int innerBottom = y + ySize - 5 - innerPadding; - Gui.drawRect( - innerLeft, - innerTop, - innerLeft + 1, - innerBottom, - 0xff08080E - ); //Left - Gui.drawRect( - innerLeft + 1, - innerTop, - innerRight, - innerTop + 1, - 0xff08080E - ); //Top - Gui.drawRect( - innerRight - 1, - innerTop + 1, - innerRight, - innerBottom, - 0xff28282E - ); //Right - Gui.drawRect( - innerLeft + 1, - innerBottom - 1, - innerRight - 1, - innerBottom, - 0xff28282E - ); //Bottom - Gui.drawRect( - innerLeft + 1, - innerTop + 1, - innerRight - 1, - innerBottom - 1, - 0x6008080E - ); //Middle + Gui.drawRect(innerLeft, innerTop, innerLeft + 1, innerBottom, 0xff08080E); //Left + Gui.drawRect(innerLeft + 1, innerTop, innerRight, innerTop + 1, 0xff08080E); //Top + Gui.drawRect(innerRight - 1, innerTop + 1, innerRight, innerBottom, 0xff28282E); //Right + Gui.drawRect(innerLeft + 1, innerBottom - 1, innerRight - 1, innerBottom, 0xff28282E); //Bottom + Gui.drawRect(innerLeft + 1, innerTop + 1, innerRight - 1, innerBottom - 1, 0x6008080E); //Middle - GlScissorStack.push( - 0, - innerTop + 1, - scaledResolution.getScaledWidth(), - innerBottom - 1, - scaledResolution - ); + GlScissorStack.push(0, innerTop + 1, scaledResolution.getScaledWidth(), innerBottom - 1, scaledResolution); float catBarSize = 1; int catY = -categoryScroll.getValue(); @@ -278,79 +205,47 @@ public class SBHConfigEditor extends GuiElement { LinkedHashMap currentConfigEditing = getCurrentConfigEditing(); for (Map.Entry entry : currentConfigEditing.entrySet()) { String selectedCategory = getSelectedCategory(); - if ( - selectedCategory == null || - !currentConfigEditing.containsKey(selectedCategory) - ) { + if (selectedCategory == null || !currentConfigEditing.containsKey(selectedCategory)) { setSelectedCategory(entry.getKey()); } String catName = entry.getValue().name; if (entry.getKey().equals(getSelectedCategory())) { - catName = - EnumChatFormatting.DARK_AQUA.toString() + - EnumChatFormatting.UNDERLINE + - catName; + catName = EnumChatFormatting.DARK_AQUA.toString() + EnumChatFormatting.UNDERLINE + catName; } else { catName = EnumChatFormatting.GRAY + catName; } - TextRenderUtils.drawStringCenteredScaledMaxWidth( - catName, - fr, - x + 75, - y + 70 + catY, - false, - 100, - -1 - ); + TextRenderUtils.drawStringCenteredScaledMaxWidth(catName, fr, x + 75, y + 70 + catY, false, 100, -1); catY += 15; if (catY > 0) { catBarSize = LerpUtils.clampZeroOne( - (float) (innerBottom - innerTop - 2) / - (catY + 5 + categoryScroll.getValue()) + (float) (innerBottom - innerTop - 2) / (catY + 5 + categoryScroll.getValue()) ); } } - float catBarStart = - categoryScroll.getValue() / - (float) (catY + categoryScroll.getValue()); + float catBarStart = categoryScroll.getValue() / (float) (catY + categoryScroll.getValue()); float catBarEnd = catBarStart + catBarSize; if (catBarEnd > 1) { catBarEnd = 1; - if ( - categoryScroll.getTarget() / - (float) (catY + categoryScroll.getValue()) + - catBarSize < - 1 - ) { + if (categoryScroll.getTarget() / (float) (catY + categoryScroll.getValue()) + catBarSize < 1) { int target = optionsScroll.getTarget(); categoryScroll.setValue( (int) Math.ceil( - (catY + 5 + categoryScroll.getValue()) - - catBarSize * - (catY + 5 + categoryScroll.getValue()) + (catY + 5 + categoryScroll.getValue()) - catBarSize * (catY + 5 + categoryScroll.getValue()) ) ); categoryScroll.setTarget(target); } else { categoryScroll.setValue( (int) Math.ceil( - (catY + 5 + categoryScroll.getValue()) - - catBarSize * - (catY + 5 + categoryScroll.getValue()) + (catY + 5 + categoryScroll.getValue()) - catBarSize * (catY + 5 + categoryScroll.getValue()) ) ); } } int catDist = innerBottom - innerTop - 12; - Gui.drawRect( - innerLeft + 2, - innerTop + 5, - innerLeft + 7, - innerBottom - 5, - 0xff101010 - ); + Gui.drawRect(innerLeft + 2, innerTop + 5, innerLeft + 7, innerBottom - 5, 0xff101010); Gui.drawRect( innerLeft + 3, innerTop + 6 + (int) (catDist * catBarStart), @@ -361,23 +256,9 @@ public class SBHConfigEditor extends GuiElement { GlScissorStack.pop(scaledResolution); - TextRenderUtils.drawStringCenteredScaledMaxWidth( - "Categories", - fr, - x + 75, - y + 44, - false, - 120, - 0xa368ef - ); + TextRenderUtils.drawStringCenteredScaledMaxWidth("Categories", fr, x + 75, y + 44, false, 120, 0xa368ef); - RenderUtils.drawFloatingRectDark( - x + 149, - y + 29, - xSize - 154, - ySize - 34, - false - ); + RenderUtils.drawFloatingRectDark(x + 149, y + 29, xSize - 154, ySize - 34, false); innerLeft = x + 149 + innerPadding; innerRight = x + xSize - 5 - innerPadding; @@ -386,13 +267,8 @@ public class SBHConfigEditor extends GuiElement { GlStateManager.color(1, 1, 1, 1); int rightStuffLen = 20; - if ( - getSelectedCategory() != null && - currentConfigEditing.containsKey(getSelectedCategory()) - ) { - ConfigProcessor.ProcessedCategory cat = currentConfigEditing.get( - getSelectedCategory() - ); + if (getSelectedCategory() != null && currentConfigEditing.containsKey(getSelectedCategory())) { + ConfigProcessor.ProcessedCategory cat = currentConfigEditing.get(getSelectedCategory()); TextRenderUtils.drawStringScaledMaxWidth( cat.desc, @@ -405,65 +281,21 @@ public class SBHConfigEditor extends GuiElement { ); } - Gui.drawRect( - innerLeft, - innerTop, - innerLeft + 1, - innerBottom, - 0xff08080E - ); //Left - Gui.drawRect( - innerLeft + 1, - innerTop, - innerRight, - innerTop + 1, - 0xff08080E - ); //Top - Gui.drawRect( - innerRight - 1, - innerTop + 1, - innerRight, - innerBottom, - 0xff303036 - ); //Right - Gui.drawRect( - innerLeft + 1, - innerBottom - 1, - innerRight - 1, - innerBottom, - 0xff303036 - ); //Bottom - Gui.drawRect( - innerLeft + 1, - innerTop + 1, - innerRight - 1, - innerBottom - 1, - 0x6008080E - ); //Middle + Gui.drawRect(innerLeft, innerTop, innerLeft + 1, innerBottom, 0xff08080E); //Left + Gui.drawRect(innerLeft + 1, innerTop, innerRight, innerTop + 1, 0xff08080E); //Top + Gui.drawRect(innerRight - 1, innerTop + 1, innerRight, innerBottom, 0xff303036); //Right + Gui.drawRect(innerLeft + 1, innerBottom - 1, innerRight - 1, innerBottom, 0xff303036); //Bottom + Gui.drawRect(innerLeft + 1, innerTop + 1, innerRight - 1, innerBottom - 1, 0x6008080E); //Middle - GlScissorStack.push( - innerLeft + 1, - innerTop + 1, - innerRight - 1, - innerBottom - 1, - scaledResolution - ); + GlScissorStack.push(innerLeft + 1, innerTop + 1, innerRight - 1, innerBottom - 1, scaledResolution); float barSize = 1; int optionY = -optionsScroll.getValue(); - if ( - getSelectedCategory() != null && - currentConfigEditing.containsKey(getSelectedCategory()) - ) { - ConfigProcessor.ProcessedCategory cat = currentConfigEditing.get( - getSelectedCategory() - ); + if (getSelectedCategory() != null && currentConfigEditing.containsKey(getSelectedCategory())) { + ConfigProcessor.ProcessedCategory cat = currentConfigEditing.get(getSelectedCategory()); int optionWidthDefault = innerRight - innerLeft - 20; GlStateManager.enableDepth(); Set activeAccordions = new HashSet<>(); - for (ConfigProcessor.ProcessedOption option : getOptionsInCategory( - cat - ) - .values()) { + for (ConfigProcessor.ProcessedOption option : getOptionsInCategory(cat).values()) { int optionWidth = optionWidthDefault; if (option.accordionId >= 0) { if (!activeAccordions.contains(option.accordionId)) { @@ -483,15 +315,8 @@ public class SBHConfigEditor extends GuiElement { } } int optionHeight = editor.getHeight(); - if ( - innerTop + 5 + optionY + optionHeight > innerTop + 1 && - innerTop + 5 + optionY < innerBottom - 1 - ) { - editor.render( - (innerLeft + innerRight - optionWidth) / 2 - 5, - innerTop + 5 + optionY, - optionWidth - ); + if (innerTop + 5 + optionY + optionHeight > innerTop + 1 && innerTop + 5 + optionY < innerBottom - 1) { + editor.render((innerLeft + innerRight - optionWidth) / 2 - 5, innerTop + 5 + optionY, optionWidth); } optionY += optionHeight + 5; } @@ -499,8 +324,7 @@ public class SBHConfigEditor extends GuiElement { if (optionY > 0) { barSize = LerpUtils.clampZeroOne( - (float) (innerBottom - innerTop - 2) / - (optionY + 5 + optionsScroll.getValue()) + (float) (innerBottom - innerTop - 2) / (optionY + 5 + optionsScroll.getValue()) ); } } @@ -508,23 +332,15 @@ public class SBHConfigEditor extends GuiElement { GlScissorStack.pop(scaledResolution); GL11.glDisable(GL11.GL_SCISSOR_TEST); - if ( - getSelectedCategory() != null && - currentConfigEditing.containsKey(getSelectedCategory()) - ) { + if (getSelectedCategory() != null && currentConfigEditing.containsKey(getSelectedCategory())) { int optionYOverlay = -optionsScroll.getValue(); - ConfigProcessor.ProcessedCategory cat = currentConfigEditing.get( - getSelectedCategory() - ); + ConfigProcessor.ProcessedCategory cat = currentConfigEditing.get(getSelectedCategory()); int optionWidthDefault = innerRight - innerLeft - 20; GlStateManager.translate(0, 0, 10); GlStateManager.enableDepth(); Set activeAccordions = new HashSet<>(); - for (ConfigProcessor.ProcessedOption option : getOptionsInCategory( - cat - ) - .values()) { + for (ConfigProcessor.ProcessedOption option : getOptionsInCategory(cat).values()) { int optionWidth = optionWidthDefault; if (option.accordionId >= 0) { if (!activeAccordions.contains(option.accordionId)) { @@ -545,12 +361,7 @@ public class SBHConfigEditor extends GuiElement { } int optionHeight = editor.getHeight(); if ( - innerTop + - 5 + - optionYOverlay + - optionHeight > - innerTop + - 1 && + innerTop + 5 + optionYOverlay + optionHeight > innerTop + 1 && innerTop + 5 + optionYOverlay < innerBottom - 1 ) { editor.renderOverlay( @@ -566,45 +377,28 @@ public class SBHConfigEditor extends GuiElement { } GL11.glEnable(GL11.GL_SCISSOR_TEST); - float barStart = - optionsScroll.getValue() / - (float) (optionY + optionsScroll.getValue()); + float barStart = optionsScroll.getValue() / (float) (optionY + optionsScroll.getValue()); float barEnd = barStart + barSize; if (barEnd > 1) { barEnd = 1; - if ( - optionsScroll.getTarget() / - (float) (optionY + optionsScroll.getValue()) + - barSize < - 1 - ) { + if (optionsScroll.getTarget() / (float) (optionY + optionsScroll.getValue()) + barSize < 1) { int target = optionsScroll.getTarget(); optionsScroll.setValue( (int) Math.ceil( - (optionY + 5 + optionsScroll.getValue()) - - barSize * - (optionY + 5 + optionsScroll.getValue()) + (optionY + 5 + optionsScroll.getValue()) - barSize * (optionY + 5 + optionsScroll.getValue()) ) ); optionsScroll.setTarget(target); } else { optionsScroll.setValue( (int) Math.ceil( - (optionY + 5 + optionsScroll.getValue()) - - barSize * - (optionY + 5 + optionsScroll.getValue()) + (optionY + 5 + optionsScroll.getValue()) - barSize * (optionY + 5 + optionsScroll.getValue()) ) ); } } int dist = innerBottom - innerTop - 12; - Gui.drawRect( - innerRight - 10, - innerTop + 5, - innerRight - 5, - innerBottom - 5, - 0xff101010 - ); + Gui.drawRect(innerRight - 10, innerTop + 5, innerRight - 5, innerBottom - 5, 0xff101010); Gui.drawRect( innerRight - 9, innerTop + 6 + (int) (dist * barStart), @@ -613,37 +407,16 @@ public class SBHConfigEditor extends GuiElement { 0xff303030 ); - for ( - int socialIndex = 0; - socialIndex < socialsIco.length; - socialIndex++ - ) { - Minecraft - .getMinecraft() - .getTextureManager() - .bindTexture(socialsIco[socialIndex]); + for (int socialIndex = 0; socialIndex < socialsIco.length; socialIndex++) { + Minecraft.getMinecraft().getTextureManager().bindTexture(socialsIco[socialIndex]); GlStateManager.color(1, 1, 1, 1); int socialLeft = x + xSize - 23 - 18 * socialIndex; - RenderUtils.drawTexturedRect( - socialLeft, - y + 7, - 16, - 16, - GL11.GL_LINEAR - ); + RenderUtils.drawTexturedRect(socialLeft, y + 7, 16, 16, GL11.GL_LINEAR); - if ( - mouseX >= socialLeft && - mouseX <= socialLeft + 16 && - mouseY >= y + 6 && - mouseY <= y + 23 - ) { + if (mouseX >= socialLeft && mouseX <= socialLeft + 16 && mouseY >= y + 6 && mouseY <= y + 23) { tooltipToDisplay = Lists.newArrayList( - EnumChatFormatting.YELLOW + - "Go to: " + - EnumChatFormatting.RESET + - socialsLink[socialIndex] + EnumChatFormatting.YELLOW + "Go to: " + EnumChatFormatting.RESET + socialsLink[socialIndex] ); } } @@ -651,35 +424,19 @@ public class SBHConfigEditor extends GuiElement { GlScissorStack.clear(); if (tooltipToDisplay != null) { - TextRenderUtils.drawHoveringText( - tooltipToDisplay, - mouseX, - mouseY, - width, - height, - -1, - fr - ); + TextRenderUtils.drawHoveringText(tooltipToDisplay, mouseX, mouseY, width, height, -1, fr); } GlStateManager.translate(0, 0, -2); } public boolean mouseInput(int mouseX, int mouseY) { - ScaledResolution scaledResolution = new ScaledResolution( - Minecraft.getMinecraft() - ); + ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); int width = scaledResolution.getScaledWidth(); int height = scaledResolution.getScaledHeight(); - int xSize = Math.min( - width - 100 / scaledResolution.getScaleFactor(), - 500 - ); - int ySize = Math.min( - height - 100 / scaledResolution.getScaleFactor(), - 400 - ); + int xSize = Math.min(width - 100 / scaledResolution.getScaleFactor(), 500); + int ySize = Math.min(height - 100 / scaledResolution.getScaleFactor(), 400); int x = (scaledResolution.getScaledWidth() - xSize) / 2; int y = (scaledResolution.getScaledHeight() - ySize) / 2; @@ -717,16 +474,11 @@ public class SBHConfigEditor extends GuiElement { catY += 15; if (catY > 0) { catBarSize = - LerpUtils.clampZeroOne( - (float) (innerBottom - innerTop - 2) / - (catY + 5 + newTarget) - ); + LerpUtils.clampZeroOne((float) (innerBottom - innerTop - 2) / (catY + 5 + newTarget)); } } - int barMax = (int) Math.floor( - (catY + 5 + newTarget) - catBarSize * (catY + 5 + newTarget) - ); + int barMax = (int) Math.floor((catY + 5 + newTarget) - catBarSize * (catY + 5 + newTarget)); if (newTarget > barMax) { newTarget = barMax; } @@ -745,17 +497,11 @@ public class SBHConfigEditor extends GuiElement { getCurrentConfigEditing() != null && getCurrentConfigEditing().containsKey(getSelectedCategory()) ) { - ConfigProcessor.ProcessedCategory cat = getCurrentConfigEditing() - .get(getSelectedCategory()); + ConfigProcessor.ProcessedCategory cat = getCurrentConfigEditing().get(getSelectedCategory()); Set activeAccordions = new HashSet<>(); - for (ConfigProcessor.ProcessedOption option : getOptionsInCategory( - cat - ) - .values()) { + for (ConfigProcessor.ProcessedOption option : getOptionsInCategory(cat).values()) { if (option.accordionId >= 0) { - if ( - !activeAccordions.contains(option.accordionId) - ) { + if (!activeAccordions.contains(option.accordionId)) { continue; } } @@ -767,9 +513,7 @@ public class SBHConfigEditor extends GuiElement { if (editor instanceof GuiOptionEditorAccordion) { GuiOptionEditorAccordion accordion = (GuiOptionEditorAccordion) editor; if (accordion.getToggled()) { - activeAccordions.add( - accordion.getAccordionId() - ); + activeAccordions.add(accordion.getAccordionId()); } } optionY += editor.getHeight() + 5; @@ -777,29 +521,18 @@ public class SBHConfigEditor extends GuiElement { if (optionY > 0) { barSize = LerpUtils.clampZeroOne( - (float) (innerBottom - innerTop - 2) / - (optionY + 5 + newTarget) + (float) (innerBottom - innerTop - 2) / (optionY + 5 + newTarget) ); } } } - int barMax = (int) Math.floor( - (optionY + 5 + newTarget) - - barSize * - (optionY + 5 + newTarget) - ); + int barMax = (int) Math.floor((optionY + 5 + newTarget) - barSize * (optionY + 5 + newTarget)); if (newTarget > barMax) { newTarget = barMax; } optionsScroll.setTimeToReachTarget( - Math.min( - 150, - Math.max( - 10, - 5 * Math.abs(newTarget - optionsScroll.getValue()) - ) - ) + Math.min(150, Math.max(10, 5 * Math.abs(newTarget - optionsScroll.getValue()))) ); optionsScroll.resetTimer(); optionsScroll.setTarget(newTarget); @@ -825,23 +558,12 @@ public class SBHConfigEditor extends GuiElement { } } - for ( - int socialIndex = 0; - socialIndex < socialsLink.length; - socialIndex++ - ) { + for (int socialIndex = 0; socialIndex < socialsLink.length; socialIndex++) { int socialLeft = x + xSize - 23 - 18 * socialIndex; - if ( - mouseX >= socialLeft && - mouseX <= socialLeft + 16 && - mouseY >= y + 6 && - mouseY <= y + 23 - ) { + if (mouseX >= socialLeft && mouseX <= socialLeft + 16 && mouseY >= y + 6 && mouseY <= y + 23) { try { - Desktop - .getDesktop() - .browse(new URI(socialsLink[socialIndex])); + Desktop.getDesktop().browse(new URI(socialsLink[socialIndex])); } catch (Exception ignored) {} return true; } @@ -855,13 +577,9 @@ public class SBHConfigEditor extends GuiElement { getCurrentConfigEditing().containsKey(getSelectedCategory()) ) { int optionWidthDefault = innerRight - innerLeft - 20; - ConfigProcessor.ProcessedCategory cat = getCurrentConfigEditing() - .get(getSelectedCategory()); + ConfigProcessor.ProcessedCategory cat = getCurrentConfigEditing().get(getSelectedCategory()); Set activeAccordions = new HashSet<>(); - for (ConfigProcessor.ProcessedOption option : getOptionsInCategory( - cat - ) - .values()) { + for (ConfigProcessor.ProcessedOption option : getOptionsInCategory(cat).values()) { int optionWidth = optionWidthDefault; if (option.accordionId >= 0) { if (!activeAccordions.contains(option.accordionId)) { @@ -895,12 +613,7 @@ public class SBHConfigEditor extends GuiElement { } } - if ( - mouseX > innerLeft && - mouseX < innerRight && - mouseY > innerTop && - mouseY < innerBottom - ) { + if (mouseX > innerLeft && mouseX < innerRight && mouseY > innerTop && mouseY < innerBottom) { optionY = -optionsScroll.getValue(); if ( getSelectedCategory() != null && @@ -908,13 +621,9 @@ public class SBHConfigEditor extends GuiElement { getCurrentConfigEditing().containsKey(getSelectedCategory()) ) { int optionWidthDefault = innerRight - innerLeft - 20; - ConfigProcessor.ProcessedCategory cat = getCurrentConfigEditing() - .get(getSelectedCategory()); + ConfigProcessor.ProcessedCategory cat = getCurrentConfigEditing().get(getSelectedCategory()); Set activeAccordions = new HashSet<>(); - for (ConfigProcessor.ProcessedOption option : getOptionsInCategory( - cat - ) - .values()) { + for (ConfigProcessor.ProcessedOption option : getOptionsInCategory(cat).values()) { int optionWidth = optionWidthDefault; if (option.accordionId >= 0) { if (!activeAccordions.contains(option.accordionId)) { @@ -953,15 +662,10 @@ public class SBHConfigEditor extends GuiElement { } public boolean keyboardInput() { - ScaledResolution scaledResolution = new ScaledResolution( - Minecraft.getMinecraft() - ); + ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); int width = scaledResolution.getScaledWidth(); - int xSize = Math.min( - width - 100 / scaledResolution.getScaleFactor(), - 500 - ); + int xSize = Math.min(width - 100 / scaledResolution.getScaleFactor(), 500); int adjScaleFactor = Math.max(2, scaledResolution.getScaleFactor()); @@ -973,13 +677,9 @@ public class SBHConfigEditor extends GuiElement { getCurrentConfigEditing() != null && getCurrentConfigEditing().containsKey(getSelectedCategory()) ) { - ConfigProcessor.ProcessedCategory cat = getCurrentConfigEditing() - .get(getSelectedCategory()); + ConfigProcessor.ProcessedCategory cat = getCurrentConfigEditing().get(getSelectedCategory()); Set activeAccordions = new HashSet<>(); - for (ConfigProcessor.ProcessedOption option : getOptionsInCategory( - cat - ) - .values()) { + for (ConfigProcessor.ProcessedOption option : getOptionsInCategory(cat).values()) { if (option.accordionId >= 0) { if (!activeAccordions.contains(option.accordionId)) { continue; diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/BackgroundBlur.java b/src/main/java/com/thatgravyboat/skyblockhud/core/BackgroundBlur.java index e95e896..7c252ad 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/BackgroundBlur.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/BackgroundBlur.java @@ -66,10 +66,8 @@ public class BackgroundBlur { } ); - output.framebufferWidth = - output.framebufferTextureWidth = width; - output.framebufferHeight = - output.framebufferTextureHeight = height; + output.framebufferWidth = output.framebufferTextureWidth = width; + output.framebufferHeight = output.framebufferTextureHeight = height; blurBackground(output, blur); } @@ -129,10 +127,7 @@ public class BackgroundBlur { } private static void blurBackground(Framebuffer output, float blurFactor) { - if ( - !OpenGlHelper.isFramebufferEnabled() || - !OpenGlHelper.areShadersSupported() - ) return; + if (!OpenGlHelper.isFramebufferEnabled() || !OpenGlHelper.areShadersSupported()) return; int width = Minecraft.getMinecraft().displayWidth; int height = Minecraft.getMinecraft().displayHeight; @@ -151,14 +146,9 @@ public class BackgroundBlur { if (blurOutputHorz == null || output == null) { return; } - if ( - blurOutputHorz.framebufferWidth != width || - blurOutputHorz.framebufferHeight != height - ) { + if (blurOutputHorz.framebufferWidth != width || blurOutputHorz.framebufferHeight != height) { blurOutputHorz.createBindFramebuffer(width, height); - blurShaderHorz.setProjectionMatrix( - createProjectionMatrix(width, height) - ); + blurShaderHorz.setProjectionMatrix(createProjectionMatrix(width, height)); Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(false); } @@ -170,47 +160,22 @@ public class BackgroundBlur { Minecraft.getMinecraft().getFramebuffer(), blurOutputHorz ); - blurShaderHorz - .getShaderManager() - .getShaderUniform("BlurDir") - .set(1, 0); - blurShaderHorz.setProjectionMatrix( - createProjectionMatrix(width, height) - ); + blurShaderHorz.getShaderManager().getShaderUniform("BlurDir").set(1, 0); + blurShaderHorz.setProjectionMatrix(createProjectionMatrix(width, height)); } catch (Exception ignored) {} try { - blurShaderVert = - new Shader( - Minecraft.getMinecraft().getResourceManager(), - "blur", - blurOutputHorz, - output - ); - blurShaderVert - .getShaderManager() - .getShaderUniform("BlurDir") - .set(0, 1); - blurShaderVert.setProjectionMatrix( - createProjectionMatrix(width, height) - ); + blurShaderVert = new Shader(Minecraft.getMinecraft().getResourceManager(), "blur", blurOutputHorz, output); + blurShaderVert.getShaderManager().getShaderUniform("BlurDir").set(0, 1); + blurShaderVert.setProjectionMatrix(createProjectionMatrix(width, height)); } catch (Exception ignored) {} if (blurShaderHorz != null && blurShaderVert != null) { - if ( - blurShaderHorz.getShaderManager().getShaderUniform("Radius") == - null - ) { + if (blurShaderHorz.getShaderManager().getShaderUniform("Radius") == null) { //Corrupted shader? return; } - blurShaderHorz - .getShaderManager() - .getShaderUniform("Radius") - .set(blurFactor); - blurShaderVert - .getShaderManager() - .getShaderUniform("Radius") - .set(blurFactor); + blurShaderHorz.getShaderManager().getShaderUniform("Radius").set(blurFactor); + blurShaderVert.getShaderManager().getShaderUniform("Radius").set(blurFactor); GL11.glPushMatrix(); /*GL30.glBindFramebuffer(GL30.GL_READ_FRAMEBUFFER, Minecraft.getMinecraft().getFramebuffer().framebufferObject); @@ -237,16 +202,7 @@ public class BackgroundBlur { int blurWidth, int blurHeight ) { - renderBlurredBackground( - blurStrength, - screenWidth, - screenHeight, - x, - y, - blurWidth, - blurHeight, - false - ); + renderBlurredBackground(blurStrength, screenWidth, screenHeight, x, y, blurWidth, blurHeight, false); } /** @@ -263,10 +219,7 @@ public class BackgroundBlur { int blurHeight, boolean forcedUpdate ) { - if ( - !OpenGlHelper.isFramebufferEnabled() || - !OpenGlHelper.areShadersSupported() - ) return; + if (!OpenGlHelper.isFramebufferEnabled() || !OpenGlHelper.areShadersSupported()) return; if (blurStrength < 0.5) return; requestedBlurs.add(blurStrength); @@ -292,16 +245,7 @@ public class BackgroundBlur { Gui.drawRect(x, y, x + blurWidth, y + blurHeight, fogColour); fb.bindFramebufferTexture(); GlStateManager.color(1f, 1f, 1f, 1f); - RenderUtils.drawTexturedRect( - x, - y, - blurWidth, - blurHeight, - uMin, - uMax, - vMin, - vMax - ); + RenderUtils.drawTexturedRect(x, y, blurWidth, blurHeight, uMin, uMax, vMin, vMax); fb.unbindFramebufferTexture(); GlStateManager.depthMask(true); } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/ChromaColour.java b/src/main/java/com/thatgravyboat/skyblockhud/core/ChromaColour.java index b8e97ee..3137153 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/ChromaColour.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/ChromaColour.java @@ -5,24 +5,12 @@ import java.awt.*; public class ChromaColour { public static String special(int chromaSpeed, int alpha, int rgb) { - return special( - chromaSpeed, - alpha, - (rgb & 0xFF0000) >> 16, - (rgb & 0x00FF00) >> 8, - (rgb & 0x0000FF) - ); + return special(chromaSpeed, alpha, (rgb & 0xFF0000) >> 16, (rgb & 0x00FF00) >> 8, (rgb & 0x0000FF)); } private static final int RADIX = 10; - public static String special( - int chromaSpeed, - int alpha, - int r, - int g, - int b - ) { + public static String special(int chromaSpeed, int alpha, int r, int g, int b) { StringBuilder sb = new StringBuilder(); sb.append(Integer.toString(chromaSpeed, RADIX)).append(":"); sb.append(Integer.toString(alpha, RADIX)).append(":"); @@ -51,9 +39,7 @@ public class ChromaColour { int a = d[3]; int chr = d[4]; - return ( - (a & 0xFF) << 24 | (r & 0xFF) << 16 | (g & 0xFF) << 8 | (b & 0xFF) - ); + return ((a & 0xFF) << 24 | (r & 0xFF) << 16 | (g & 0xFF) << 8 | (b & 0xFF)); } public static int getSpeed(String special) { @@ -61,12 +47,7 @@ public class ChromaColour { } public static float getSecondsForSpeed(int speed) { - return ( - (255 - speed) / - 254f * - (MAX_CHROMA_SECS - MIN_CHROMA_SECS) + - MIN_CHROMA_SECS - ); + return ((255 - speed) / 254f * (MAX_CHROMA_SECS - MIN_CHROMA_SECS) + MIN_CHROMA_SECS); } private static final int MIN_CHROMA_SECS = 1; @@ -88,16 +69,12 @@ public class ChromaColour { if (chr > 0) { float seconds = getSecondsForSpeed(chr); - hsv[0] += - (System.currentTimeMillis() - startTime) / 1000f / seconds; + hsv[0] += (System.currentTimeMillis() - startTime) / 1000f / seconds; hsv[0] %= 1; if (hsv[0] < 0) hsv[0] += 1; } - return ( - (a & 0xFF) << 24 | - (Color.HSBtoRGB(hsv[0], hsv[1], hsv[2]) & 0x00FFFFFF) - ); + return ((a & 0xFF) << 24 | (Color.HSBtoRGB(hsv[0], hsv[1], hsv[2]) & 0x00FFFFFF)); } public static int rotateHue(int argb, int degrees) { @@ -111,9 +88,6 @@ public class ChromaColour { hsv[0] += degrees / 360f; hsv[0] %= 1; - return ( - (a & 0xFF) << 24 | - (Color.HSBtoRGB(hsv[0], hsv[1], hsv[2]) & 0x00FFFFFF) - ); + return ((a & 0xFF) << 24 | (Color.HSBtoRGB(hsv[0], hsv[1], hsv[2]) & 0x00FFFFFF)); } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/GlScissorStack.java b/src/main/java/com/thatgravyboat/skyblockhud/core/GlScissorStack.java index 306565e..0e1694e 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/GlScissorStack.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/GlScissorStack.java @@ -40,24 +40,13 @@ public class GlScissorStack { public void set(ScaledResolution scaledResolution) { int height = Minecraft.getMinecraft().displayHeight; int scale = scaledResolution.getScaleFactor(); - GL11.glScissor( - left * scale, - height - bottom * scale, - (right - left) * scale, - (bottom - top) * scale - ); + GL11.glScissor(left * scale, height - bottom * scale, (right - left) * scale, (bottom - top) * scale); } } private static final LinkedList boundsStack = new LinkedList<>(); - public static void push( - int left, - int top, - int right, - int bottom, - ScaledResolution scaledResolution - ) { + public static void push(int left, int top, int right, int bottom, ScaledResolution scaledResolution) { if (right < left) { int temp = right; right = left; @@ -71,9 +60,7 @@ public class GlScissorStack { if (boundsStack.isEmpty()) { boundsStack.push(new Bounds(left, top, right, bottom)); } else { - boundsStack.push( - boundsStack.peek().createSubBound(left, top, right, bottom) - ); + boundsStack.push(boundsStack.peek().createSubBound(left, top, right, bottom)); } if (!boundsStack.isEmpty()) { boundsStack.peek().set(scaledResolution); diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElementBoolean.java b/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElementBoolean.java index a8ed7d5..e41b7b3 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElementBoolean.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElementBoolean.java @@ -24,22 +24,11 @@ public class GuiElementBoolean extends GuiElement { private static final int xSize = 48; private static final int ySize = 14; - public GuiElementBoolean( - int x, - int y, - boolean value, - Consumer toggleCallback - ) { + public GuiElementBoolean(int x, int y, boolean value, Consumer toggleCallback) { this(x, y, value, 0, toggleCallback); } - public GuiElementBoolean( - int x, - int y, - boolean value, - int clickRadius, - Consumer toggleCallback - ) { + public GuiElementBoolean(int x, int y, boolean value, int clickRadius, Consumer toggleCallback) { this.x = x; this.y = y; this.value = value; @@ -54,10 +43,7 @@ public class GuiElementBoolean extends GuiElement { @Override public void render() { GlStateManager.color(1, 1, 1, 1); - Minecraft - .getMinecraft() - .getTextureManager() - .bindTexture(GuiTextures.BAR); + Minecraft.getMinecraft().getTextureManager().bindTexture(GuiTextures.BAR); RenderUtils.drawTexturedRect(x, y, xSize, ySize); ResourceLocation buttonLoc = GuiTextures.ON; @@ -66,10 +52,7 @@ public class GuiElementBoolean extends GuiElement { lastMillis = currentMillis; boolean passedLimit = false; if (previewValue != value) { - if ( - (previewValue && animation > 12) || - (!previewValue && animation < 24) - ) { + if ((previewValue && animation > 12) || (!previewValue && animation < 24)) { passedLimit = true; } } @@ -96,9 +79,7 @@ public class GuiElementBoolean extends GuiElement { } } - int animation = (int) ( - LerpUtils.sigmoidZeroOne(this.animation / 36f) * 36 - ); + int animation = (int) (LerpUtils.sigmoidZeroOne(this.animation / 36f) * 36); if (animation < 3) { buttonLoc = GuiTextures.OFF; } else if (animation < 13) { diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElementColour.java b/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElementColour.java index 8b5c2d6..a7db23b 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElementColour.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElementColour.java @@ -31,9 +31,7 @@ public class GuiElementColour extends GuiElement { "skyblockhud:core/colour_selector_chroma.png" ); - private static final ResourceLocation colourPickerLocation = new ResourceLocation( - "mbcore:dynamic/colourpicker" - ); + private static final ResourceLocation colourPickerLocation = new ResourceLocation("mbcore:dynamic/colourpicker"); private static final ResourceLocation colourPickerBarValueLocation = new ResourceLocation( "mbcore:dynamic/colourpickervalue" ); @@ -42,9 +40,7 @@ public class GuiElementColour extends GuiElement { ); private final GuiElementTextField hexField = new GuiElementTextField( "", - GuiElementTextField.SCALE_TEXT | - GuiElementTextField.FORCE_CAPS | - GuiElementTextField.NO_SPACE + GuiElementTextField.SCALE_TEXT | GuiElementTextField.FORCE_CAPS | GuiElementTextField.NO_SPACE ); private int x; @@ -68,20 +64,10 @@ public class GuiElementColour extends GuiElement { Consumer colourChangedCallback, Runnable closeCallback ) { - final ScaledResolution scaledResolution = new ScaledResolution( - Minecraft.getMinecraft() - ); + final ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); - this.y = - Math.max( - 10, - Math.min(scaledResolution.getScaledHeight() - ySize - 10, y) - ); - this.x = - Math.max( - 10, - Math.min(scaledResolution.getScaledWidth() - xSize - 10, x) - ); + this.y = Math.max(10, Math.min(scaledResolution.getScaledHeight() - ySize - 10, y)); + this.x = Math.max(10, Math.min(scaledResolution.getScaledWidth() - xSize - 10, x)); this.colour = initialColour; this.colourChangedCallback = colourChangedCallback; @@ -89,12 +75,7 @@ public class GuiElementColour extends GuiElement { int colour = ChromaColour.specialToSimpleRGB(initialColour); Color c = new Color(colour); - float[] hsv = Color.RGBtoHSB( - c.getRed(), - c.getGreen(), - c.getBlue(), - null - ); + float[] hsv = Color.RGBtoHSB(c.getRed(), c.getGreen(), c.getBlue(), null); updateAngleAndRadius(hsv); } @@ -108,51 +89,25 @@ public class GuiElementColour extends GuiElement { int currentColour = ChromaColour.specialToSimpleRGB(colour); Color c = new Color(currentColour, true); - float[] hsv = Color.RGBtoHSB( - c.getRed(), - c.getGreen(), - c.getBlue(), - null - ); + float[] hsv = Color.RGBtoHSB(c.getRed(), c.getGreen(), c.getBlue(), null); - BufferedImage bufferedImage = new BufferedImage( - 288, - 288, - BufferedImage.TYPE_INT_ARGB - ); + BufferedImage bufferedImage = new BufferedImage(288, 288, BufferedImage.TYPE_INT_ARGB); float borderRadius = 0.05f; if (Keyboard.isKeyDown(Keyboard.KEY_N)) borderRadius = 0; for (int x = -16; x < 272; x++) { for (int y = -16; y < 272; y++) { - float radius = (float) Math.sqrt( - ((x - 128) * (x - 128) + (y - 128) * (y - 128)) / 16384f - ); - float angle = (float) Math.toDegrees( - Math.atan((128 - x) / (y - 128 + 1E-5)) + Math.PI / 2 - ); + float radius = (float) Math.sqrt(((x - 128) * (x - 128) + (y - 128) * (y - 128)) / 16384f); + float angle = (float) Math.toDegrees(Math.atan((128 - x) / (y - 128 + 1E-5)) + Math.PI / 2); if (y < 128) angle += 180; if (radius <= 1) { - int rgb = Color - .getHSBColor( - angle / 360f, - (float) Math.pow(radius, 1.5f), - hsv[2] - ) - .getRGB(); + int rgb = Color.getHSBColor(angle / 360f, (float) Math.pow(radius, 1.5f), hsv[2]).getRGB(); bufferedImage.setRGB(x + 16, y + 16, rgb); } else if (radius <= 1 + borderRadius) { - float invBlackAlpha = - Math.abs(radius - 1 - borderRadius / 2) / - borderRadius * - 2; + float invBlackAlpha = Math.abs(radius - 1 - borderRadius / 2) / borderRadius * 2; float blackAlpha = 1 - invBlackAlpha; if (radius > 1 + borderRadius / 2) { - bufferedImage.setRGB( - x + 16, - y + 16, - (int) (blackAlpha * 255) << 24 - ); + bufferedImage.setRGB(x + 16, y + 16, (int) (blackAlpha * 255) << 24); } else { Color col = Color.getHSBColor(angle / 360f, 1, hsv[2]); int rgb = (int) (col.getRed() * invBlackAlpha) << 16 | @@ -164,34 +119,22 @@ public class GuiElementColour extends GuiElement { } } - BufferedImage bufferedImageValue = new BufferedImage( - 10, - 64, - BufferedImage.TYPE_INT_ARGB - ); + BufferedImage bufferedImageValue = new BufferedImage(10, 64, BufferedImage.TYPE_INT_ARGB); for (int x = 0; x < 10; x++) { for (int y = 0; y < 64; y++) { if ((x == 0 || x == 9) && (y == 0 || y == 63)) continue; - int rgb = Color - .getHSBColor(wheelAngle / 360, wheelRadius, (64 - y) / 64f) - .getRGB(); + int rgb = Color.getHSBColor(wheelAngle / 360, wheelRadius, (64 - y) / 64f).getRGB(); bufferedImageValue.setRGB(x, y, rgb); } } - BufferedImage bufferedImageOpacity = new BufferedImage( - 10, - 64, - BufferedImage.TYPE_INT_ARGB - ); + BufferedImage bufferedImageOpacity = new BufferedImage(10, 64, BufferedImage.TYPE_INT_ARGB); for (int x = 0; x < 10; x++) { for (int y = 0; y < 64; y++) { if ((x == 0 || x == 9) && (y == 0 || y == 63)) continue; - int rgb = - (currentColour & 0x00FFFFFF) | - (Math.min(255, (64 - y) * 4) << 24); + int rgb = (currentColour & 0x00FFFFFF) | (Math.min(255, (64 - y) * 4) << 24); bufferedImageOpacity.setRGB(x, y, rgb); } } @@ -200,68 +143,30 @@ public class GuiElementColour extends GuiElement { int selx = (int) (Math.cos(Math.toRadians(wheelAngle)) * selradius); int sely = (int) (Math.sin(Math.toRadians(wheelAngle)) * selradius); - Minecraft - .getMinecraft() - .getTextureManager() - .bindTexture(colour_selector_bar_alpha); + Minecraft.getMinecraft().getTextureManager().bindTexture(colour_selector_bar_alpha); GlStateManager.color(1, 1, 1, 1); - RenderUtils.drawTexturedRect( - x + 5 + 64 + 5 + 10 + 5, - y + 5, - 10, - 64, - GL11.GL_NEAREST - ); + RenderUtils.drawTexturedRect(x + 5 + 64 + 5 + 10 + 5, y + 5, 10, 64, GL11.GL_NEAREST); Minecraft .getMinecraft() .getTextureManager() - .loadTexture( - colourPickerBarValueLocation, - new DynamicTexture(bufferedImageValue) - ); - Minecraft - .getMinecraft() - .getTextureManager() - .bindTexture(colourPickerBarValueLocation); + .loadTexture(colourPickerBarValueLocation, new DynamicTexture(bufferedImageValue)); + Minecraft.getMinecraft().getTextureManager().bindTexture(colourPickerBarValueLocation); GlStateManager.color(1, 1, 1, 1); - RenderUtils.drawTexturedRect( - x + 5 + 64 + 5, - y + 5, - 10, - 64, - GL11.GL_NEAREST - ); + RenderUtils.drawTexturedRect(x + 5 + 64 + 5, y + 5, 10, 64, GL11.GL_NEAREST); Minecraft .getMinecraft() .getTextureManager() - .loadTexture( - colourPickerBarOpacityLocation, - new DynamicTexture(bufferedImageOpacity) - ); - Minecraft - .getMinecraft() - .getTextureManager() - .bindTexture(colourPickerBarOpacityLocation); + .loadTexture(colourPickerBarOpacityLocation, new DynamicTexture(bufferedImageOpacity)); + Minecraft.getMinecraft().getTextureManager().bindTexture(colourPickerBarOpacityLocation); GlStateManager.color(1, 1, 1, 1); - RenderUtils.drawTexturedRect( - x + 5 + 64 + 5 + 10 + 5, - y + 5, - 10, - 64, - GL11.GL_NEAREST - ); + RenderUtils.drawTexturedRect(x + 5 + 64 + 5 + 10 + 5, y + 5, 10, 64, GL11.GL_NEAREST); int chromaSpeed = ChromaColour.getSpeed(colour); int currentColourChroma = ChromaColour.specialToChromaRGB(colour); Color cChroma = new Color(currentColourChroma, true); - float hsvChroma[] = Color.RGBtoHSB( - cChroma.getRed(), - cChroma.getGreen(), - cChroma.getBlue(), - null - ); + float hsvChroma[] = Color.RGBtoHSB(cChroma.getRed(), cChroma.getGreen(), cChroma.getBlue(), null); if (chromaSpeed > 0) { Gui.drawRect( @@ -278,58 +183,23 @@ public class GuiElementColour extends GuiElement { x + 5 + 64 + 5 + 10 + 5 + 10 + 5 + 10 - 1, y + 5 + 37 - 1, Color.HSBtoRGB( - ( - hsvChroma[0] + - (System.currentTimeMillis() - ChromaColour.startTime) / - 1000f - ) % - 1, + (hsvChroma[0] + (System.currentTimeMillis() - ChromaColour.startTime) / 1000f) % 1, 0.8f, 0.8f ) ); } - Minecraft - .getMinecraft() - .getTextureManager() - .bindTexture(colour_selector_bar); + Minecraft.getMinecraft().getTextureManager().bindTexture(colour_selector_bar); GlStateManager.color(1, 1, 1, 1); - RenderUtils.drawTexturedRect( - x + 5 + 64 + 5, - y + 5, - 10, - 64, - GL11.GL_NEAREST - ); - RenderUtils.drawTexturedRect( - x + 5 + 64 + 5 + 10 + 5, - y + 5, - 10, - 64, - GL11.GL_NEAREST - ); + RenderUtils.drawTexturedRect(x + 5 + 64 + 5, y + 5, 10, 64, GL11.GL_NEAREST); + RenderUtils.drawTexturedRect(x + 5 + 64 + 5 + 10 + 5, y + 5, 10, 64, GL11.GL_NEAREST); if (chromaSpeed > 0) { - RenderUtils.drawTexturedRect( - x + 5 + 64 + 5 + 10 + 5 + 10 + 5, - y + 5, - 10, - 64, - GL11.GL_NEAREST - ); + RenderUtils.drawTexturedRect(x + 5 + 64 + 5 + 10 + 5 + 10 + 5, y + 5, 10, 64, GL11.GL_NEAREST); } else { - Minecraft - .getMinecraft() - .getTextureManager() - .bindTexture(colour_selector_chroma); - RenderUtils.drawTexturedRect( - x + 5 + 64 + 5 + 10 + 5 + 10 + 5, - y + 5 + 27, - 10, - 10, - GL11.GL_NEAREST - ); + Minecraft.getMinecraft().getTextureManager().bindTexture(colour_selector_chroma); + RenderUtils.drawTexturedRect(x + 5 + 64 + 5 + 10 + 5 + 10 + 5, y + 5 + 27, 10, 10, GL11.GL_NEAREST); } Gui.drawRect( @@ -359,29 +229,14 @@ public class GuiElementColour extends GuiElement { Minecraft .getMinecraft() .getTextureManager() - .loadTexture( - colourPickerLocation, - new DynamicTexture(bufferedImage) - ); - Minecraft - .getMinecraft() - .getTextureManager() - .bindTexture(colourPickerLocation); + .loadTexture(colourPickerLocation, new DynamicTexture(bufferedImage)); + Minecraft.getMinecraft().getTextureManager().bindTexture(colourPickerLocation); GlStateManager.color(1, 1, 1, 1); RenderUtils.drawTexturedRect(x + 1, y + 1, 72, 72, GL11.GL_LINEAR); - Minecraft - .getMinecraft() - .getTextureManager() - .bindTexture(colour_selector_dot); + Minecraft.getMinecraft().getTextureManager().bindTexture(colour_selector_dot); GlStateManager.color(1, 1, 1, 1); - RenderUtils.drawTexturedRect( - x + 5 + 32 + selx - 4, - y + 5 + 32 + sely - 4, - 8, - 8, - GL11.GL_NEAREST - ); + RenderUtils.drawTexturedRect(x + 5 + 32 + selx - 4, y + 5 + 32 + sely - 4, 8, 8, GL11.GL_NEAREST); TextRenderUtils.drawStringCenteredScaledMaxWidth( EnumChatFormatting.GRAY.toString() + Math.round(hsv[2] * 100) + "", @@ -393,9 +248,7 @@ public class GuiElementColour extends GuiElement { -1 ); TextRenderUtils.drawStringCenteredScaledMaxWidth( - EnumChatFormatting.GRAY.toString() + - Math.round(c.getAlpha() / 255f * 100) + - "", + EnumChatFormatting.GRAY.toString() + Math.round(c.getAlpha() / 255f * 100) + "", Minecraft.getMinecraft().fontRendererObj, x + 5 + 64 + 5 + 15 + 5, y + 5 + 64 + 5 + 5, @@ -405,9 +258,7 @@ public class GuiElementColour extends GuiElement { ); if (chromaSpeed > 0) { TextRenderUtils.drawStringCenteredScaledMaxWidth( - EnumChatFormatting.GRAY.toString() + - (int) ChromaColour.getSecondsForSpeed(chromaSpeed) + - "s", + EnumChatFormatting.GRAY.toString() + (int) ChromaColour.getSecondsForSpeed(chromaSpeed) + "s", Minecraft.getMinecraft().fontRendererObj, x + 5 + 64 + 5 + 30 + 6, y + 5 + 64 + 5 + 5, @@ -418,9 +269,7 @@ public class GuiElementColour extends GuiElement { } hexField.setSize(48, 10); - if (!hexField.getFocus()) hexField.setText( - Integer.toHexString(c.getRGB() & 0xFFFFFF).toUpperCase() - ); + if (!hexField.getFocus()) hexField.setText(Integer.toHexString(c.getRGB() & 0xFFFFFF).toUpperCase()); StringBuilder sb = new StringBuilder(EnumChatFormatting.GRAY + "#"); for (int i = 0; i < 6 - hexField.getText().length(); i++) { @@ -433,13 +282,9 @@ public class GuiElementColour extends GuiElement { } public boolean mouseInput(int mouseX, int mouseY) { - ScaledResolution scaledResolution = new ScaledResolution( - Minecraft.getMinecraft() - ); + ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); float mouseXF = (float) ( - Mouse.getX() * - scaledResolution.getScaledWidth_double() / - Minecraft.getMinecraft().displayWidth + Mouse.getX() * scaledResolution.getScaledWidth_double() / Minecraft.getMinecraft().displayWidth ); float mouseYF = (float) ( scaledResolution.getScaledHeight_double() - @@ -449,17 +294,10 @@ public class GuiElementColour extends GuiElement { 1 ); - if ( - (Mouse.getEventButton() == 0 || Mouse.getEventButton() == 1) && - Mouse.getEventButtonState() - ) { + if ((Mouse.getEventButton() == 0 || Mouse.getEventButton() == 1) && Mouse.getEventButtonState()) { if (mouseX > x + 5 + 8 && mouseX < x + 5 + 8 + 48) { if (mouseY > y + 5 + 64 + 5 && mouseY < y + 5 + 64 + 5 + 10) { - hexField.mouseClicked( - mouseX, - mouseY, - Mouse.getEventButton() - ); + hexField.mouseClicked(mouseX, mouseY, Mouse.getEventButton()); clickedComponent = -1; return true; } @@ -469,12 +307,7 @@ public class GuiElementColour extends GuiElement { clickedComponent = -1; } if (Mouse.getEventButtonState() && Mouse.getEventButton() == 0) { - if ( - mouseX >= x && - mouseX <= x + 119 && - mouseY >= y && - mouseY <= y + 89 - ) { + if (mouseX >= x && mouseX <= x + 119 && mouseY >= y && mouseY <= y + 89) { hexField.unfocus(); int xWheel = mouseX - x - 5; @@ -508,19 +341,10 @@ public class GuiElementColour extends GuiElement { if (y > -5 && y <= 69) { clickedComponent = 3; } - } else if ( - mouseY > this.y + 5 + 27 && mouseY < this.y + 5 + 37 - ) { - int currentColour = ChromaColour.specialToSimpleRGB( - colour - ); + } else if (mouseY > this.y + 5 + 27 && mouseY < this.y + 5 + 37) { + int currentColour = ChromaColour.specialToSimpleRGB(colour); Color c = new Color(currentColour, true); - colour = - ChromaColour.special( - 200, - c.getAlpha(), - currentColour - ); + colour = ChromaColour.special(200, c.getAlpha(), currentColour); colourChangedCallback.accept(colour); } } @@ -533,46 +357,24 @@ public class GuiElementColour extends GuiElement { if (Mouse.isButtonDown(0) && clickedComponent >= 0) { int currentColour = ChromaColour.specialToSimpleRGB(colour); Color c = new Color(currentColour, true); - float[] hsv = Color.RGBtoHSB( - c.getRed(), - c.getGreen(), - c.getBlue(), - null - ); + float[] hsv = Color.RGBtoHSB(c.getRed(), c.getGreen(), c.getBlue(), null); float xWheel = mouseXF - x - 5; float yWheel = mouseYF - y - 5; if (clickedComponent == 0) { - float angle = (float) Math.toDegrees( - Math.atan((32 - xWheel) / (yWheel - 32 + 1E-5)) + - Math.PI / - 2 - ); + float angle = (float) Math.toDegrees(Math.atan((32 - xWheel) / (yWheel - 32 + 1E-5)) + Math.PI / 2); xWheel = Math.max(0, Math.min(64, xWheel)); yWheel = Math.max(0, Math.min(64, yWheel)); float radius = (float) Math.sqrt( - ( - (xWheel - 32) * - (xWheel - 32) + - (yWheel - 32) * - (yWheel - 32) - ) / - 1024f + ((xWheel - 32) * (xWheel - 32) + (yWheel - 32) * (yWheel - 32)) / 1024f ); if (yWheel < 32) angle += 180; this.wheelAngle = angle; this.wheelRadius = (float) Math.pow(Math.min(1, radius), 1.5f); - int rgb = Color - .getHSBColor(angle / 360f, wheelRadius, hsv[2]) - .getRGB(); - colour = - ChromaColour.special( - ChromaColour.getSpeed(colour), - c.getAlpha(), - rgb - ); + int rgb = Color.getHSBColor(angle / 360f, wheelRadius, hsv[2]).getRGB(); + colour = ChromaColour.special(ChromaColour.getSpeed(colour), c.getAlpha(), rgb); colourChangedCallback.accept(colour); return true; } @@ -582,37 +384,21 @@ public class GuiElementColour extends GuiElement { System.out.println(y); if (clickedComponent == 1) { - int rgb = Color - .getHSBColor(wheelAngle / 360, wheelRadius, 1 - y / 64f) - .getRGB(); - colour = - ChromaColour.special( - ChromaColour.getSpeed(colour), - c.getAlpha(), - rgb - ); + int rgb = Color.getHSBColor(wheelAngle / 360, wheelRadius, 1 - y / 64f).getRGB(); + colour = ChromaColour.special(ChromaColour.getSpeed(colour), c.getAlpha(), rgb); colourChangedCallback.accept(colour); return true; } if (clickedComponent == 2) { colour = - ChromaColour.special( - ChromaColour.getSpeed(colour), - 255 - Math.round(y / 64f * 255), - currentColour - ); + ChromaColour.special(ChromaColour.getSpeed(colour), 255 - Math.round(y / 64f * 255), currentColour); colourChangedCallback.accept(colour); return true; } if (clickedComponent == 3) { - colour = - ChromaColour.special( - 255 - Math.round(y / 64f * 255), - c.getAlpha(), - currentColour - ); + colour = ChromaColour.special(255 - Math.round(y / 64f * 255), c.getAlpha(), currentColour); colourChangedCallback.accept(colour); } return true; @@ -628,10 +414,7 @@ public class GuiElementColour extends GuiElement { } String old = hexField.getText(); - hexField.keyTyped( - Keyboard.getEventCharacter(), - Keyboard.getEventKey() - ); + hexField.keyTyped(Keyboard.getEventCharacter(), Keyboard.getEventKey()); if (hexField.getText().length() > 6) { hexField.setText(old); @@ -640,23 +423,12 @@ public class GuiElementColour extends GuiElement { String text = hexField.getText().toLowerCase(); int rgb = Integer.parseInt(text, 16); - int alpha = - (ChromaColour.specialToSimpleRGB(colour) >> 24) & 0xFF; - colour = - ChromaColour.special( - ChromaColour.getSpeed(colour), - alpha, - rgb - ); + int alpha = (ChromaColour.specialToSimpleRGB(colour) >> 24) & 0xFF; + colour = ChromaColour.special(ChromaColour.getSpeed(colour), alpha, rgb); colourChangedCallback.accept(colour); Color c = new Color(rgb); - float[] hsv = Color.RGBtoHSB( - c.getRed(), - c.getGreen(), - c.getBlue(), - null - ); + float[] hsv = Color.RGBtoHSB(c.getRed(), c.getGreen(), c.getBlue(), null); updateAngleAndRadius(hsv); } catch (Exception e) {} } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElementTextField.java b/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElementTextField.java index a3d01b5..cc002b2 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElementTextField.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElementTextField.java @@ -34,14 +34,7 @@ public class GuiElementTextField { private String prependText = ""; - private final GuiTextField textField = new GuiTextField( - 0, - Minecraft.getMinecraft().fontRendererObj, - 0, - 0, - 0, - 0 - ); + private final GuiTextField textField = new GuiTextField(0, Minecraft.getMinecraft().fontRendererObj, 0, 0, 0, 0); private int customBorderColour = -1; @@ -49,12 +42,7 @@ public class GuiElementTextField { this(initialText, 100, 20, options); } - public GuiElementTextField( - String initialText, - int sizeX, - int sizeY, - int options - ) { + public GuiElementTextField(String initialText, int sizeX, int sizeY, int options) { textField.setFocused(true); textField.setCanLoseFocus(false); textField.setMaxStringLength(999); @@ -109,18 +97,10 @@ public class GuiElementTextField { } public int getHeight() { - ScaledResolution scaledresolution = new ScaledResolution( - Minecraft.getMinecraft() - ); - int paddingUnscaled = - searchBarPadding / scaledresolution.getScaleFactor(); - - int numLines = - org.apache.commons.lang3.StringUtils.countMatches( - textField.getText(), - "\n" - ) + - 1; + ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft()); + int paddingUnscaled = searchBarPadding / scaledresolution.getScaleFactor(); + + int numLines = org.apache.commons.lang3.StringUtils.countMatches(textField.getText(), "\n") + 1; int extraSize = (searchBarYSize - 8) / 2 + 8; int bottomTextBox = searchBarYSize + extraSize * (numLines - 1); @@ -128,21 +108,14 @@ public class GuiElementTextField { } public int getWidth() { - ScaledResolution scaledresolution = new ScaledResolution( - Minecraft.getMinecraft() - ); - int paddingUnscaled = - searchBarPadding / scaledresolution.getScaleFactor(); + ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft()); + int paddingUnscaled = searchBarPadding / scaledresolution.getScaleFactor(); return searchBarXSize + paddingUnscaled * 2; } private float getScaleFactor(String str) { - return Math.min( - 1, - (searchBarXSize - 2) / - (float) Minecraft.getMinecraft().fontRendererObj.getStringWidth(str) - ); + return Math.min(1, (searchBarXSize - 2) / (float) Minecraft.getMinecraft().fontRendererObj.getStringWidth(str)); } private boolean isScaling() { @@ -151,10 +124,7 @@ public class GuiElementTextField { private float getStringWidth(String str) { if (isScaling()) { - return ( - Minecraft.getMinecraft().fontRendererObj.getStringWidth(str) * - getScaleFactor(str) - ); + return (Minecraft.getMinecraft().fontRendererObj.getStringWidth(str) * getScaleFactor(str)); } else { return Minecraft.getMinecraft().fontRendererObj.getStringWidth(str); } @@ -168,13 +138,9 @@ public class GuiElementTextField { String renderText = prependText + textField.getText(); - int lineNum = Math.round( - ((yComp - (searchBarYSize - 8) / 2)) / extraSize - ); + int lineNum = Math.round(((yComp - (searchBarYSize - 8) / 2)) / extraSize); - Pattern patternControlCode = Pattern.compile( - "(?i)\\u00A7([^\\u00B6])(?!\\u00B6)" - ); + Pattern patternControlCode = Pattern.compile("(?i)\\u00A7([^\\u00B6])(?!\\u00B6)"); String text = renderText; String textNoColour = renderText; if ((options & COLOUR) != 0) { @@ -202,28 +168,15 @@ public class GuiElementTextField { } String textNC = textNoColour.substring(0, cursorIndex); - int colorCodes = org.apache.commons.lang3.StringUtils.countMatches( - textNC, - "\u00B6" - ); - String line = text - .substring( - cursorIndex + (((options & COLOUR) != 0) ? colorCodes * 2 : 0) - ) - .split("\n")[0]; + int colorCodes = org.apache.commons.lang3.StringUtils.countMatches(textNC, "\u00B6"); + String line = text.substring(cursorIndex + (((options & COLOUR) != 0) ? colorCodes * 2 : 0)).split("\n")[0]; int padding = Math.min(5, searchBarXSize - strLenNoColor(line)) / 2; - String trimmed = Minecraft - .getMinecraft() - .fontRendererObj.trimStringToWidth(line, xComp - padding); + String trimmed = Minecraft.getMinecraft().fontRendererObj.trimStringToWidth(line, xComp - padding); int linePos = strLenNoColor(trimmed); if (linePos != strLenNoColor(line)) { char after = line.charAt(linePos); - int trimmedWidth = Minecraft - .getMinecraft() - .fontRendererObj.getStringWidth(trimmed); - int charWidth = Minecraft - .getMinecraft() - .fontRendererObj.getCharWidth(after); + int trimmedWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(trimmed); + int charWidth = Minecraft.getMinecraft().fontRendererObj.getCharWidth(after); if (trimmedWidth + charWidth / 2 < xComp - padding) { linePos++; } @@ -258,12 +211,7 @@ public class GuiElementTextField { return str.replaceAll("(?i)\\u00A7.", "").length(); } - public void mouseClickMove( - int mouseX, - int mouseY, - int clickedMouseButton, - long timeSinceLastClick - ) { + public void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) { if (focus) { textField.setSelectionPos(getCursorPos(mouseX, mouseY)); } @@ -272,9 +220,7 @@ public class GuiElementTextField { public void keyTyped(char typedChar, int keyCode) { if (focus) { if ((options & MULTILINE) != 0) { //Carriage return - Pattern patternControlCode = Pattern.compile( - "(?i)\\u00A7([^\\u00B6\n])(?!\\u00B6)" - ); + Pattern patternControlCode = Pattern.compile("(?i)\\u00A7([^\\u00B6\n])(?!\\u00B6)"); String text = textField.getText(); String textNoColour = textField.getText(); @@ -282,8 +228,7 @@ public class GuiElementTextField { Matcher matcher = patternControlCode.matcher(text); if (!matcher.find() || matcher.groupCount() < 1) break; String code = matcher.group(1); - text = - matcher.replaceFirst("\u00A7" + code + "\u00B6" + code); + text = matcher.replaceFirst("\u00A7" + code + "\u00B6" + code); } while (true) { Matcher matcher = patternControlCode.matcher(textNoColour); @@ -293,29 +238,16 @@ public class GuiElementTextField { } if (keyCode == 28) { - String before = textField - .getText() - .substring(0, textField.getCursorPosition()); - String after = textField - .getText() - .substring(textField.getCursorPosition()); + String before = textField.getText().substring(0, textField.getCursorPosition()); + String after = textField.getText().substring(textField.getCursorPosition()); int pos = textField.getCursorPosition(); textField.setText(before + "\n" + after); textField.setCursorPosition(pos + 1); return; } else if (keyCode == 200) { //Up - String textNCBeforeCursor = textNoColour.substring( - 0, - textField.getSelectionEnd() - ); - int colorCodes = org.apache.commons.lang3.StringUtils.countMatches( - textNCBeforeCursor, - "\u00B6" - ); - String textBeforeCursor = text.substring( - 0, - textField.getSelectionEnd() + colorCodes * 2 - ); + String textNCBeforeCursor = textNoColour.substring(0, textField.getSelectionEnd()); + int colorCodes = org.apache.commons.lang3.StringUtils.countMatches(textNCBeforeCursor, "\u00B6"); + String textBeforeCursor = text.substring(0, textField.getSelectionEnd() + colorCodes * 2); int numLinesBeforeCursor = org.apache.commons.lang3.StringUtils.countMatches( textBeforeCursor, @@ -326,9 +258,7 @@ public class GuiElementTextField { int textBeforeCursorWidth; String lineBefore; String thisLineBeforeCursor; - if ( - split.length == numLinesBeforeCursor && split.length > 0 - ) { + if (split.length == numLinesBeforeCursor && split.length > 0) { textBeforeCursorWidth = 0; lineBefore = split[split.length - 1]; thisLineBeforeCursor = ""; @@ -336,32 +266,19 @@ public class GuiElementTextField { thisLineBeforeCursor = split[split.length - 1]; lineBefore = split[split.length - 2]; textBeforeCursorWidth = - Minecraft - .getMinecraft() - .fontRendererObj.getStringWidth( - thisLineBeforeCursor - ); + Minecraft.getMinecraft().fontRendererObj.getStringWidth(thisLineBeforeCursor); } else { return; } String trimmed = Minecraft .getMinecraft() - .fontRendererObj.trimStringToWidth( - lineBefore, - textBeforeCursorWidth - ); + .fontRendererObj.trimStringToWidth(lineBefore, textBeforeCursorWidth); int linePos = strLenNoColor(trimmed); if (linePos != strLenNoColor(lineBefore)) { char after = lineBefore.charAt(linePos); - int trimmedWidth = Minecraft - .getMinecraft() - .fontRendererObj.getStringWidth(trimmed); - int charWidth = Minecraft - .getMinecraft() - .fontRendererObj.getCharWidth(after); - if ( - trimmedWidth + charWidth / 2 < textBeforeCursorWidth - ) { + int trimmedWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(trimmed); + int charWidth = Minecraft.getMinecraft().fontRendererObj.getCharWidth(after); + if (trimmedWidth + charWidth / 2 < textBeforeCursorWidth) { linePos++; } } @@ -378,18 +295,9 @@ public class GuiElementTextField { textField.setCursorPosition(newPos); } } else if (keyCode == 208) { //Down - String textNCBeforeCursor = textNoColour.substring( - 0, - textField.getSelectionEnd() - ); - int colorCodes = org.apache.commons.lang3.StringUtils.countMatches( - textNCBeforeCursor, - "\u00B6" - ); - String textBeforeCursor = text.substring( - 0, - textField.getSelectionEnd() + colorCodes * 2 - ); + String textNCBeforeCursor = textNoColour.substring(0, textField.getSelectionEnd()); + int colorCodes = org.apache.commons.lang3.StringUtils.countMatches(textNCBeforeCursor, "\u00B6"); + String textBeforeCursor = text.substring(0, textField.getSelectionEnd() + colorCodes * 2); int numLinesBeforeCursor = org.apache.commons.lang3.StringUtils.countMatches( textBeforeCursor, @@ -405,11 +313,7 @@ public class GuiElementTextField { } else if (split.length > 0) { thisLineBeforeCursor = split[split.length - 1]; textBeforeCursorWidth = - Minecraft - .getMinecraft() - .fontRendererObj.getStringWidth( - thisLineBeforeCursor - ); + Minecraft.getMinecraft().fontRendererObj.getStringWidth(thisLineBeforeCursor); } else { return; } @@ -419,25 +323,13 @@ public class GuiElementTextField { String lineAfter = split2[numLinesBeforeCursor + 1]; String trimmed = Minecraft .getMinecraft() - .fontRendererObj.trimStringToWidth( - lineAfter, - textBeforeCursorWidth - ); + .fontRendererObj.trimStringToWidth(lineAfter, textBeforeCursorWidth); int linePos = strLenNoColor(trimmed); if (linePos != strLenNoColor(lineAfter)) { char after = lineAfter.charAt(linePos); - int trimmedWidth = Minecraft - .getMinecraft() - .fontRendererObj.getStringWidth(trimmed); - int charWidth = Minecraft - .getMinecraft() - .fontRendererObj.getCharWidth(after); - if ( - trimmedWidth + - charWidth / - 2 < - textBeforeCursorWidth - ) { + int trimmedWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(trimmed); + int charWidth = Minecraft.getMinecraft().fontRendererObj.getCharWidth(after); + if (trimmedWidth + charWidth / 2 < textBeforeCursorWidth) { linePos++; } } @@ -458,8 +350,7 @@ public class GuiElementTextField { } String old = textField.getText(); - if ((options & FORCE_CAPS) != 0) typedChar = - Character.toUpperCase(typedChar); + if ((options & FORCE_CAPS) != 0) typedChar = Character.toUpperCase(typedChar); if ((options & NO_SPACE) != 0 && typedChar == ' ') return; textField.setFocused(true); @@ -470,9 +361,7 @@ public class GuiElementTextField { int pos = textField.getCursorPosition() - 2; if (pos >= 0 && pos < textField.getText().length()) { if (textField.getText().charAt(pos) == '&') { - String before = textField - .getText() - .substring(0, pos); + String before = textField.getText().substring(0, pos); String after = ""; if (pos + 2 < textField.getText().length()) { after = textField.getText().substring(pos + 2); @@ -484,25 +373,14 @@ public class GuiElementTextField { } } - if ( - (options & NUM_ONLY) != 0 && - textField.getText().matches("[^0-9.]") - ) textField.setText(old); + if ((options & NUM_ONLY) != 0 && textField.getText().matches("[^0-9.]")) textField.setText(old); } } public void render(int x, int y) { this.x = x; this.y = y; - drawTextbox( - x, - y, - searchBarXSize, - searchBarYSize, - searchBarPadding, - textField, - focus - ); + drawTextbox(x, y, searchBarXSize, searchBarYSize, searchBarPadding, textField, focus); } private void drawTextbox( @@ -514,9 +392,7 @@ public class GuiElementTextField { GuiTextField textField, boolean focus ) { - ScaledResolution scaledresolution = new ScaledResolution( - Minecraft.getMinecraft() - ); + ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft()); String renderText = prependText + textField.getText(); GlStateManager.disableLighting(); @@ -524,16 +400,10 @@ public class GuiElementTextField { /** * Search bar */ - int paddingUnscaled = - searchBarPadding / scaledresolution.getScaleFactor(); + int paddingUnscaled = searchBarPadding / scaledresolution.getScaleFactor(); if (paddingUnscaled < 1) paddingUnscaled = 1; - int numLines = - org.apache.commons.lang3.StringUtils.countMatches( - renderText, - "\n" - ) + - 1; + int numLines = org.apache.commons.lang3.StringUtils.countMatches(renderText, "\n") + 1; int extraSize = (searchBarYSize - 8) / 2 + 8; int bottomTextBox = y + searchBarYSize + extraSize * (numLines - 1); @@ -549,18 +419,10 @@ public class GuiElementTextField { bottomTextBox + paddingUnscaled, borderColour ); - Gui.drawRect( - x, - y, - x + searchBarXSize, - bottomTextBox, - Color.BLACK.getRGB() - ); + Gui.drawRect(x, y, x + searchBarXSize, bottomTextBox, Color.BLACK.getRGB()); //bar text - Pattern patternControlCode = Pattern.compile( - "(?i)\\u00A7([^\\u00B6\n])(?!\\u00B6)" - ); + Pattern patternControlCode = Pattern.compile("(?i)\\u00A7([^\\u00B6\n])(?!\\u00B6)"); String text = renderText; String textNoColor = renderText; @@ -587,23 +449,13 @@ public class GuiElementTextField { if ( isScaling() && - Minecraft - .getMinecraft() - .fontRendererObj.getStringWidth(texts[yOffI]) > - searchBarXSize - - 10 + Minecraft.getMinecraft().fontRendererObj.getStringWidth(texts[yOffI]) > searchBarXSize - 10 ) { scale = (searchBarXSize - 2) / - (float) Minecraft - .getMinecraft() - .fontRendererObj.getStringWidth(texts[yOffI]); + (float) Minecraft.getMinecraft().fontRendererObj.getStringWidth(texts[yOffI]); if (scale > 1) scale = 1; - float newLen = - Minecraft - .getMinecraft() - .fontRendererObj.getStringWidth(texts[yOffI]) * - scale; + float newLen = Minecraft.getMinecraft().fontRendererObj.getStringWidth(texts[yOffI]) * scale; xStartOffset = (int) ((searchBarXSize - newLen) / 2f); TextRenderUtils.drawStringCenteredScaledMaxWidth( @@ -619,10 +471,7 @@ public class GuiElementTextField { Minecraft .getMinecraft() .fontRendererObj.drawString( - StringUtils.trimToWidth( - texts[yOffI], - searchBarXSize - 10 - ), + StringUtils.trimToWidth(texts[yOffI], searchBarXSize - 10), x + 5, y + (searchBarYSize - 8) / 2 + yOff, Color.WHITE.getRGB() @@ -631,25 +480,14 @@ public class GuiElementTextField { } if (focus && System.currentTimeMillis() % 1000 > 500) { - String textNCBeforeCursor = textNoColor.substring( - 0, - textField.getCursorPosition() + prependText.length() - ); - int colorCodes = org.apache.commons.lang3.StringUtils.countMatches( - textNCBeforeCursor, - "\u00B6" - ); + String textNCBeforeCursor = textNoColor.substring(0, textField.getCursorPosition() + prependText.length()); + int colorCodes = org.apache.commons.lang3.StringUtils.countMatches(textNCBeforeCursor, "\u00B6"); String textBeforeCursor = text.substring( 0, - textField.getCursorPosition() + - prependText.length() + - (((options & COLOUR) != 0) ? colorCodes * 2 : 0) + textField.getCursorPosition() + prependText.length() + (((options & COLOUR) != 0) ? colorCodes * 2 : 0) ); - int numLinesBeforeCursor = org.apache.commons.lang3.StringUtils.countMatches( - textBeforeCursor, - "\n" - ); + int numLinesBeforeCursor = org.apache.commons.lang3.StringUtils.countMatches(textBeforeCursor, "\n"); int yOff = numLinesBeforeCursor * extraSize; String[] split = textBeforeCursor.split("\n"); @@ -658,14 +496,7 @@ public class GuiElementTextField { textBeforeCursorWidth = 0; } else { textBeforeCursorWidth = - (int) ( - Minecraft - .getMinecraft() - .fontRendererObj.getStringWidth( - split[split.length - 1] - ) * - scale - ); + (int) (Minecraft.getMinecraft().fontRendererObj.getStringWidth(split[split.length - 1]) * scale); } Gui.drawRect( x + xStartOffset + textBeforeCursorWidth, @@ -701,16 +532,7 @@ public class GuiElementTextField { char c = textNoColor.charAt(i); if (sectionSignPrev) { - if ( - c != 'k' && - c != 'K' && - c != 'm' && - c != 'M' && - c != 'n' && - c != 'N' && - c != 'o' && - c != 'O' - ) { + if (c != 'k' && c != 'K' && c != 'm' && c != 'M' && c != 'n' && c != 'N' && c != 'o' && c != 'O') { bold = c == 'l' || c == 'L'; } sectionSignPrev = false; @@ -739,12 +561,8 @@ public class GuiElementTextField { //String c2 = bold ? EnumChatFormatting.BOLD.toString() : "" + c; - System.out.println( - "Adding len for char:" + c + ":" + Integer.toHexString(c) - ); - int len = Minecraft - .getMinecraft() - .fontRendererObj.getStringWidth(String.valueOf(c)); + System.out.println("Adding len for char:" + c + ":" + Integer.toHexString(c)); + int len = Minecraft.getMinecraft().fontRendererObj.getStringWidth(String.valueOf(c)); if (bold) len++; if (i >= leftIndex && i < rightIndex) { Gui.drawRect( diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/GuiScreenElementWrapper.java b/src/main/java/com/thatgravyboat/skyblockhud/core/GuiScreenElementWrapper.java index 747d7c5..326c85f 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/GuiScreenElementWrapper.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/GuiScreenElementWrapper.java @@ -22,12 +22,7 @@ public class GuiScreenElementWrapper extends GuiScreen { public void handleMouseInput() throws IOException { super.handleMouseInput(); int i = Mouse.getEventX() * this.width / this.mc.displayWidth; - int j = - this.height - - Mouse.getEventY() * - this.height / - this.mc.displayHeight - - 1; + int j = this.height - Mouse.getEventY() * this.height / this.mc.displayHeight - 1; element.mouseInput(i, j); } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/config/Position.java b/src/main/java/com/thatgravyboat/skyblockhud/core/config/Position.java index 0151e76..0b3a1f5 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/config/Position.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/config/Position.java @@ -93,11 +93,7 @@ public class Position { return ret; } - public int moveX( - int deltaX, - int objWidth, - ScaledResolution scaledResolution - ) { + public int moveX(int deltaX, int objWidth, ScaledResolution scaledResolution) { int screenWidth = scaledResolution.getScaledWidth(); boolean wasPositiveX = this.x >= 0; this.x += deltaX; @@ -146,11 +142,7 @@ public class Position { return deltaX; } - public int moveY( - int deltaY, - int objHeight, - ScaledResolution scaledResolution - ) { + public int moveY(int deltaY, int objHeight, ScaledResolution scaledResolution) { int screenHeight = scaledResolution.getScaledHeight(); boolean wasPositiveY = this.y >= 0; this.y += deltaY; @@ -199,13 +191,7 @@ public class Position { return deltaY; } - public boolean rightAligned( - ScaledResolution scaledResolution, - int objWidth - ) { - return ( - this.getAbsX(scaledResolution, objWidth) > - (scaledResolution.getScaledWidth() / 2) - ); + public boolean rightAligned(ScaledResolution scaledResolution, int objWidth) { + return (this.getAbsX(scaledResolution, objWidth) > (scaledResolution.getScaledWidth() / 2)); } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditor.java b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditor.java index 5dfcecc..85aa0b7 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditor.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditor.java @@ -33,9 +33,7 @@ public abstract class GuiOptionEditor { int maxLines = 5; float scale = 1; - int lineCount = fr - .listFormattedStringToWidth(option.desc, width * 2 / 3 - 10) - .size(); + int lineCount = fr.listFormattedStringToWidth(option.desc, width * 2 / 3 - 10).size(); if (lineCount <= 0) return; @@ -43,31 +41,15 @@ public abstract class GuiOptionEditor { while (paraHeight >= HEIGHT - 10) { scale -= 1 / 8f; - lineCount = - fr - .listFormattedStringToWidth( - option.desc, - (int) (width * 2 / 3 / scale - 10) - ) - .size(); + lineCount = fr.listFormattedStringToWidth(option.desc, (int) (width * 2 / 3 / scale - 10)).size(); paraHeight = (int) (9 * scale * lineCount - 1 * scale); } GlStateManager.pushMatrix(); - GlStateManager.translate( - x + 5 + width / 3f, - y + HEIGHT / 2f - paraHeight / 2, - 0 - ); + GlStateManager.translate(x + 5 + width / 3f, y + HEIGHT / 2f - paraHeight / 2, 0); GlStateManager.scale(scale, scale, 1); - fr.drawSplitString( - option.desc, - 0, - 0, - (int) (width * 2 / 3 / scale - 10), - 0xc0c0c0 - ); + fr.drawSplitString(option.desc, 0, 0, (int) (width * 2 / 3 / scale - 10), 0xc0c0c0); GlStateManager.popMatrix(); } @@ -76,23 +58,11 @@ public abstract class GuiOptionEditor { return HEIGHT; } - public abstract boolean mouseInput( - int x, - int y, - int width, - int mouseX, - int mouseY - ); + public abstract boolean mouseInput(int x, int y, int width, int mouseX, int mouseY); public abstract boolean keyboardInput(); - public boolean mouseInputOverlay( - int x, - int y, - int width, - int mouseX, - int mouseY - ) { + public boolean mouseInputOverlay(int x, int y, int width, int mouseX, int mouseY) { return false; } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorAccordion.java b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorAccordion.java index 5270c01..7888587 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorAccordion.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorAccordion.java @@ -16,10 +16,7 @@ public class GuiOptionEditorAccordion extends GuiOptionEditor { private int accordionId; private boolean accordionToggled; - public GuiOptionEditorAccordion( - ConfigProcessor.ProcessedOption option, - int accordionId - ) { + public GuiOptionEditorAccordion(ConfigProcessor.ProcessedOption option, int accordionId) { super(option); this.accordionToggled = (boolean) option.get(); this.accordionId = accordionId; @@ -52,19 +49,11 @@ public class GuiOptionEditorAccordion extends GuiOptionEditor { worldrenderer.begin(GL11.GL_TRIANGLES, DefaultVertexFormats.POSITION); if (accordionToggled) { worldrenderer.pos((double) x + 6, (double) y + 6, 0.0D).endVertex(); - worldrenderer - .pos((double) x + 9.75f, (double) y + 13.5f, 0.0D) - .endVertex(); - worldrenderer - .pos((double) x + 13.5f, (double) y + 6, 0.0D) - .endVertex(); + worldrenderer.pos((double) x + 9.75f, (double) y + 13.5f, 0.0D).endVertex(); + worldrenderer.pos((double) x + 13.5f, (double) y + 6, 0.0D).endVertex(); } else { - worldrenderer - .pos((double) x + 6, (double) y + 13.5f, 0.0D) - .endVertex(); - worldrenderer - .pos((double) x + 13.5f, (double) y + 9.75f, 0.0D) - .endVertex(); + worldrenderer.pos((double) x + 6, (double) y + 13.5f, 0.0D).endVertex(); + worldrenderer.pos((double) x + 13.5f, (double) y + 9.75f, 0.0D).endVertex(); worldrenderer.pos((double) x + 6, (double) y + 6, 0.0D).endVertex(); } tessellator.draw(); @@ -84,13 +73,7 @@ public class GuiOptionEditorAccordion extends GuiOptionEditor { @Override public boolean mouseInput(int x, int y, int width, int mouseX, int mouseY) { - if ( - Mouse.getEventButtonState() && - mouseX > x && - mouseX < x + width && - mouseY > y && - mouseY < y + getHeight() - ) { + if (Mouse.getEventButtonState() && mouseX > x && mouseX < x + width && mouseY > y && mouseY < y + getHeight()) { accordionToggled = !accordionToggled; return true; } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorBoolean.java b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorBoolean.java index 508a7cc..4167e06 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorBoolean.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorBoolean.java @@ -9,14 +9,7 @@ public class GuiOptionEditorBoolean extends GuiOptionEditor { public GuiOptionEditorBoolean(ConfigProcessor.ProcessedOption option) { super(option); - bool = - new GuiElementBoolean( - 0, - 0, - (boolean) option.get(), - 10, - option::set - ); + bool = new GuiElementBoolean(0, 0, (boolean) option.get(), 10, option::set); } @Override diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorButton.java b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorButton.java index 01fb7bd..7868ece 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorButton.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorButton.java @@ -28,9 +28,7 @@ public class GuiOptionEditorButton extends GuiOptionEditor { this.config = config; this.buttonText = buttonText; - if ( - this.buttonText != null && this.buttonText.isEmpty() - ) this.buttonText = null; + if (this.buttonText != null && this.buttonText.isEmpty()) this.buttonText = null; } @Override @@ -41,12 +39,7 @@ public class GuiOptionEditorButton extends GuiOptionEditor { GlStateManager.color(1, 1, 1, 1); Minecraft.getMinecraft().getTextureManager().bindTexture(button_tex); - RenderUtils.drawTexturedRect( - x + width / 6 - 24, - y + height - 7 - 14, - 48, - 16 - ); + RenderUtils.drawTexturedRect(x + width / 6 - 24, y + height - 7 - 14, 48, 16); if (buttonText != null) { TextRenderUtils.drawStringCenteredScaledMaxWidth( diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorColour.java b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorColour.java index ed44e5d..e64d14c 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorColour.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorColour.java @@ -31,12 +31,7 @@ public class GuiOptionEditorColour extends GuiOptionEditor { int b = argb & 0xFF; GlStateManager.color(r / 255f, g / 255f, b / 255f, 1); Minecraft.getMinecraft().getTextureManager().bindTexture(button_white); - RenderUtils.drawTexturedRect( - x + width / 6f - 24, - y + height - 7 - 14, - 48, - 16 - ); + RenderUtils.drawTexturedRect(x + width / 6f - 24, y + height - 7 - 14, 48, 16); } @Override @@ -47,16 +42,8 @@ public class GuiOptionEditorColour extends GuiOptionEditor { } @Override - public boolean mouseInputOverlay( - int x, - int y, - int width, - int mouseX, - int mouseY - ) { - return ( - colourElement != null && colourElement.mouseInput(mouseX, mouseY) - ); + public boolean mouseInputOverlay(int x, int y, int width, int mouseX, int mouseY) { + return (colourElement != null && colourElement.mouseInput(mouseX, mouseY)); } @Override diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorDraggableList.java b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorDraggableList.java index 619e144..11175a3 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorDraggableList.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorDraggableList.java @@ -21,9 +21,7 @@ import org.lwjgl.opengl.GL11; public class GuiOptionEditorDraggableList extends GuiOptionEditor { - private static final ResourceLocation DELETE = new ResourceLocation( - "notenoughupdates:core/delete.png" - ); + private static final ResourceLocation DELETE = new ResourceLocation("notenoughupdates:core/delete.png"); private String[] exampleText; private List activeText; @@ -37,10 +35,7 @@ public class GuiOptionEditorDraggableList extends GuiOptionEditor { private boolean dropdownOpen = false; - public GuiOptionEditorDraggableList( - ConfigProcessor.ProcessedOption option, - String[] exampleText - ) { + public GuiOptionEditorDraggableList(ConfigProcessor.ProcessedOption option, String[] exampleText) { super(option); this.exampleText = exampleText; this.activeText = (List) option.get(); @@ -66,12 +61,7 @@ public class GuiOptionEditorDraggableList extends GuiOptionEditor { GlStateManager.color(1, 1, 1, 1); Minecraft.getMinecraft().getTextureManager().bindTexture(button_tex); - RenderUtils.drawTexturedRect( - x + width / 6f - 24, - y + 45 - 7 - 14, - 48, - 16 - ); + RenderUtils.drawTexturedRect(x + width / 6f - 24, y + 45 - 7 - 14, 48, 16); TextRenderUtils.drawStringCenteredScaledMaxWidth( "Add", @@ -85,18 +75,11 @@ public class GuiOptionEditorDraggableList extends GuiOptionEditor { long currentTime = System.currentTimeMillis(); float greenBlue = LerpUtils.clampZeroOne( - ((trashHoverTime < 0 ? 250 : 0) + trashHoverTime - currentTime) / - 250f + ((trashHoverTime < 0 ? 250 : 0) + trashHoverTime - currentTime) / 250f ); GlStateManager.color(1, greenBlue, greenBlue, 1); Minecraft.getMinecraft().getTextureManager().bindTexture(DELETE); - Utils.drawTexturedRect( - x + width / 6f + 27, - y + 45 - 7 - 13, - 11, - 14, - GL11.GL_NEAREST - ); + Utils.drawTexturedRect(x + width / 6f + 27, y + 45 - 7 - 13, 11, 14, GL11.GL_NEAREST); Gui.drawRect(x + 5, y + 45, x + width - 5, y + height - 5, 0xffdddddd); Gui.drawRect(x + 6, y + 46, x + width - 6, y + height - 6, 0xff000000); @@ -111,11 +94,7 @@ public class GuiOptionEditorDraggableList extends GuiOptionEditor { int ySize = multilines.length * 10; if (i++ != dragStartIndex) { - for ( - int multilineIndex = 0; - multilineIndex < multilines.length; - multilineIndex++ - ) { + for (int multilineIndex = 0; multilineIndex < multilines.length; multilineIndex++) { String line = multilines[multilineIndex]; Utils.drawStringScaledMaxWidth( line + EnumChatFormatting.RESET, @@ -129,13 +108,7 @@ public class GuiOptionEditorDraggableList extends GuiOptionEditor { } Minecraft .getMinecraft() - .fontRendererObj.drawString( - "\u2261", - x + 10, - y + 50 + yOff + ySize / 2f - 4, - 0xffffff, - true - ); + .fontRendererObj.drawString("\u2261", x + 10, y + 50 + yOff + ySize / 2f - 4, 0xffffff, true); } yOff += ySize; @@ -164,27 +137,9 @@ public class GuiOptionEditorDraggableList extends GuiOptionEditor { int outline = 0xff404046; Gui.drawRect(left, top, left + 1, top + dropdownHeight, outline); //Left Gui.drawRect(left + 1, top, left + dropdownWidth, top + 1, outline); //Top - Gui.drawRect( - left + dropdownWidth - 1, - top + 1, - left + dropdownWidth, - top + dropdownHeight, - outline - ); //Right - Gui.drawRect( - left + 1, - top + dropdownHeight - 1, - left + dropdownWidth - 1, - top + dropdownHeight, - outline - ); //Bottom - Gui.drawRect( - left + 1, - top + 1, - left + dropdownWidth - 1, - top + dropdownHeight - 1, - main - ); //Middle + Gui.drawRect(left + dropdownWidth - 1, top + 1, left + dropdownWidth, top + dropdownHeight, outline); //Right + Gui.drawRect(left + 1, top + dropdownHeight - 1, left + dropdownWidth - 1, top + dropdownHeight, outline); //Bottom + Gui.drawRect(left + 1, top + 1, left + dropdownWidth - 1, top + dropdownHeight - 1, main); //Middle int dropdownY = -1; for (int strIndex : remaining) { @@ -207,26 +162,17 @@ public class GuiOptionEditorDraggableList extends GuiOptionEditor { int opacity = 0x80; long currentTime = System.currentTimeMillis(); if (trashHoverTime < 0) { - float greenBlue = LerpUtils.clampZeroOne( - (currentTime + trashHoverTime) / 250f - ); + float greenBlue = LerpUtils.clampZeroOne((currentTime + trashHoverTime) / 250f); opacity = (int) (opacity * greenBlue); } else { - float greenBlue = LerpUtils.clampZeroOne( - (250 + trashHoverTime - currentTime) / 250f - ); + float greenBlue = LerpUtils.clampZeroOne((250 + trashHoverTime - currentTime) / 250f); opacity = (int) (opacity * greenBlue); } if (opacity < 20) return; - ScaledResolution scaledResolution = new ScaledResolution( - Minecraft.getMinecraft() - ); - int mouseX = - Mouse.getX() * - scaledResolution.getScaledWidth() / - Minecraft.getMinecraft().displayWidth; + ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); + int mouseX = Mouse.getX() * scaledResolution.getScaledWidth() / Minecraft.getMinecraft().displayWidth; int mouseY = scaledResolution.getScaledHeight() - Mouse.getY() * @@ -239,11 +185,7 @@ public class GuiOptionEditorDraggableList extends GuiOptionEditor { String[] multilines = str.split("\n"); GlStateManager.enableBlend(); - for ( - int multilineIndex = 0; - multilineIndex < multilines.length; - multilineIndex++ - ) { + for (int multilineIndex = 0; multilineIndex < multilines.length; multilineIndex++) { String line = multilines[multilineIndex]; Utils.drawStringScaledMaxWidth( line + EnumChatFormatting.RESET, @@ -291,8 +233,7 @@ public class GuiOptionEditorDraggableList extends GuiOptionEditor { if (!Mouse.isButtonDown(0) || dropdownOpen) { currentDragging = -1; dragStartIndex = -1; - if (trashHoverTime > 0) trashHoverTime = - -System.currentTimeMillis(); + if (trashHoverTime > 0) trashHoverTime = -System.currentTimeMillis(); } else if ( currentDragging >= 0 && mouseX >= x + width / 6 + 27 - 3 && @@ -302,8 +243,7 @@ public class GuiOptionEditorDraggableList extends GuiOptionEditor { ) { if (trashHoverTime < 0) trashHoverTime = System.currentTimeMillis(); } else { - if (trashHoverTime > 0) trashHoverTime = - -System.currentTimeMillis(); + if (trashHoverTime > 0) trashHoverTime = -System.currentTimeMillis(); } if (Mouse.getEventButtonState()) { @@ -322,12 +262,7 @@ public class GuiOptionEditorDraggableList extends GuiOptionEditor { int dropdownHeight = -1 + 12 * remaining.size(); - if ( - mouseX > left && - mouseX < left + dropdownWidth && - mouseY > top && - mouseY < top + dropdownHeight - ) { + if (mouseX > left && mouseX < left + dropdownWidth && mouseY > top && mouseY < top + dropdownHeight) { int dropdownY = -1; for (int strIndex : remaining) { if (mouseY < top + dropdownY + 12) { diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorDropdown.java b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorDropdown.java index 8aa5c08..43a04d7 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorDropdown.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorDropdown.java @@ -47,13 +47,7 @@ public class GuiOptionEditorDropdown extends GuiOptionEditor { selectedString = values[selected]; } - RenderUtils.drawFloatingRectDark( - left, - top, - dropdownWidth, - 14, - false - ); + RenderUtils.drawFloatingRectDark(left, top, dropdownWidth, 14, false); TextRenderUtils.drawStringScaled( "\u25BC", fr, @@ -97,35 +91,11 @@ public class GuiOptionEditorDropdown extends GuiOptionEditor { int blue = 0xff2355ad; Gui.drawRect(left, top, left + 1, top + dropdownHeight, blue); //Left Gui.drawRect(left + 1, top, left + dropdownWidth, top + 1, blue); //Top - Gui.drawRect( - left + dropdownWidth - 1, - top + 1, - left + dropdownWidth, - top + dropdownHeight, - blue - ); //Right - Gui.drawRect( - left + 1, - top + dropdownHeight - 1, - left + dropdownWidth - 1, - top + dropdownHeight, - blue - ); //Bottom - Gui.drawRect( - left + 1, - top + 1, - left + dropdownWidth - 1, - top + dropdownHeight - 1, - main - ); //Middle - - Gui.drawRect( - left + 1, - top + 14 - 1, - left + dropdownWidth - 1, - top + 14, - blue - ); //Bar + Gui.drawRect(left + dropdownWidth - 1, top + 1, left + dropdownWidth, top + dropdownHeight, blue); //Right + Gui.drawRect(left + 1, top + dropdownHeight - 1, left + dropdownWidth - 1, top + dropdownHeight, blue); //Bottom + Gui.drawRect(left + 1, top + 1, left + dropdownWidth - 1, top + dropdownHeight - 1, main); //Middle + + Gui.drawRect(left + 1, top + 14 - 1, left + dropdownWidth - 1, top + 14, blue); //Bar int dropdownY = 13; for (String option : values) { @@ -174,12 +144,7 @@ public class GuiOptionEditorDropdown extends GuiOptionEditor { int top = y + height - 7 - 14; if (Mouse.getEventButtonState() && Mouse.getEventButton() == 0) { - if ( - mouseX >= left && - mouseX <= left + 80 && - mouseY >= top && - mouseY <= top + 14 - ) { + if (mouseX >= left && mouseX <= left + 80 && mouseY >= top && mouseY <= top + 14) { open = !open; return true; } @@ -189,36 +154,19 @@ public class GuiOptionEditorDropdown extends GuiOptionEditor { } @Override - public boolean mouseInputOverlay( - int x, - int y, - int width, - int mouseX, - int mouseY - ) { + public boolean mouseInputOverlay(int x, int y, int width, int mouseX, int mouseY) { int height = getHeight(); int left = x + width / 6 - 40; int top = y + height - 7 - 14; if (Mouse.getEventButtonState() && Mouse.getEventButton() == 0) { - if ( - !( - mouseX >= left && - mouseX <= left + 80 && - mouseY >= top && - mouseY <= top + 14 - ) && - open - ) { + if (!(mouseX >= left && mouseX <= left + 80 && mouseY >= top && mouseY <= top + 14) && open) { open = false; if (mouseX >= left && mouseX <= left + 80) { int dropdownY = 13; for (int ordinal = 0; ordinal < values.length; ordinal++) { - if ( - mouseY >= top + 3 + dropdownY && - mouseY <= top + 3 + dropdownY + 12 - ) { + if (mouseY >= top + 3 + dropdownY && mouseY <= top + 3 + dropdownY + 12) { selected = ordinal; if (useOrdinal) { option.set(selected); diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorSlider.java b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorSlider.java index dd981d8..2932e34 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorSlider.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorSlider.java @@ -33,9 +33,7 @@ public class GuiOptionEditorSlider extends GuiOptionEditor { textField = new GuiElementTextField( strVal, - GuiElementTextField.NO_SPACE | - GuiElementTextField.NUM_ONLY | - GuiElementTextField.SCALE_TEXT + GuiElementTextField.NO_SPACE | GuiElementTextField.NUM_ONLY | GuiElementTextField.SCALE_TEXT ); } @@ -56,8 +54,7 @@ public class GuiOptionEditorSlider extends GuiOptionEditor { strVal = Integer.toString(val.intValue()); } else { strVal = Float.toString(val); - strVal = - strVal.replaceAll("(\\.\\d\\d\\d)(?:\\d)+", "$1"); + strVal = strVal.replaceAll("(\\.\\d\\d\\d)(?:\\d)+", "$1"); strVal = strVal.replaceAll("0+$", ""); } textField.setText(strVal); @@ -80,29 +77,16 @@ public class GuiOptionEditorSlider extends GuiOptionEditor { slider.render(); if (textField.getFocus()) { - textField.setOptions( - GuiElementTextField.NO_SPACE | GuiElementTextField.NUM_ONLY - ); - textField.setSize( - Minecraft - .getMinecraft() - .fontRendererObj.getStringWidth(textField.getText()) + - 10, - 16 - ); + textField.setOptions(GuiElementTextField.NO_SPACE | GuiElementTextField.NUM_ONLY); + textField.setSize(Minecraft.getMinecraft().fontRendererObj.getStringWidth(textField.getText()) + 10, 16); } else { textField.setSize(textFieldWidth, 16); textField.setOptions( - GuiElementTextField.NO_SPACE | - GuiElementTextField.NUM_ONLY | - GuiElementTextField.SCALE_TEXT + GuiElementTextField.NO_SPACE | GuiElementTextField.NUM_ONLY | GuiElementTextField.SCALE_TEXT ); } - textField.render( - x + width / 6 - fullWidth / 2 + sliderWidth + 5, - y + height - 7 - 14 - ); + textField.render(x + width / 6 - fullWidth / 2 + sliderWidth + 5, y + height - 7 - 14); } @Override @@ -122,21 +106,14 @@ public class GuiOptionEditorSlider extends GuiOptionEditor { } if (textField.getFocus()) { - textFieldWidth = - Minecraft - .getMinecraft() - .fontRendererObj.getStringWidth(textField.getText()) + - 10; + textFieldWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(textField.getText()) + 10; } int textFieldX = x + width / 6 - fullWidth / 2 + sliderWidth + 5; int textFieldY = y + height - 7 - 14; textField.setSize(textFieldWidth, 16); - if ( - Mouse.getEventButtonState() && - (Mouse.getEventButton() == 0 || Mouse.getEventButton() == 1) - ) { + if (Mouse.getEventButtonState() && (Mouse.getEventButton() == 0 || Mouse.getEventButton() == 1)) { if ( mouseX > textFieldX && mouseX < textFieldX + textFieldWidth && @@ -155,10 +132,7 @@ public class GuiOptionEditorSlider extends GuiOptionEditor { @Override public boolean keyboardInput() { if (Keyboard.getEventKeyState() && textField.getFocus()) { - textField.keyTyped( - Keyboard.getEventCharacter(), - Keyboard.getEventKey() - ); + textField.keyTyped(Keyboard.getEventCharacter(), Keyboard.getEventKey()); try { textField.setCustomBorderColour(0xffffffff); diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorText.java b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorText.java index 3e712f2..da39ca1 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorText.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorText.java @@ -27,13 +27,7 @@ public class GuiOptionEditorText extends GuiOptionEditor { int textFieldX = x + width / 6 - fullWidth / 2; if (textField.getFocus()) { fullWidth = - Math.max( - fullWidth, - Minecraft - .getMinecraft() - .fontRendererObj.getStringWidth(textField.getText()) + - 10 - ); + Math.max(fullWidth, Minecraft.getMinecraft().fontRendererObj.getStringWidth(textField.getText()) + 10); } textField.setSize(fullWidth, 16); @@ -51,22 +45,13 @@ public class GuiOptionEditorText extends GuiOptionEditor { if (textField.getFocus()) { fullWidth = - Math.max( - fullWidth, - Minecraft - .getMinecraft() - .fontRendererObj.getStringWidth(textField.getText()) + - 10 - ); + Math.max(fullWidth, Minecraft.getMinecraft().fontRendererObj.getStringWidth(textField.getText()) + 10); } int textFieldY = y + height - 7 - 14; textField.setSize(fullWidth, 16); - if ( - Mouse.getEventButtonState() && - (Mouse.getEventButton() == 0 || Mouse.getEventButton() == 1) - ) { + if (Mouse.getEventButtonState() && (Mouse.getEventButton() == 0 || Mouse.getEventButton() == 1)) { if ( mouseX > textFieldX && mouseX < textFieldX + fullWidth && @@ -86,10 +71,7 @@ public class GuiOptionEditorText extends GuiOptionEditor { public boolean keyboardInput() { if (Keyboard.getEventKeyState() && textField.getFocus()) { Keyboard.enableRepeatEvents(true); - textField.keyTyped( - Keyboard.getEventCharacter(), - Keyboard.getEventKey() - ); + textField.keyTyped(Keyboard.getEventCharacter(), Keyboard.getEventKey()); try { textField.setCustomBorderColour(0xffffffff); diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiPositionEditor.java b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiPositionEditor.java index eaa399e..0fae02e 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiPositionEditor.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiPositionEditor.java @@ -67,28 +67,13 @@ public class GuiPositionEditor extends GuiScreen { this.width = scaledResolution.getScaledWidth(); this.height = scaledResolution.getScaledHeight(); mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth; - mouseY = - height - - Mouse.getY() * - height / - Minecraft.getMinecraft().displayHeight - - 1; + mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1; drawDefaultBackground(); if (clicked) { - grabbedX += - position.moveX( - mouseX - grabbedX, - elementWidth, - scaledResolution - ); - grabbedY += - position.moveY( - mouseY - grabbedY, - elementHeight, - scaledResolution - ); + grabbedX += position.moveX(mouseX - grabbedX, elementWidth, scaledResolution); + grabbedY += position.moveY(mouseY - grabbedY, elementHeight, scaledResolution); } renderCallback.run(); @@ -124,8 +109,7 @@ public class GuiPositionEditor extends GuiScreen { } @Override - protected void mouseClicked(int mouseX, int mouseY, int mouseButton) - throws IOException { + protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException { super.mouseClicked(mouseX, mouseY, mouseButton); if (mouseButton == 0) { @@ -133,29 +117,17 @@ public class GuiPositionEditor extends GuiScreen { if (guiScaleOverride >= 0) { scaledResolution = Utils.pushGuiScale(guiScaleOverride); } else { - scaledResolution = - new ScaledResolution(Minecraft.getMinecraft()); + scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); } - mouseX = - Mouse.getX() * width / Minecraft.getMinecraft().displayWidth; - mouseY = - height - - Mouse.getY() * - height / - Minecraft.getMinecraft().displayHeight - - 1; + mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth; + mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1; int x = position.getAbsX(scaledResolution, elementWidth); int y = position.getAbsY(scaledResolution, elementHeight); if (position.isCenterX()) x -= elementWidth / 2; if (position.isCenterY()) y -= elementHeight / 2; - if ( - mouseX >= x && - mouseY >= y && - mouseX <= x + elementWidth && - mouseY <= y + elementHeight - ) { + if (mouseX >= x && mouseY >= y && mouseX <= x + elementWidth && mouseY <= y + elementHeight) { clicked = true; grabbedX = mouseX; grabbedY = mouseY; @@ -174,34 +146,16 @@ public class GuiPositionEditor extends GuiScreen { if (keyCode == Keyboard.KEY_R) { position.set(originalPosition); } else if (!clicked) { - boolean shiftHeld = - Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || - Keyboard.isKeyDown(Keyboard.KEY_RSHIFT); + boolean shiftHeld = Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT); int dist = shiftHeld ? 10 : 1; if (keyCode == Keyboard.KEY_DOWN) { - position.moveY( - dist, - elementHeight, - new ScaledResolution(Minecraft.getMinecraft()) - ); + position.moveY(dist, elementHeight, new ScaledResolution(Minecraft.getMinecraft())); } else if (keyCode == Keyboard.KEY_UP) { - position.moveY( - -dist, - elementHeight, - new ScaledResolution(Minecraft.getMinecraft()) - ); + position.moveY(-dist, elementHeight, new ScaledResolution(Minecraft.getMinecraft())); } else if (keyCode == Keyboard.KEY_LEFT) { - position.moveX( - -dist, - elementWidth, - new ScaledResolution(Minecraft.getMinecraft()) - ); + position.moveX(-dist, elementWidth, new ScaledResolution(Minecraft.getMinecraft())); } else if (keyCode == Keyboard.KEY_RIGHT) { - position.moveX( - dist, - elementWidth, - new ScaledResolution(Minecraft.getMinecraft()) - ); + position.moveX(dist, elementWidth, new ScaledResolution(Minecraft.getMinecraft())); } } super.keyTyped(typedChar, keyCode); @@ -214,48 +168,21 @@ public class GuiPositionEditor extends GuiScreen { } @Override - protected void mouseClickMove( - int mouseX, - int mouseY, - int clickedMouseButton, - long timeSinceLastClick - ) { - super.mouseClickMove( - mouseX, - mouseY, - clickedMouseButton, - timeSinceLastClick - ); + protected void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) { + super.mouseClickMove(mouseX, mouseY, clickedMouseButton, timeSinceLastClick); if (clicked) { ScaledResolution scaledResolution; if (guiScaleOverride >= 0) { scaledResolution = Utils.pushGuiScale(guiScaleOverride); } else { - scaledResolution = - new ScaledResolution(Minecraft.getMinecraft()); + scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); } - mouseX = - Mouse.getX() * width / Minecraft.getMinecraft().displayWidth; - mouseY = - height - - Mouse.getY() * - height / - Minecraft.getMinecraft().displayHeight - - 1; + mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth; + mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1; - grabbedX += - position.moveX( - mouseX - grabbedX, - elementWidth, - scaledResolution - ); - grabbedY += - position.moveY( - mouseY - grabbedY, - elementHeight, - scaledResolution - ); + grabbedX += position.moveX(mouseX - grabbedX, elementWidth, scaledResolution); + grabbedY += position.moveY(mouseY - grabbedY, elementHeight, scaledResolution); positionChangedCallback.run(); if (guiScaleOverride >= 0) { diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/config/struct/ConfigProcessor.java b/src/main/java/com/thatgravyboat/skyblockhud/core/config/struct/ConfigProcessor.java index 559fa9e..e989b61 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/config/struct/ConfigProcessor.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/config/struct/ConfigProcessor.java @@ -35,13 +35,7 @@ public class ConfigProcessor { private final Field field; private final Object container; - public ProcessedOption( - String name, - String desc, - int subcategoryId, - Field field, - Object container - ) { + public ProcessedOption(String name, String desc, int subcategoryId, Field field, Object container) { this.name = name; this.desc = desc; this.subcategoryId = subcategoryId; @@ -73,17 +67,11 @@ public class ConfigProcessor { } } - public static LinkedHashMap create( - Config config - ) { + public static LinkedHashMap create(Config config) { LinkedHashMap processedConfig = new LinkedHashMap<>(); for (Field categoryField : config.getClass().getDeclaredFields()) { - boolean exposePresent = categoryField.isAnnotationPresent( - Expose.class - ); - boolean categoryPresent = categoryField.isAnnotationPresent( - Category.class - ); + boolean exposePresent = categoryField.isAnnotationPresent(Expose.class); + boolean categoryPresent = categoryField.isAnnotationPresent(Category.class); if (exposePresent && categoryPresent) { Object categoryObj; @@ -94,26 +82,15 @@ public class ConfigProcessor { continue; } - Category categoryAnnotation = categoryField.getAnnotation( - Category.class - ); - ProcessedCategory cat = new ProcessedCategory( - categoryAnnotation.name(), - categoryAnnotation.desc() - ); + Category categoryAnnotation = categoryField.getAnnotation(Category.class); + ProcessedCategory cat = new ProcessedCategory(categoryAnnotation.name(), categoryAnnotation.desc()); processedConfig.put(categoryField.getName(), cat); - for (Field optionField : categoryObj - .getClass() - .getDeclaredFields()) { - boolean optionPresent = optionField.isAnnotationPresent( - ConfigOption.class - ); + for (Field optionField : categoryObj.getClass().getDeclaredFields()) { + boolean optionPresent = optionField.isAnnotationPresent(ConfigOption.class); if (optionPresent) { - ConfigOption optionAnnotation = optionField.getAnnotation( - ConfigOption.class - ); + ConfigOption optionAnnotation = optionField.getAnnotation(ConfigOption.class); ProcessedOption option = new ProcessedOption( optionAnnotation.name(), optionAnnotation.desc(), @@ -121,24 +98,14 @@ public class ConfigProcessor { optionField, categoryObj ); - if ( - optionField.isAnnotationPresent( - ConfigAccordionId.class - ) - ) { - ConfigAccordionId annotation = optionField.getAnnotation( - ConfigAccordionId.class - ); + if (optionField.isAnnotationPresent(ConfigAccordionId.class)) { + ConfigAccordionId annotation = optionField.getAnnotation(ConfigAccordionId.class); option.accordionId = annotation.id(); } GuiOptionEditor editor = null; Class optionType = optionField.getType(); - if ( - optionField.isAnnotationPresent( - ConfigEditorButton.class - ) - ) { + if (optionField.isAnnotationPresent(ConfigEditorButton.class)) { ConfigEditorButton configEditorAnnotation = optionField.getAnnotation( ConfigEditorButton.class ); @@ -152,33 +119,21 @@ public class ConfigProcessor { } if ( optionType.isAssignableFrom(boolean.class) && - optionField.isAnnotationPresent( - ConfigEditorBoolean.class - ) + optionField.isAnnotationPresent(ConfigEditorBoolean.class) ) { editor = new GuiOptionEditorBoolean(option); } if ( optionType.isAssignableFrom(boolean.class) && - optionField.isAnnotationPresent( - ConfigEditorAccordion.class - ) + optionField.isAnnotationPresent(ConfigEditorAccordion.class) ) { ConfigEditorAccordion configEditorAnnotation = optionField.getAnnotation( ConfigEditorAccordion.class ); - editor = - new GuiOptionEditorAccordion( - option, - configEditorAnnotation.id() - ); + editor = new GuiOptionEditorAccordion(option, configEditorAnnotation.id()); } if (optionType.isAssignableFrom(int.class)) { - if ( - optionField.isAnnotationPresent( - ConfigEditorDropdown.class - ) - ) { + if (optionField.isAnnotationPresent(ConfigEditorDropdown.class)) { ConfigEditorDropdown configEditorAnnotation = optionField.getAnnotation( ConfigEditorDropdown.class ); @@ -192,27 +147,15 @@ public class ConfigProcessor { } } if (optionType.isAssignableFrom(List.class)) { - if ( - optionField.isAnnotationPresent( - ConfigEditorDraggableList.class - ) - ) { + if (optionField.isAnnotationPresent(ConfigEditorDraggableList.class)) { ConfigEditorDraggableList configEditorAnnotation = optionField.getAnnotation( ConfigEditorDraggableList.class ); - editor = - new GuiOptionEditorDraggableList( - option, - configEditorAnnotation.exampleText() - ); + editor = new GuiOptionEditorDraggableList(option, configEditorAnnotation.exampleText()); } } if (optionType.isAssignableFrom(String.class)) { - if ( - optionField.isAnnotationPresent( - ConfigEditorDropdown.class - ) - ) { + if (optionField.isAnnotationPresent(ConfigEditorDropdown.class)) { ConfigEditorDropdown configEditorAnnotation = optionField.getAnnotation( ConfigEditorDropdown.class ); @@ -223,17 +166,9 @@ public class ConfigProcessor { configEditorAnnotation.initialIndex(), false ); - } else if ( - optionField.isAnnotationPresent( - ConfigEditorColour.class - ) - ) { + } else if (optionField.isAnnotationPresent(ConfigEditorColour.class)) { editor = new GuiOptionEditorColour(option); - } else if ( - optionField.isAnnotationPresent( - ConfigEditorText.class - ) - ) { + } else if (optionField.isAnnotationPresent(ConfigEditorText.class)) { editor = new GuiOptionEditorText(option); } } @@ -242,11 +177,7 @@ public class ConfigProcessor { optionType.isAssignableFrom(float.class) || optionType.isAssignableFrom(double.class) ) { - if ( - optionField.isAnnotationPresent( - ConfigEditorSlider.class - ) - ) { + if (optionField.isAnnotationPresent(ConfigEditorSlider.class)) { ConfigEditorSlider configEditorAnnotation = optionField.getAnnotation( ConfigEditorSlider.class ); @@ -260,21 +191,11 @@ public class ConfigProcessor { } } if (optionType.isAssignableFrom(String.class)) { - if ( - optionField.isAnnotationPresent( - ConfigEditorDropdown.class - ) - ) { + if (optionField.isAnnotationPresent(ConfigEditorDropdown.class)) { ConfigEditorDropdown configEditorAnnotation = optionField.getAnnotation( ConfigEditorDropdown.class ); - editor = - new GuiOptionEditorDropdown( - option, - configEditorAnnotation.values(), - 0, - false - ); + editor = new GuiOptionEditorDropdown(option, configEditorAnnotation.values(), 0, false); } } if (editor == null) { diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/util/GuiElementSlider.java b/src/main/java/com/thatgravyboat/skyblockhud/core/util/GuiElementSlider.java index cdd745d..fd7d3b3 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/util/GuiElementSlider.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/util/GuiElementSlider.java @@ -55,13 +55,8 @@ public class GuiElementSlider extends GuiElement { @Override public void render() { - final ScaledResolution scaledResolution = new ScaledResolution( - Minecraft.getMinecraft() - ); - int mouseX = - Mouse.getX() * - scaledResolution.getScaledWidth() / - Minecraft.getMinecraft().displayWidth; + final ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); + int mouseX = Mouse.getX() * scaledResolution.getScaledWidth() / Minecraft.getMinecraft().displayWidth; float value = this.value; if (clicked) { @@ -70,47 +65,23 @@ public class GuiElementSlider extends GuiElement { value = Math.round(value / minStep) * minStep; } - float sliderAmount = Math.max( - 0, - Math.min(1, (value - minValue) / (maxValue - minValue)) - ); + float sliderAmount = Math.max(0, Math.min(1, (value - minValue) / (maxValue - minValue))); int sliderAmountI = (int) (width * sliderAmount); GlStateManager.color(1f, 1f, 1f, 1f); Minecraft.getMinecraft().getTextureManager().bindTexture(slider_on_cap); Utils.drawTexturedRect(x, y, 4, HEIGHT, GL11.GL_NEAREST); - Minecraft - .getMinecraft() - .getTextureManager() - .bindTexture(slider_off_cap); + Minecraft.getMinecraft().getTextureManager().bindTexture(slider_off_cap); Utils.drawTexturedRect(x + width - 4, y, 4, HEIGHT, GL11.GL_NEAREST); if (sliderAmountI > 5) { - Minecraft - .getMinecraft() - .getTextureManager() - .bindTexture(slider_on_segment); - Utils.drawTexturedRect( - x + 4, - y, - sliderAmountI - 4, - HEIGHT, - GL11.GL_NEAREST - ); + Minecraft.getMinecraft().getTextureManager().bindTexture(slider_on_segment); + Utils.drawTexturedRect(x + 4, y, sliderAmountI - 4, HEIGHT, GL11.GL_NEAREST); } if (sliderAmountI < width - 5) { - Minecraft - .getMinecraft() - .getTextureManager() - .bindTexture(slider_off_segment); - Utils.drawTexturedRect( - x + sliderAmountI, - y, - width - 4 - sliderAmountI, - HEIGHT, - GL11.GL_NEAREST - ); + Minecraft.getMinecraft().getTextureManager().bindTexture(slider_off_segment); + Utils.drawTexturedRect(x + sliderAmountI, y, width - 4 - sliderAmountI, HEIGHT, GL11.GL_NEAREST); } for (int i = 1; i < 4; i++) { @@ -118,31 +89,12 @@ public class GuiElementSlider extends GuiElement { Minecraft .getMinecraft() .getTextureManager() - .bindTexture( - notchX > x + sliderAmountI - ? slider_off_notch - : slider_on_notch - ); - Utils.drawTexturedRect( - notchX, - y + (HEIGHT - 4) / 2f, - 2, - 4, - GL11.GL_NEAREST - ); + .bindTexture(notchX > x + sliderAmountI ? slider_off_notch : slider_on_notch); + Utils.drawTexturedRect(notchX, y + (HEIGHT - 4) / 2f, 2, 4, GL11.GL_NEAREST); } - Minecraft - .getMinecraft() - .getTextureManager() - .bindTexture(slider_button_new); - Utils.drawTexturedRect( - x + sliderAmountI - 4, - y, - 8, - HEIGHT, - GL11.GL_NEAREST - ); + Minecraft.getMinecraft().getTextureManager().bindTexture(slider_button_new); + Utils.drawTexturedRect(x + sliderAmountI - 4, y, 8, HEIGHT, GL11.GL_NEAREST); } @Override @@ -153,26 +105,17 @@ public class GuiElementSlider extends GuiElement { if (Mouse.getEventButton() == 0) { clicked = - Mouse.getEventButtonState() && - mouseX > x && - mouseX < x + width && - mouseY > y && - mouseY < y + HEIGHT; + Mouse.getEventButtonState() && mouseX > x && mouseX < x + width && mouseY > y && mouseY < y + HEIGHT; if (clicked) { value = (mouseX - x) * (maxValue - minValue) / width + minValue; value = Math.max(minValue, Math.min(maxValue, value)); - value = - (float) (Math.round(value / minStep) * (double) minStep); + value = (float) (Math.round(value / minStep) * (double) minStep); setCallback.accept(value); return true; } } - if ( - !Mouse.getEventButtonState() && - Mouse.getEventButton() == -1 && - clicked - ) { + if (!Mouse.getEventButtonState() && Mouse.getEventButton() == -1 && clicked) { value = (mouseX - x) * (maxValue - minValue) / width + minValue; value = Math.max(minValue, Math.min(maxValue, value)); value = Math.round(value / minStep) * minStep; diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/util/MiscUtils.java b/src/main/java/com/thatgravyboat/skyblockhud/core/util/MiscUtils.java index 4173694..5c59853 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/util/MiscUtils.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/util/MiscUtils.java @@ -21,10 +21,7 @@ import org.lwjgl.input.Mouse; public class MiscUtils { public static void copyToClipboard(String str) { - Toolkit - .getDefaultToolkit() - .getSystemClipboard() - .setContents(new StringSelection(str), null); + Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(str), null); } private static void unzip(InputStream src, File dest) { @@ -79,52 +76,28 @@ public class MiscUtils { } catch (Exception ignored) {} } - public static void setCursor( - ResourceLocation loc, - int hotspotX, - int hotspotY - ) { - if ( - currentCursor != null && loc.getResourcePath().equals(currentCursor) - ) { + public static void setCursor(ResourceLocation loc, int hotspotX, int hotspotY) { + if (currentCursor != null && loc.getResourcePath().equals(currentCursor)) { return; } currentCursor = loc.getResourcePath(); try { BufferedImage image = ImageIO.read( - Minecraft - .getMinecraft() - .getResourceManager() - .getResource(loc) - .getInputStream() + Minecraft.getMinecraft().getResourceManager().getResource(loc).getInputStream() ); int maxSize = Cursor.getMaxCursorSize(); IntBuffer buffer = BufferUtils.createIntBuffer(maxSize * maxSize); for (int i = 0; i < maxSize * maxSize; i++) { int cursorX = i % maxSize; int cursorY = i / maxSize; - if ( - cursorX >= image.getWidth() || cursorY >= image.getHeight() - ) { + if (cursorX >= image.getWidth() || cursorY >= image.getHeight()) { buffer.put(0x00000000); } else { - buffer.put( - image.getRGB(cursorX, image.getHeight() - 1 - cursorY) - ); + buffer.put(image.getRGB(cursorX, image.getHeight() - 1 - cursorY)); } } buffer.flip(); - Mouse.setNativeCursor( - new Cursor( - maxSize, - maxSize, - hotspotX, - hotspotY, - 1, - buffer, - null - ) - ); + Mouse.setNativeCursor(new Cursor(maxSize, maxSize, hotspotX, hotspotY, 1, buffer, null)); } catch (Exception e) { e.printStackTrace(); } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/util/StringUtils.java b/src/main/java/com/thatgravyboat/skyblockhud/core/util/StringUtils.java index 48c7566..5b34cb1 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/util/StringUtils.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/util/StringUtils.java @@ -7,10 +7,7 @@ import net.minecraft.client.gui.FontRenderer; public class StringUtils { - public static final Set PROTOCOLS = Sets.newHashSet( - "http", - "https" - ); + public static final Set PROTOCOLS = Sets.newHashSet("http", "https"); public static String cleanColour(String in) { return in.replaceAll("(?i)\\u00A7.", ""); diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/util/lerp/LerpUtils.java b/src/main/java/com/thatgravyboat/skyblockhud/core/util/lerp/LerpUtils.java index b24bbe6..1b88f5a 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/util/lerp/LerpUtils.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/util/lerp/LerpUtils.java @@ -11,10 +11,8 @@ public class LerpUtils { } private static final float sigmoidStr = 8; - private static final float sigmoidA = - -1 / (sigmoid(-0.5f * sigmoidStr) - sigmoid(0.5f * sigmoidStr)); - private static final float sigmoidB = - sigmoidA * sigmoid(-0.5f * sigmoidStr); + private static final float sigmoidA = -1 / (sigmoid(-0.5f * sigmoidStr) - sigmoid(0.5f * sigmoidStr)); + private static final float sigmoidB = sigmoidA * sigmoid(-0.5f * sigmoidStr); public static float sigmoidZeroOne(float f) { f = clampZeroOne(f); diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/util/lerp/LerpingFloat.java b/src/main/java/com/thatgravyboat/skyblockhud/core/util/lerp/LerpingFloat.java index 9e379c7..edf129b 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/util/lerp/LerpingFloat.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/util/lerp/LerpingFloat.java @@ -22,8 +22,7 @@ public class LerpingFloat { int lastTimeSpent = timeSpent; this.timeSpent += System.currentTimeMillis() - lastMillis; - float lastDistPercentToTarget = - lastTimeSpent / (float) timeToReachTarget; + float lastDistPercentToTarget = lastTimeSpent / (float) timeToReachTarget; float distPercentToTarget = timeSpent / (float) timeToReachTarget; float fac = (1 - lastDistPercentToTarget) / lastDistPercentToTarget; diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/util/lerp/LerpingInteger.java b/src/main/java/com/thatgravyboat/skyblockhud/core/util/lerp/LerpingInteger.java index 63e7143..0bae869 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/util/lerp/LerpingInteger.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/util/lerp/LerpingInteger.java @@ -22,8 +22,7 @@ public class LerpingInteger { int lastTimeSpent = timeSpent; this.timeSpent += System.currentTimeMillis() - lastMillis; - float lastDistPercentToTarget = - lastTimeSpent / (float) timeToReachTarget; + float lastDistPercentToTarget = lastTimeSpent / (float) timeToReachTarget; float distPercentToTarget = timeSpent / (float) timeToReachTarget; float fac = (1 - lastDistPercentToTarget) / lastDistPercentToTarget; diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/util/render/RenderUtils.java b/src/main/java/com/thatgravyboat/skyblockhud/core/util/render/RenderUtils.java index 242166b..518b928 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/util/render/RenderUtils.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/util/render/RenderUtils.java @@ -14,28 +14,15 @@ import org.lwjgl.opengl.GL14; public class RenderUtils { - public static void drawFloatingRectDark( - int x, - int y, - int width, - int height - ) { + public static void drawFloatingRectDark(int x, int y, int width, int height) { drawFloatingRectDark(x, y, width, height, true); } - public static void drawFloatingRectDark( - int x, - int y, - int width, - int height, - boolean shadow - ) { + public static void drawFloatingRectDark(int x, int y, int width, int height, boolean shadow) { int alpha = 0xf0000000; if (OpenGlHelper.isFramebufferEnabled()) { - ScaledResolution scaledResolution = new ScaledResolution( - Minecraft.getMinecraft() - ); + ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); BackgroundBlur.renderBlurredBackground( 15, scaledResolution.getScaledWidth(), @@ -59,20 +46,8 @@ public class RenderUtils { Gui.drawRect(x + 1, y + height - 1, x + width - 1, y + height, dark); //Bottom Gui.drawRect(x + 1, y + 1, x + width - 1, y + height - 1, main); //Middle if (shadow) { - Gui.drawRect( - x + width, - y + 2, - x + width + 2, - y + height + 2, - 0x70000000 - ); //Right shadow - Gui.drawRect( - x + 2, - y + height, - x + width, - y + height + 2, - 0x70000000 - ); //Bottom shadow + Gui.drawRect(x + width, y + 2, x + width + 2, y + height + 2, 0x70000000); //Right shadow + Gui.drawRect(x + 2, y + height, x + width, y + height + 2, 0x70000000); //Bottom shadow } } @@ -80,14 +55,7 @@ public class RenderUtils { drawFloatingRectWithAlpha(x, y, width, height, 0xFF, true); } - public static void drawFloatingRectWithAlpha( - int x, - int y, - int width, - int height, - int alpha, - boolean shadow - ) { + public static void drawFloatingRectWithAlpha(int x, int y, int width, int height, int alpha, boolean shadow) { int main = (alpha << 24) | 0xc0c0c0; int light = (alpha << 24) | 0xf0f0f0; int dark = (alpha << 24) | 0x909090; @@ -97,71 +65,29 @@ public class RenderUtils { Gui.drawRect(x + 1, y + height - 1, x + width - 1, y + height, dark); //Bottom Gui.drawRect(x + 1, y + 1, x + width - 1, y + height - 1, main); //Middle if (shadow) { - Gui.drawRect( - x + width, - y + 2, - x + width + 2, - y + height + 2, - (alpha * 3 / 5) << 24 - ); //Right shadow - Gui.drawRect( - x + 2, - y + height, - x + width, - y + height + 2, - (alpha * 3 / 5) << 24 - ); //Bottom shadow + Gui.drawRect(x + width, y + 2, x + width + 2, y + height + 2, (alpha * 3 / 5) << 24); //Right shadow + Gui.drawRect(x + 2, y + height, x + width, y + height + 2, (alpha * 3 / 5) << 24); //Bottom shadow } } - public static void drawTexturedModalRect( - int x, - int y, - int textureX, - int textureY, - int width, - int height - ) { + public static void drawTexturedModalRect(int x, int y, int textureX, int textureY, int width, int height) { double f = 0.00390625; double f1 = 0.00390625; Tessellator tessellator = Tessellator.getInstance(); WorldRenderer worldrenderer = tessellator.getWorldRenderer(); worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX); - worldrenderer - .pos(x + 0.0, y + height, 0.0) - .tex((textureX + 0.0) * f, (textureY + height) * f1) - .endVertex(); - worldrenderer - .pos(x + width, y + height, 0.0) - .tex((textureX + width) * f, (textureY + height) * f1) - .endVertex(); - worldrenderer - .pos(x + width, y + 0.0, 0.0) - .tex((textureX + width) * f, (textureY + 0.0) * f1) - .endVertex(); - worldrenderer - .pos(x + 0.0, y + 0.0, 0.0) - .tex((textureX + 0.0) * f, (textureY + 0.0) * f1) - .endVertex(); + worldrenderer.pos(x + 0.0, y + height, 0.0).tex((textureX + 0.0) * f, (textureY + height) * f1).endVertex(); + worldrenderer.pos(x + width, y + height, 0.0).tex((textureX + width) * f, (textureY + height) * f1).endVertex(); + worldrenderer.pos(x + width, y + 0.0, 0.0).tex((textureX + width) * f, (textureY + 0.0) * f1).endVertex(); + worldrenderer.pos(x + 0.0, y + 0.0, 0.0).tex((textureX + 0.0) * f, (textureY + 0.0) * f1).endVertex(); tessellator.draw(); } - public static void drawTexturedRect( - float x, - float y, - float width, - float height - ) { + public static void drawTexturedRect(float x, float y, float width, float height) { drawTexturedRect(x, y, width, height, 0, 1, 0, 1); } - public static void drawTexturedRect( - float x, - float y, - float width, - float height, - int filter - ) { + public static void drawTexturedRect(float x, float y, float width, float height, int filter) { drawTexturedRect(x, y, width, height, 0, 1, 0, 1, filter); } @@ -175,17 +101,7 @@ public class RenderUtils { float vMin, float vMax ) { - drawTexturedRect( - x, - y, - width, - height, - uMin, - uMax, - vMin, - vMax, - GL11.GL_NEAREST - ); + drawTexturedRect(x, y, width, height, uMin, uMax, vMin, vMax, GL11.GL_NEAREST); } public static void drawTexturedRect( @@ -207,17 +123,7 @@ public class RenderUtils { GL11.GL_ONE_MINUS_SRC_ALPHA ); - drawTexturedRectNoBlend( - x, - y, - width, - height, - uMin, - uMax, - vMin, - vMax, - filter - ); + drawTexturedRectNoBlend(x, y, width, height, uMin, uMax, vMin, vMax, filter); GlStateManager.disableBlend(); } @@ -235,39 +141,20 @@ public class RenderUtils { ) { GlStateManager.enableTexture2D(); - GL11.glTexParameteri( - GL11.GL_TEXTURE_2D, - GL11.GL_TEXTURE_MIN_FILTER, - filter - ); - GL11.glTexParameteri( - GL11.GL_TEXTURE_2D, - GL11.GL_TEXTURE_MAG_FILTER, - filter - ); + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, filter); + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, filter); Tessellator tessellator = Tessellator.getInstance(); WorldRenderer worldrenderer = tessellator.getWorldRenderer(); worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX); worldrenderer.pos(x, y + height, 0.0D).tex(uMin, vMax).endVertex(); - worldrenderer - .pos(x + width, y + height, 0.0D) - .tex(uMax, vMax) - .endVertex(); + worldrenderer.pos(x + width, y + height, 0.0D).tex(uMax, vMax).endVertex(); worldrenderer.pos(x + width, y, 0.0D).tex(uMax, vMin).endVertex(); worldrenderer.pos(x, y, 0.0D).tex(uMin, vMin).endVertex(); tessellator.draw(); - GL11.glTexParameteri( - GL11.GL_TEXTURE_2D, - GL11.GL_TEXTURE_MIN_FILTER, - GL11.GL_NEAREST - ); - GL11.glTexParameteri( - GL11.GL_TEXTURE_2D, - GL11.GL_TEXTURE_MAG_FILTER, - GL11.GL_NEAREST - ); + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST); + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST); } public static void drawGradientRect( @@ -297,22 +184,10 @@ public class RenderUtils { Tessellator tessellator = Tessellator.getInstance(); WorldRenderer worldrenderer = tessellator.getWorldRenderer(); worldrenderer.begin(7, DefaultVertexFormats.POSITION_COLOR); - worldrenderer - .pos(right, top, zLevel) - .color(startRed, startGreen, startBlue, startAlpha) - .endVertex(); - worldrenderer - .pos(left, top, zLevel) - .color(startRed, startGreen, startBlue, startAlpha) - .endVertex(); - worldrenderer - .pos(left, bottom, zLevel) - .color(endRed, endGreen, endBlue, endAlpha) - .endVertex(); - worldrenderer - .pos(right, bottom, zLevel) - .color(endRed, endGreen, endBlue, endAlpha) - .endVertex(); + worldrenderer.pos(right, top, zLevel).color(startRed, startGreen, startBlue, startAlpha).endVertex(); + worldrenderer.pos(left, top, zLevel).color(startRed, startGreen, startBlue, startAlpha).endVertex(); + worldrenderer.pos(left, bottom, zLevel).color(endRed, endGreen, endBlue, endAlpha).endVertex(); + worldrenderer.pos(right, bottom, zLevel).color(endRed, endGreen, endBlue, endAlpha).endVertex(); tessellator.draw(); GlStateManager.shadeModel(7424); @@ -325,19 +200,7 @@ public class RenderUtils { Gui.drawRect(left, top, left + width, top + height, 0x6008080E); //Middle Gui.drawRect(left, top, left + 1, top + height, 0xff08080E); //Left Gui.drawRect(left, top, left + width, top + 1, 0xff08080E); //Top - Gui.drawRect( - left + width - 1, - top, - left + width, - top + height, - 0xff28282E - ); //Right - Gui.drawRect( - left, - top + height - 1, - left + width, - top + height, - 0xff28282E - ); //Bottom + Gui.drawRect(left + width - 1, top, left + width, top + height, 0xff28282E); //Right + Gui.drawRect(left, top + height - 1, left + width, top + height, 0xff28282E); //Bottom } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/util/render/TextRenderUtils.java b/src/main/java/com/thatgravyboat/skyblockhud/core/util/render/TextRenderUtils.java index 4284012..478414e 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/util/render/TextRenderUtils.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/util/render/TextRenderUtils.java @@ -32,14 +32,7 @@ public class TextRenderUtils { return height; } - public static void drawStringVertical( - String str, - FontRenderer fr, - float x, - float y, - boolean shadow, - int colour - ) { + public static void drawStringVertical(String str, FontRenderer fr, float x, float y, boolean shadow, int colour) { String format = FontRenderer.getFormatFromString(str); str = StringUtils.cleanColour(str); for (int i = 0; i < str.length(); i++) { @@ -47,13 +40,7 @@ public class TextRenderUtils { int charHeight = getCharVertLen(c); int charWidth = fr.getCharWidth(c); - fr.drawString( - format + c, - x + (5 - charWidth) / 2f, - y - 7 + charHeight, - colour, - shadow - ); + fr.drawString(format + c, x + (5 - charWidth) / 2f, y - 7 + charHeight, colour, shadow); y += charHeight + 1.5f; } @@ -75,14 +62,7 @@ public class TextRenderUtils { drawStringScaled(str, fr, x, y, shadow, colour, factor); } - public static void drawStringCentered( - String str, - FontRenderer fr, - float x, - float y, - boolean shadow, - int colour - ) { + public static void drawStringCentered(String str, FontRenderer fr, float x, float y, boolean shadow, int colour) { int strLen = fr.getStringWidth(str); float x2 = x - strLen / 2f; @@ -123,15 +103,7 @@ public class TextRenderUtils { float fontHeight = 8 * factor; - drawStringScaled( - str, - fr, - x - newLen / 2, - y - fontHeight / 2, - shadow, - colour, - factor - ); + drawStringScaled(str, fr, x - newLen / 2, y - fontHeight / 2, shadow, colour, factor); } public static void renderToolTip( @@ -156,15 +128,7 @@ public class TextRenderUtils { } FontRenderer font = stack.getItem().getFontRenderer(stack); - drawHoveringText( - list, - mouseX, - mouseY, - screenWidth, - screenHeight, - -1, - font == null ? fontStd : font - ); + drawHoveringText(list, mouseX, mouseY, screenWidth, screenHeight, -1, font == null ? fontStd : font); } public static void drawHoveringText( @@ -217,10 +181,7 @@ public class TextRenderUtils { List wrappedTextLines = new ArrayList(); for (int i = 0; i < textLines.size(); i++) { String textLine = textLines.get(i); - List wrappedLine = font.listFormattedStringToWidth( - textLine, - tooltipTextWidth - ); + List wrappedLine = font.listFormattedStringToWidth(textLine, tooltipTextWidth); if (i == 0) { titleLinesCount = wrappedLine.size(); } @@ -305,10 +266,7 @@ public class TextRenderUtils { backgroundColor ); final int borderColorStart = 0x505000FF; - final int borderColorEnd = - (borderColorStart & 0xFEFEFE) >> 1 | - borderColorStart & - 0xFF000000; + final int borderColorEnd = (borderColorStart & 0xFEFEFE) >> 1 | borderColorStart & 0xFF000000; RenderUtils.drawGradientRect( zLevel, tooltipX - 3, @@ -346,18 +304,9 @@ public class TextRenderUtils { borderColorEnd ); - for ( - int lineNumber = 0; - lineNumber < textLines.size(); - ++lineNumber - ) { + for (int lineNumber = 0; lineNumber < textLines.size(); ++lineNumber) { String line = textLines.get(lineNumber); - font.drawStringWithShadow( - line, - (float) tooltipX, - (float) tooltipY, - -1 - ); + font.drawStringWithShadow(line, (float) tooltipX, (float) tooltipY, -1); if (lineNumber + 1 == titleLinesCount) { tooltipY += 2; diff --git a/src/main/java/com/thatgravyboat/skyblockhud/dungeons/Classes.java b/src/main/java/com/thatgravyboat/skyblockhud/dungeons/Classes.java index f0f58da..b05fe91 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/dungeons/Classes.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/dungeons/Classes.java @@ -36,9 +36,7 @@ public enum Classes { } catch (IllegalArgumentException ignored) {} } else if (input.length() == 3) { try { - return Classes.valueOf( - input.replace("[", "").replace("]", "").toUpperCase() - ); + return Classes.valueOf(input.replace("[", "").replace("]", "").toUpperCase()); } catch (IllegalArgumentException ignored) {} } else { for (Classes clazz : Classes.values()) { diff --git a/src/main/java/com/thatgravyboat/skyblockhud/dungeons/DungeonHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/dungeons/DungeonHandler.java index 0c9cb2f..4fd0fd4 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/dungeons/DungeonHandler.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/dungeons/DungeonHandler.java @@ -24,23 +24,15 @@ public class DungeonHandler { private static int deaths = 0; private static int crypts = 0; - private static final Pattern DungeonPlayerRegex = Pattern.compile( - "^\\[([HMBAT])] ([\\w]+) ([0-9]+|DEAD)$" - ); + private static final Pattern DungeonPlayerRegex = Pattern.compile("^\\[([HMBAT])] ([\\w]+) ([0-9]+|DEAD)$"); @SubscribeEvent public void onSidebarLineUpdate(SidebarLineUpdateEvent event) { if (LocationHandler.getCurrentLocation().equals(Locations.CATACOMBS)) { DungeonHandler.checkForDungeonTime(event.formattedLine); DungeonHandler.checkForDungeonCleared(event.formattedLine); - DungeonHandler.checkForDungeonKeys( - event.formattedLine, - event.rawLine - ); - DungeonHandler.checkForDungeonPlayers( - event.formattedLine, - Minecraft.getMinecraft() - ); + DungeonHandler.checkForDungeonKeys(event.formattedLine, event.rawLine); + DungeonHandler.checkForDungeonPlayers(event.formattedLine, Minecraft.getMinecraft()); } } @@ -57,12 +49,7 @@ public class DungeonHandler { Classes playerClass = Classes.valueOf(dungeonMatcher.group(1)); String displayName = dungeonMatcher.group(2); String health = dungeonMatcher.group(3); - if ( - !mc.thePlayer - .getName() - .toLowerCase() - .startsWith(displayName.toLowerCase().trim()) - ) { + if (!mc.thePlayer.getName().toLowerCase().startsWith(displayName.toLowerCase().trim())) { int healthNum = 0; if (!health.equalsIgnoreCase("dead")) { try { @@ -82,22 +69,12 @@ public class DungeonHandler { public static void checkForDungeonTime(String scoreLine) { if (scoreLine.toLowerCase().trim().contains("time elapsed:")) { - String timeLine = scoreLine - .toLowerCase() - .trim() - .replace("time elapsed:", ""); + String timeLine = scoreLine.toLowerCase().trim().replace("time elapsed:", ""); String[] times = timeLine.split("m "); int time = 0; try { - time += - Integer.parseInt( - times[0].replace(" ", "").replace("m", "") - ) * - 60; - time += - Integer.parseInt( - times[1].replace(" ", "").replace("s", "") - ); + time += Integer.parseInt(times[0].replace(" ", "").replace("m", "")) * 60; + time += Integer.parseInt(times[1].replace(" ", "").replace("s", "")); } catch (NumberFormatException ignored) {} dungeonTime = time; } @@ -136,15 +113,10 @@ public class DungeonHandler { boolean hasSecrets = false; String[] parts = statusBar.split(" {4,}"); for (String part : parts) { - if ( - part.toLowerCase().contains("secrets") && - !statusBar.toLowerCase().contains("no secrets") - ) { + if (part.toLowerCase().contains("secrets") && !statusBar.toLowerCase().contains("no secrets")) { hasSecrets = true; try { - String secret = Utils - .removeColor(part.replace("Secrets", "")) - .replace(" ", ""); + String secret = Utils.removeColor(part.replace("Secrets", "")).replace(" ", ""); maxSecrets = Integer.parseInt(secret.split("/")[1]); secrets = Integer.parseInt(secret.split("/")[0]); } catch (NumberFormatException ignored) {} @@ -159,9 +131,7 @@ public class DungeonHandler { public static void parseTotalSecrets(String playerName) { if (playerName.toLowerCase().contains("secrets found:")) { String totalSecret = Utils - .removeColor( - playerName.toLowerCase().replace("secrets found:", "") - ) + .removeColor(playerName.toLowerCase().replace("secrets found:", "")) .replace(" ", ""); try { totalSecrets = Integer.parseInt(totalSecret); @@ -184,9 +154,7 @@ public class DungeonHandler { public static void parseCrypts(String playerName) { if (playerName.toLowerCase().contains("crypts:")) { - String crypt = Utils - .removeColor(playerName.toLowerCase().replace("crypts:", "")) - .replace(" ", ""); + String crypt = Utils.removeColor(playerName.toLowerCase().replace("crypts:", "")).replace(" ", ""); try { crypts = Integer.parseInt(crypt); } catch (NumberFormatException ignored) {} diff --git a/src/main/java/com/thatgravyboat/skyblockhud/dungeons/DungeonPlayer.java b/src/main/java/com/thatgravyboat/skyblockhud/dungeons/DungeonPlayer.java index f517655..b0816fb 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/dungeons/DungeonPlayer.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/dungeons/DungeonPlayer.java @@ -7,12 +7,7 @@ public class DungeonPlayer { private final int health; private final boolean dead; - public DungeonPlayer( - Classes playersClass, - String playersName, - int playersHealth, - boolean isDead - ) { + public DungeonPlayer(Classes playersClass, String playersName, int playersHealth, boolean isDead) { this.dungeonClass = playersClass; this.name = playersName; this.health = isDead ? 0 : playersHealth; diff --git a/src/main/java/com/thatgravyboat/skyblockhud/handlers/BossbarHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/handlers/BossbarHandler.java index 0338195..6f06f40 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/handlers/BossbarHandler.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/handlers/BossbarHandler.java @@ -16,10 +16,7 @@ public class BossbarHandler { @SubscribeEvent(priority = EventPriority.LOWEST) public void onBossbarRender(RenderGameOverlayEvent.Pre event) { - if ( - event.type == RenderGameOverlayEvent.ElementType.BOSSHEALTH && - BossStatus.bossName != null - ) { + if (event.type == RenderGameOverlayEvent.ElementType.BOSSHEALTH && BossStatus.bossName != null) { bossBarRendered = !event.isCanceled(); if (!SkyblockHud.config.main.bossShiftHud) { bossBarRendered = false; @@ -27,11 +24,8 @@ public class BossbarHandler { String bossName = Utils.removeColor(BossStatus.bossName); if ( SkyblockHud.config.renderer.hideBossBar && - DwarvenMineHandler.currentEvent == - DwarvenMineHandler.Event.NONE && - !LocationHandler - .getCurrentLocation() - .equals(Locations.CATACOMBS) + DwarvenMineHandler.currentEvent == DwarvenMineHandler.Event.NONE && + !LocationHandler.getCurrentLocation().equals(Locations.CATACOMBS) ) { if (bossName.equalsIgnoreCase("wither")) { event.setCanceled(true); diff --git a/src/main/java/com/thatgravyboat/skyblockhud/handlers/CurrencyHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/handlers/CurrencyHandler.java index ea0ccca..847b6c7 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/handlers/CurrencyHandler.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/handlers/CurrencyHandler.java @@ -35,19 +35,13 @@ public class CurrencyHandler { @SubscribeEvent public void onSidebarLineUpdate(SidebarLineUpdateEvent event) { if ( - Utils - .removeColor(event.formattedLine.toLowerCase().trim()) - .contains("purse:") || - Utils - .removeColor(event.formattedLine.toLowerCase().trim()) - .contains("piggy:") + Utils.removeColor(event.formattedLine.toLowerCase().trim()).contains("purse:") || + Utils.removeColor(event.formattedLine.toLowerCase().trim()).contains("piggy:") ) { CurrencyHandler.checkCoins(event.formattedLine); } if ( - Utils - .removeColor(event.formattedLine.toLowerCase().trim()) - .contains("bits:") && + Utils.removeColor(event.formattedLine.toLowerCase().trim()).contains("bits:") && !event.formattedLine.toLowerCase().contains("(") ) { CurrencyHandler.checkBits(event.formattedLine); @@ -56,81 +50,50 @@ public class CurrencyHandler { @SubscribeEvent public void onSidebarPost(SidebarPostEvent event) { - if ( - !Arrays.toString(event.arrayScores).toLowerCase().contains("bits:") - ) { + if (!Arrays.toString(event.arrayScores).toLowerCase().contains("bits:")) { CurrencyHandler.setBits(0); } } public static String getCoinsFormatted() { - DecimalFormat formatter = new DecimalFormat( - "#,###.0", - DecimalFormatSymbols.getInstance(Locale.CANADA) - ); + DecimalFormat formatter = new DecimalFormat("#,###.0", DecimalFormatSymbols.getInstance(Locale.CANADA)); String output = formatter.format(coins); - if (output.equals(".0")) output = "0.0"; else if ( - output.equals(",0") - ) output = "0,0"; + if (output.equals(".0")) output = "0.0"; else if (output.equals(",0")) output = "0,0"; return output; } public static String getBitsFormatted() { - DecimalFormat formatter = new DecimalFormat( - "#.#", - DecimalFormatSymbols.getInstance(Locale.CANADA) - ); + DecimalFormat formatter = new DecimalFormat("#.#", DecimalFormatSymbols.getInstance(Locale.CANADA)); formatter.setRoundingMode(RoundingMode.FLOOR); - return bits > 999 - ? formatter.format((double) bits / 1000) + "k" - : String.valueOf(bits); + return bits > 999 ? formatter.format((double) bits / 1000) + "k" : String.valueOf(bits); } public static void checkCoins(String formatedScoreboardLine) { String purse = Utils .removeWhiteSpaceAndRemoveWord( Utils.removeColor(formatedScoreboardLine.toLowerCase().trim()), - Utils - .removeColor( - formatedScoreboardLine.toLowerCase().trim() - ) - .contains("purse:") - ? "purse:" - : "piggy:" + Utils.removeColor(formatedScoreboardLine.toLowerCase().trim()).contains("purse:") ? "purse:" : "piggy:" ) .replace(",", ""); if (!purse.contains("(") && !purse.contains("+")) { try { - double coins = Double.parseDouble( - Pattern.compile("[^0-9.]").matcher(purse).replaceAll("") - ); + double coins = Double.parseDouble(Pattern.compile("[^0-9.]").matcher(purse).replaceAll("")); CurrencyHandler.setCoins(coins); } catch (IllegalArgumentException ex) { - System.out.println( - "Failed to parse purse, please report to ThatGravyBoat. Purse Text: " + - purse - ); + System.out.println("Failed to parse purse, please report to ThatGravyBoat. Purse Text: " + purse); } } } public static void checkBits(String formatedScoreboardLine) { String bits = Utils - .removeWhiteSpaceAndRemoveWord( - Utils.removeColor(formatedScoreboardLine.toLowerCase().trim()), - "bits:" - ) + .removeWhiteSpaceAndRemoveWord(Utils.removeColor(formatedScoreboardLine.toLowerCase().trim()), "bits:") .replace(",", ""); try { - int bit = Integer.parseInt( - Pattern.compile("[^0-9]").matcher(bits).replaceAll("") - ); + int bit = Integer.parseInt(Pattern.compile("[^0-9]").matcher(bits).replaceAll("")); CurrencyHandler.setBits(bit); } catch (IllegalArgumentException ex) { - System.out.println( - "Failed to parse bits, please report to ThatGravyBoat. Bits Text: " + - bits - ); + System.out.println("Failed to parse bits, please report to ThatGravyBoat. Bits Text: " + bits); } } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/handlers/HeldItemHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/handlers/HeldItemHandler.java index e7686d2..fa0d21c 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/handlers/HeldItemHandler.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/handlers/HeldItemHandler.java @@ -13,21 +13,10 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; public class HeldItemHandler extends Gui { public void drawFuelBar(Minecraft mc, int current, int max) { - GenericOverlays.drawSmallBar( - mc, - 100, - 100, - (double) current / (double) max, - 1.0d, - 0xff00ff, - 0xffff00, - 0 - ); + GenericOverlays.drawSmallBar(mc, 100, 100, (double) current / (double) max, 1.0d, 0xff00ff, 0xffff00, 0); drawString( mc.fontRendererObj, - "Fuel - " + - Math.round(((double) current / (double) max) * 100) + - "%", + "Fuel - " + Math.round(((double) current / (double) max) * 100) + "%", 100, 100, 0xffffff @@ -37,16 +26,11 @@ public class HeldItemHandler extends Gui { public boolean isDrill(ItemStack stack) { if (stack == null) return false; if (!stack.getTagCompound().hasKey("ExtraAttributes")) return false; - return stack - .getTagCompound() - .getCompoundTag("ExtraAttributes") - .hasKey("drill_fuel"); + return stack.getTagCompound().getCompoundTag("ExtraAttributes").hasKey("drill_fuel"); } public String getDrillFuel(ItemStack stack) { - NBTTagCompound display = stack - .getTagCompound() - .getCompoundTag("display"); + NBTTagCompound display = stack.getTagCompound().getCompoundTag("display"); NBTTagList lore = display.getTagList("Lore", 8); for (int i = lore.tagCount() - 1; i >= 0; i--) { String line = Utils.removeColor(lore.getStringTagAt(i)); diff --git a/src/main/java/com/thatgravyboat/skyblockhud/handlers/MapHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/handlers/MapHandler.java index ab618af..5bc90d8 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/handlers/MapHandler.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/handlers/MapHandler.java @@ -44,22 +44,11 @@ public class MapHandler { public String command; public MapIconTypes type; - public MapIcon( - Vector2f pos, - ResourceLocation icon, - String tooltip, - MapIconTypes type - ) { + public MapIcon(Vector2f pos, ResourceLocation icon, String tooltip, MapIconTypes type) { this(pos, icon, tooltip, type, ""); } - public MapIcon( - Vector2f pos, - ResourceLocation icon, - String tooltip, - MapIconTypes type, - String command - ) { + public MapIcon(Vector2f pos, ResourceLocation icon, String tooltip, MapIconTypes type, String command) { this.position = pos; this.icon = icon; this.tooltip = tooltip; @@ -69,32 +58,16 @@ public class MapHandler { public boolean canRender() { SBHConfig.Map mapConfig = SkyblockHud.config.map; - if ( - mapConfig.showInfoIcons && type.equals(MapIconTypes.INFO) - ) return true; else if ( + if (mapConfig.showInfoIcons && type.equals(MapIconTypes.INFO)) return true; else if ( mapConfig.showMiscIcons && type.equals(MapIconTypes.MISC) - ) return true; else if ( - mapConfig.showNpcIcons && type.equals(MapIconTypes.NPC) - ) return true; else if ( + ) return true; else if (mapConfig.showNpcIcons && type.equals(MapIconTypes.NPC)) return true; else if ( mapConfig.showQuestIcons && type.equals(MapIconTypes.QUEST) - ) return true; else return ( - mapConfig.showShopIcons && type.equals(MapIconTypes.SHOPS) - ); + ) return true; else return (mapConfig.showShopIcons && type.equals(MapIconTypes.SHOPS)); } } public enum Maps { - HUB( - 0.5f, - 494, - 444, - 294, - 218, - 294, - 224, - new ResourceLocation("skyblockhud", "maps/hub.png"), - HubIcons.hubIcons - ), + HUB(0.5f, 494, 444, 294, 218, 294, 224, new ResourceLocation("skyblockhud", "maps/hub.png"), HubIcons.hubIcons), MUSHROOM( 1.0f, 318, @@ -206,15 +179,9 @@ public class MapHandler { ) { Minecraft mc = Minecraft.getMinecraft(); if (mc.currentScreen instanceof MapScreen) return; - if ( - LocationHandler.getCurrentLocation().getCategory().getMap() == - null - ) return; + if (LocationHandler.getCurrentLocation().getCategory().getMap() == null) return; if (mc.thePlayer != null) { - MapHandler.Maps map = LocationHandler - .getCurrentLocation() - .getCategory() - .getMap(); + MapHandler.Maps map = LocationHandler.getCurrentLocation().getCategory().getMap(); mc.renderEngine.bindTexture(mapOverlay); GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f); Position pos = SkyblockHud.config.map.miniMapPosition; @@ -235,16 +202,8 @@ public class MapHandler { float u = (x / (map.width / 256f)) - 33f; float v = (z / (map.height / 256f)) - 28f; - GL11.glTexParameteri( - GL11.GL_TEXTURE_2D, - GL11.GL_TEXTURE_WRAP_S, - GL11.GL_CLAMP - ); - GL11.glTexParameteri( - GL11.GL_TEXTURE_2D, - GL11.GL_TEXTURE_WRAP_T, - GL11.GL_CLAMP - ); + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_CLAMP); + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_CLAMP); Gui.drawModalRectWithCustomSizedTexture( pos.getAbsX(event.resolution, 72) + 4, @@ -279,9 +238,7 @@ public class MapHandler { 256, 256 ); - String keyCode = GameSettings.getKeyDisplayString( - KeyBindings.map.getKeyCode() - ); + String keyCode = GameSettings.getKeyDisplayString(KeyBindings.map.getKeyCode()); Utils.drawStringCenteredScaled( keyCode, mc.fontRendererObj, @@ -292,12 +249,7 @@ public class MapHandler { 0xFFFFFF ); BlockPos playerPos = mc.thePlayer.getPosition(); - String position = String.format( - "%d/%d/%d", - playerPos.getX(), - playerPos.getY(), - playerPos.getZ() - ); + String position = String.format("%d/%d/%d", playerPos.getX(), playerPos.getY(), playerPos.getZ()); Utils.drawStringCenteredScaled( position, mc.fontRendererObj, @@ -316,18 +268,14 @@ public class MapHandler { public void clientTick(TickEvent.ClientTickEvent event) { if ( KeyBindings.map.isPressed() && - LocationHandler.getCurrentLocation().getCategory().getMap() != - null && + LocationHandler.getCurrentLocation().getCategory().getMap() != null && SkyblockHud.hasSkyblockScoreboard() ) SkyblockHud.screenToOpen = new MapScreen(); } public static class MapScreen extends GuiScreen { - public MapHandler.Maps map = LocationHandler - .getCurrentLocation() - .getCategory() - .getMap(); + public MapHandler.Maps map = LocationHandler.getCurrentLocation().getCategory().getMap(); @Override public void drawScreen(int mouseX, int mouseY, float partialTicks) { @@ -347,10 +295,7 @@ public class MapHandler { (int) (map.height * map.scaleFactor) ); drawIcons((int) mapX, (int) mapY); - if ( - this.mc.thePlayer != null && - SkyblockHud.config.map.showPlayerLocation - ) { + if (this.mc.thePlayer != null && SkyblockHud.config.map.showPlayerLocation) { int x = this.mc.thePlayer.getPosition().getX() + map.xOffset; int z = this.mc.thePlayer.getPosition().getZ() + map.yOffset; fontRendererObj.drawString( @@ -371,24 +316,9 @@ public class MapHandler { GlStateManager.enableBlend(); GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f); this.mc.renderEngine.bindTexture(icon.icon); - float x = - ((icon.position.x + map.xOffset) * map.scaleFactor) + - startX - - 4; - float y = - ((icon.position.y + map.yOffset) * map.scaleFactor) + - startY - - 4; - Gui.drawModalRectWithCustomSizedTexture( - (int) x, - (int) y, - 0, - 0, - 8, - 8, - 8, - 8 - ); + float x = ((icon.position.x + map.xOffset) * map.scaleFactor) + startX - 4; + float y = ((icon.position.y + map.yOffset) * map.scaleFactor) + startY - 4; + Gui.drawModalRectWithCustomSizedTexture((int) x, (int) y, 0, 0, 8, 8, 8, 8); GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f); } } @@ -400,36 +330,16 @@ public class MapHandler { if ( Utils.inRangeInclusive( mouseX, - (int) ( - (icon.position.x + map.xOffset) * map.scaleFactor - ) + - startX - - 4, - (int) ( - (icon.position.x + map.xOffset) * map.scaleFactor - ) + - startX + - 4 + (int) ((icon.position.x + map.xOffset) * map.scaleFactor) + startX - 4, + (int) ((icon.position.x + map.xOffset) * map.scaleFactor) + startX + 4 ) && Utils.inRangeInclusive( mouseY, - (int) ( - (icon.position.y + map.yOffset) * map.scaleFactor - ) + - startY - - 4, - (int) ( - (icon.position.y + map.yOffset) * map.scaleFactor - ) + - startY + - 4 + (int) ((icon.position.y + map.yOffset) * map.scaleFactor) + startY - 4, + (int) ((icon.position.y + map.yOffset) * map.scaleFactor) + startY + 4 ) ) { - drawHoveringText( - Arrays.asList(icon.tooltip.split("\n")), - mouseX, - mouseY - ); + drawHoveringText(Arrays.asList(icon.tooltip.split("\n")), mouseX, mouseY); break; } } @@ -437,40 +347,20 @@ public class MapHandler { @Override protected void mouseClicked(int mouseX, int mouseY, int mouseButton) { - int mapX = (int) ( - (width / 2f) - ((map.width / 2f) * map.scaleFactor) - ); - int mapY = (int) ( - (height / 2f) - ((map.height / 2f) * map.scaleFactor) - ); + int mapX = (int) ((width / 2f) - ((map.width / 2f) * map.scaleFactor)); + int mapY = (int) ((height / 2f) - ((map.height / 2f) * map.scaleFactor)); for (MapIcon icon : map.icons) { if (!icon.canRender()) continue; if ( Utils.inRangeInclusive( mouseX, - (int) ( - (icon.position.x + map.xOffset) * map.scaleFactor - ) + - mapX - - 4, - (int) ( - (icon.position.x + map.xOffset) * map.scaleFactor - ) + - mapX + - 4 + (int) ((icon.position.x + map.xOffset) * map.scaleFactor) + mapX - 4, + (int) ((icon.position.x + map.xOffset) * map.scaleFactor) + mapX + 4 ) && Utils.inRangeInclusive( mouseY, - (int) ( - (icon.position.y + map.yOffset) * map.scaleFactor - ) + - mapY - - 4, - (int) ( - (icon.position.y + map.yOffset) * map.scaleFactor - ) + - mapY + - 4 + (int) ((icon.position.y + map.yOffset) * map.scaleFactor) + mapY - 4, + (int) ((icon.position.y + map.yOffset) * map.scaleFactor) + mapY + 4 ) ) { if (!icon.command.isEmpty()) { diff --git a/src/main/java/com/thatgravyboat/skyblockhud/handlers/SlayerHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/handlers/SlayerHandler.java index 6b2c808..627be26 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/handlers/SlayerHandler.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/handlers/SlayerHandler.java @@ -12,12 +12,8 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; public class SlayerHandler { //Optional Characters are required because Hypixel dumb and cuts off text - private static final Pattern COMBAT_XP_REGEX = Pattern.compile( - "\\(([\\d,]+)/([\\dkm]+)\\) comb?a?t? x?p?" - ); - private static final Pattern KILLS_REGEX = Pattern.compile( - "(\\d+)/(\\d+) kills?" - ); + private static final Pattern COMBAT_XP_REGEX = Pattern.compile("\\(([\\d,]+)/([\\dkm]+)\\) comb?a?t? x?p?"); + private static final Pattern KILLS_REGEX = Pattern.compile("(\\d+)/(\\d+) kills?"); public enum slayerTypes { ZOMBIE(34, "Revenant Horror"), @@ -63,32 +59,23 @@ public class SlayerHandler { @SubscribeEvent public void onSidebarPost(SidebarPostEvent event) { String arrayString = Arrays.toString(event.arrayScores); - isDoingSlayer = - Arrays.toString(event.arrayScores).contains("Slayer Quest"); + isDoingSlayer = Arrays.toString(event.arrayScores).contains("Slayer Quest"); if ( isDoingSlayer && ( currentSlayer.equals(slayerTypes.NONE) || !arrayString .replace(" ", "") - .contains( - currentSlayer.getDisplayName().replace(" ", "") + - Utils.intToRomanNumeral(slayerTier) - ) + .contains(currentSlayer.getDisplayName().replace(" ", "") + Utils.intToRomanNumeral(slayerTier)) ) ) { for (int i = 0; i < event.scores.size(); i++) { String line = event.scores.get(i); if (line.contains("Slayer Quest") && event.scores.size() > 3) { String slayer = event.scores.get(i - 1).toLowerCase(); - SlayerHandler.slayerTypes selectedSlayer = - SlayerHandler.slayerTypes.NONE; + SlayerHandler.slayerTypes selectedSlayer = SlayerHandler.slayerTypes.NONE; for (slayerTypes types : slayerTypes.values()) { - if ( - slayer.contains( - types.displayName.toLowerCase(Locale.ENGLISH) - ) - ) { + if (slayer.contains(types.displayName.toLowerCase(Locale.ENGLISH))) { selectedSlayer = types; break; } @@ -96,14 +83,7 @@ public class SlayerHandler { SlayerHandler.currentSlayer = selectedSlayer; SlayerHandler.slayerTier = Utils.whatRomanNumeral( - slayer - .replace( - selectedSlayer - .getDisplayName() - .toLowerCase(), - "" - ) - .replace(" ", "") + slayer.replace(selectedSlayer.getDisplayName().toLowerCase(), "").replace(" ", "") ); break; } @@ -117,9 +97,7 @@ public class SlayerHandler { @SubscribeEvent public void onSidebarLineUpdate(SidebarLineUpdateEvent event) { - if ( - !isDoingSlayer && event.formattedLine.equals("Slayer Quest") - ) isDoingSlayer = true; + if (!isDoingSlayer && event.formattedLine.equals("Slayer Quest")) isDoingSlayer = true; if (isDoingSlayer) { String line = event.formattedLine.toLowerCase(); @@ -144,11 +122,7 @@ public class SlayerHandler { try { maxKills = Integer.parseInt(xpMatcher.group(2).replace("k", "")) * - ( - xpMatcher.group(2).contains("k") - ? 1000 - : xpMatcher.group(2).contains("m") ? 1000000 : 1 - ); + (xpMatcher.group(2).contains("k") ? 1000 : xpMatcher.group(2).contains("m") ? 1000000 : 1); } catch (Exception ignored) {} } else if (line.contains("slay the boss")) { SlayerHandler.bossSlain = false; diff --git a/src/main/java/com/thatgravyboat/skyblockhud/handlers/TimeHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/handlers/TimeHandler.java index 1fc3d3f..91b3835 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/handlers/TimeHandler.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/handlers/TimeHandler.java @@ -14,34 +14,17 @@ public class TimeHandler { @SubscribeEvent public void onSidebarLineUpdate(SidebarLineUpdateEvent event) { - if ( - Pattern.matches( - "([0-9]*):([0-9]*)(pm|am)", - event.formattedLine.toLowerCase().trim() - ) - ) { - boolean isPm = event.formattedLine - .toLowerCase() - .trim() - .endsWith("pm"); - SimpleDateFormat parseFormat = new SimpleDateFormat( - "hh:mm a", - Locale.CANADA - ); + if (Pattern.matches("([0-9]*):([0-9]*)(pm|am)", event.formattedLine.toLowerCase().trim())) { + boolean isPm = event.formattedLine.toLowerCase().trim().endsWith("pm"); + SimpleDateFormat parseFormat = new SimpleDateFormat("hh:mm a", Locale.CANADA); String currentTimeString = event.formattedLine .replace(" ", "") .replace(isPm ? "pm" : "am", isPm ? " pm" : " am"); try { time = - ( - parseFormat.parse(currentTimeString).getTime() - - parseFormat.parse("00:00 am").getTime() - ) / - 1000L; + (parseFormat.parse(currentTimeString).getTime() - parseFormat.parse("00:00 am").getTime()) / 1000L; } catch (ParseException ignored) { - LogManager - .getLogger() - .warn("timeformat error: " + currentTimeString); + LogManager.getLogger().warn("timeformat error: " + currentTimeString); } } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/handlers/mapicons/DwarvenIcons.java b/src/main/java/com/thatgravyboat/skyblockhud/handlers/mapicons/DwarvenIcons.java index abfbd0e..3ef4179 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/handlers/mapicons/DwarvenIcons.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/handlers/mapicons/DwarvenIcons.java @@ -27,9 +27,7 @@ public class DwarvenIcons { new ComponentBuilder() .nl("Puzzler", new char[] { 'a', 'l' }) .nl("Description", 'l') - .nl( - "The Puzzler gives you a small puzzle each day to solve and" - ) + .nl("The Puzzler gives you a small puzzle each day to solve and") .nl("gives you 1000 mithril powder.") .build(), MapHandler.MapIconTypes.NPC @@ -47,12 +45,8 @@ public class DwarvenIcons { new ComponentBuilder() .nl("King", new char[] { 'a', 'l' }) .nl("Description", 'l') - .nl( - "The King allows you to first start commissions and if you click" - ) - .nl( - "each king which change every skyblock day you will get" - ) + .nl("The King allows you to first start commissions and if you click") + .nl("each king which change every skyblock day you will get") .nl("the King Talisman.") .nl() .apd("Click to open HOTM", new char[] { '6', 'l' }) @@ -67,10 +61,7 @@ public class DwarvenIcons { dwarvenIcons.add( new MapHandler.MapIcon( new Vector2f(4, 8), - new ResourceLocation( - "skyblockhud", - "maps/icons/blacksmith.png" - ), + new ResourceLocation("skyblockhud", "maps/icons/blacksmith.png"), new ComponentBuilder() .nl("Forge", new char[] { 'a', 'l' }) .nl("Description", 'l') @@ -78,9 +69,7 @@ public class DwarvenIcons { .nl("and fuel your drill.") .nl("NPCS", new char[] { 'c', 'l' }) .nl(" Forger - Allows you to forge special items") - .nl( - " Jotraeline Greatforge - Allows you to refuel your drill." - ) + .nl(" Jotraeline Greatforge - Allows you to refuel your drill.") .nl() .apd("Click to warp", new char[] { '6', 'l' }) .build(), diff --git a/src/main/java/com/thatgravyboat/skyblockhud/handlers/mapicons/HubIcons.java b/src/main/java/com/thatgravyboat/skyblockhud/handlers/mapicons/HubIcons.java index 2eafaec..4539f35 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/handlers/mapicons/HubIcons.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/handlers/mapicons/HubIcons.java @@ -78,9 +78,7 @@ public class HubIcons { .nl(" Bartender") .nl(" Maddox the slayer") .nl("Description", 'l') - .nl( - "The Tavern is where maddox the slayer is located you can" - ) + .nl("The Tavern is where maddox the slayer is located you can") .nl("start slayer quests with them to unlock") .apd("new items the more slayer bosses you kill.") .build(), @@ -110,10 +108,7 @@ public class HubIcons { hubIcons.add( new MapHandler.MapIcon( new Vector2f(58, -73), - new ResourceLocation( - "skyblockhud", - "maps/icons/fishing_merchant.png" - ), + new ResourceLocation("skyblockhud", "maps/icons/fishing_merchant.png"), new ComponentBuilder() .nl("Fishing Merchant", new char[] { 'a', 'l' }) .nl("Description", 'l') @@ -141,10 +136,7 @@ public class HubIcons { hubIcons.add( new MapHandler.MapIcon( new Vector2f(-4, -128), - new ResourceLocation( - "skyblockhud", - "maps/icons/metal_merchants.png" - ), + new ResourceLocation("skyblockhud", "maps/icons/metal_merchants.png"), new ComponentBuilder() .nl("Blacksmith Merchants", new char[] { 'a', 'l' }) .nl("Merchants", new char[] { 'c', 'l' }) @@ -158,10 +150,7 @@ public class HubIcons { hubIcons.add( new MapHandler.MapIcon( new Vector2f(-30, -120), - new ResourceLocation( - "skyblockhud", - "maps/icons/blacksmith.png" - ), + new ResourceLocation("skyblockhud", "maps/icons/blacksmith.png"), new ComponentBuilder() .nl("Blacksmith", new char[] { 'a', 'l' }) .nl("NPCS", new char[] { 'c', 'l' }) @@ -170,9 +159,7 @@ public class HubIcons { .nl(" Smithmonger") .nl("Description", 'l') .nl("The Blacksmith lets you reforge your items") - .nl( - "while the Smithmonger allows you to buy reforge stones" - ) + .nl("while the Smithmonger allows you to buy reforge stones") .apd("and Dusk allows you to combine and apply runes.") .build(), MapHandler.MapIconTypes.SHOPS @@ -253,9 +240,7 @@ public class HubIcons { new ComponentBuilder() .nl("Bank", new char[] { 'a', 'l' }) .nl("Description", 'l') - .nl( - "The Bank is where you can store your money on skyblock" - ) + .nl("The Bank is where you can store your money on skyblock") .apd("you can also store some items in the vault.") .build(), MapHandler.MapIconTypes.MISC diff --git a/src/main/java/com/thatgravyboat/skyblockhud/handlers/sbentities/EntityTypeHelper.java b/src/main/java/com/thatgravyboat/skyblockhud/handlers/sbentities/EntityTypeHelper.java index f5e7c2f..eda0b6f 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/handlers/sbentities/EntityTypeHelper.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/handlers/sbentities/EntityTypeHelper.java @@ -17,17 +17,9 @@ public class EntityTypeHelper { .getBaseValue(); if ( maxHealthBase == 13000d || - ( - maxHealthBase == 2000d && - enderman - .getHeldBlockState() - .getBlock() - .equals(Blocks.end_portal_frame) - ) + (maxHealthBase == 2000d && enderman.getHeldBlockState().getBlock().equals(Blocks.end_portal_frame)) ) { - return LocationHandler - .getCurrentLocation() - .equals(Locations.DRAGONSNEST); + return LocationHandler.getCurrentLocation().equals(Locations.DRAGONSNEST); } } return false; diff --git a/src/main/java/com/thatgravyboat/skyblockhud/handlers/sbentities/EntityTypeRegistry.java b/src/main/java/com/thatgravyboat/skyblockhud/handlers/sbentities/EntityTypeRegistry.java index a2b70ef..83c6a70 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/handlers/sbentities/EntityTypeRegistry.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/handlers/sbentities/EntityTypeRegistry.java @@ -12,19 +12,14 @@ public class EntityTypeRegistry { private static final Map, List> entities = Maps.newHashMap(); static { - entities.put( - EntityEnderman.class, - ImmutableList.of( - SkyBlockEntity.of("zealot", EntityTypeHelper::isZealot) - ) - ); + entities.put(EntityEnderman.class, ImmutableList.of(SkyBlockEntity.of("zealot", EntityTypeHelper::isZealot))); } public static String getEntityId(Entity entity) { if (!entities.containsKey(entity.getClass())) return null; - for (SkyBlockEntity skyBlockEntity : entities.get( - entity.getClass() - )) if (skyBlockEntity.isEntity(entity)) return skyBlockEntity.getName(); + for (SkyBlockEntity skyBlockEntity : entities.get(entity.getClass())) if ( + skyBlockEntity.isEntity(entity) + ) return skyBlockEntity.getName(); return null; } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/location/DwarvenMineHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/location/DwarvenMineHandler.java index c047767..7df5667 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/location/DwarvenMineHandler.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/location/DwarvenMineHandler.java @@ -37,18 +37,13 @@ public class DwarvenMineHandler { public static String getMithrilFormatted() { String output = formatter.format(mithril); - if (output.equals(".0")) output = "0.0"; else if ( - output.equals(",0") - ) output = "0,0"; + if (output.equals(".0")) output = "0.0"; else if (output.equals(",0")) output = "0,0"; return output; } public static void parseMithril(String line) { try { - mithril = - Integer.parseInt( - line.toLowerCase().replace("mithril powder:", "").trim() - ); + mithril = Integer.parseInt(line.toLowerCase().replace("mithril powder:", "").trim()); } catch (Exception ignored) {} } @@ -56,21 +51,13 @@ public class DwarvenMineHandler { public void onSidebarLineUpdate(SidebarLineUpdateEvent event) { if (event.formattedLine.toLowerCase().contains("mithril")) { try { - mithril = - Integer.parseInt( - event.formattedLine - .toLowerCase() - .replace("mithril:", "") - .trim() - ); + mithril = Integer.parseInt(event.formattedLine.toLowerCase().replace("mithril:", "").trim()); } catch (Exception ignored) {} } if (event.formattedLine.toLowerCase().contains("event")) { if (event.formattedLine.toLowerCase().contains("raffle")) { DwarvenMineHandler.currentEvent = Event.TICKET; - } else if ( - event.formattedLine.toLowerCase().contains("goblin raid") - ) { + } else if (event.formattedLine.toLowerCase().contains("goblin raid")) { DwarvenMineHandler.currentEvent = Event.GOBLIN; } } @@ -83,23 +70,14 @@ public class DwarvenMineHandler { try { eventMax = Integer.parseInt( - event.formattedLine - .toLowerCase() - .replace("pool:", "") - .trim() - .split("/")[0].trim() + event.formattedLine.toLowerCase().replace("pool:", "").trim().split("/")[0].trim() ); } catch (Exception ignored) {} - } else if ( - event.formattedLine.toLowerCase().contains("tickets:") - ) { + } else if (event.formattedLine.toLowerCase().contains("tickets:")) { try { eventProgress = Integer.parseInt( - event.formattedLine - .toLowerCase() - .replace("tickets:", "") - .split("\\(")[0].trim() + event.formattedLine.toLowerCase().replace("tickets:", "").split("\\(")[0].trim() ); } catch (Exception ignored) {} } @@ -121,12 +99,7 @@ public class DwarvenMineHandler { ) { try { eventProgress = - Integer.parseInt( - event.formattedLine - .toLowerCase() - .replace("your kills:", "") - .trim() - ); + Integer.parseInt(event.formattedLine.toLowerCase().replace("your kills:", "").trim()); } catch (Exception ignored) {} } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/location/EndIslandHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/location/EndIslandHandler.java index 51ea9d8..c989cb4 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/location/EndIslandHandler.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/location/EndIslandHandler.java @@ -32,11 +32,7 @@ public class EndIslandHandler { if (input.contains(" ")) { try { return dragonTypes.valueOf( - input - .toLowerCase() - .replace("dragon", "") - .replace(" ", "") - .toUpperCase() + input.toLowerCase().replace("dragon", "").replace(" ", "").toUpperCase() ); } catch (IllegalArgumentException ignored) { return NODRAGON; diff --git a/src/main/java/com/thatgravyboat/skyblockhud/location/FarmingIslandHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/location/FarmingIslandHandler.java index 8997fa4..a4abaae 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/location/FarmingIslandHandler.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/location/FarmingIslandHandler.java @@ -11,19 +11,12 @@ public class FarmingIslandHandler { @SubscribeEvent public void onSidebarPost(SidebarPostEvent event) { - boolean isTracking = Arrays - .toString(event.arrayScores) - .toLowerCase() - .contains("tracker mob location:"); + boolean isTracking = Arrays.toString(event.arrayScores).toLowerCase().contains("tracker mob location:"); if (isTracking && location == Locations.NONE) { for (int i = 0; i < event.scores.size(); i++) { String line = event.scores.get(i); - if ( - line.toLowerCase().contains("tracker mob location:") && - i > 2 - ) { - location = - Locations.get(event.scores.get(i - 1).toLowerCase()); + if (line.toLowerCase().contains("tracker mob location:") && i > 2) { + location = Locations.get(event.scores.get(i - 1).toLowerCase()); break; } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/location/IslandHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/location/IslandHandler.java index a50358d..d16a3ac 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/location/IslandHandler.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/location/IslandHandler.java @@ -30,14 +30,9 @@ public class IslandHandler { public static boolean checkFlightDuration(String formatedScoreboardLine) { if ( LocationHandler.getCurrentLocation() == Locations.YOURISLAND && - Utils - .removeColor(formatedScoreboardLine.toLowerCase().trim()) - .contains("flight duration:") + Utils.removeColor(formatedScoreboardLine.toLowerCase().trim()).contains("flight duration:") ) { - String timeString = formatedScoreboardLine - .toLowerCase() - .replace("flight duration:", "") - .replace(" ", ""); + String timeString = formatedScoreboardLine.toLowerCase().replace("flight duration:", "").replace(" ", ""); String[] times = timeString.split(":"); if (times.length == 2) { int s = 0; @@ -68,18 +63,11 @@ public class IslandHandler { public static boolean checkRestone(String formatedScoreboardLine) { if (LocationHandler.getCurrentLocation() == Locations.YOURISLAND) { - if ( - formatedScoreboardLine.toLowerCase().contains("redstone:") - ) return true; + if (formatedScoreboardLine.toLowerCase().contains("redstone:")) return true; try { redstone = formatedScoreboardLine.toLowerCase().contains("redstone:") - ? Integer.parseInt( - Utils.removeWhiteSpaceAndRemoveWord( - formatedScoreboardLine, - "redstone:" - ) - ) + ? Integer.parseInt(Utils.removeWhiteSpaceAndRemoveWord(formatedScoreboardLine, "redstone:")) : 0; } catch (Exception ignored) {} } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/location/LocationHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/location/LocationHandler.java index 5cd006a..bf55db6 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/location/LocationHandler.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/location/LocationHandler.java @@ -14,9 +14,7 @@ public class LocationHandler { @SubscribeEvent public void onSidebarLineUpdate(SidebarLineUpdateEvent event) { if (event.rawLine.contains("\u23E3")) { - String objectiveName = event.objective - .getDisplayName() - .replaceAll("(?i)\\u00A7.", ""); + String objectiveName = event.objective.getDisplayName().replaceAll("(?i)\\u00A7.", ""); if (objectiveName.toLowerCase(Locale.ENGLISH).endsWith("guest")) { LocationHandler.setCurrentLocation(Locations.GUESTISLAND); } else { @@ -38,10 +36,7 @@ public class LocationHandler { } public static void handleLocation(String locationLine) { - String location = locationLine - .replace(" ", "") - .toUpperCase(Locale.ENGLISH) - .trim(); + String location = locationLine.replace(" ", "").toUpperCase(Locale.ENGLISH).trim(); if (location.startsWith("THECATACOMBS")) { currentLocation = Locations.CATACOMBS; } else setCurrentLocation(location.replaceAll("[^A-Za-z0-9]", "")); diff --git a/src/main/java/com/thatgravyboat/skyblockhud/location/Locations.java b/src/main/java/com/thatgravyboat/skyblockhud/location/Locations.java index 7669456..74e7ae1 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/location/Locations.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/location/Locations.java @@ -7,11 +7,7 @@ public enum Locations { //ISLAND YOURISLAND("yourisland", "Your Island", LocationCategory.ISLAND), GUESTISLAND("guestisland", "Guest Island", LocationCategory.ISLAND), - MOULBERRYSISLAND( - "moulberryisland", - "Cool Dude Hub", - LocationCategory.ISLAND - ), + MOULBERRYSISLAND("moulberryisland", "Cool Dude Hub", LocationCategory.ISLAND), //HUB VILLAGE("village", "Village", LocationCategory.HUB), AUCTIONHOUSE("auctionhouse", "Auction House", LocationCategory.HUB), @@ -33,11 +29,7 @@ public enum Locations { COALMINE("coalmine", "Coal Mine", LocationCategory.HUB), FARM("farm", "Farm", LocationCategory.HUB), LIBRARY("library", "Library", LocationCategory.HUB), - COMMUNITYCENTER( - "communitycenter", - "Community Center", - LocationCategory.HUB - ), + COMMUNITYCENTER("communitycenter", "Community Center", LocationCategory.HUB), ELECTIONROOM("electionroom", "Election Room", LocationCategory.HUB), BUILDERSHOUSE("buildershouse", "Builder's House", LocationCategory.HUB), BLACKSMITH("blacksmith", "Blacksmith", LocationCategory.HUB), @@ -47,66 +39,26 @@ public enum Locations { THEBARN("thebarn", "The Barn", LocationCategory.BARN), WINDMILL("windmill", "Windmill", LocationCategory.BARN), //MUSHROOM DESERT - MUSHROOMDESERT( - "mushroomdesert", - "Mushroom Desert", - LocationCategory.MUSHROOMDESERT - ), - DESERTSETTLEMENT( - "desertsettlement", - "Desert Settlement", - LocationCategory.MUSHROOMDESERT - ), + MUSHROOMDESERT("mushroomdesert", "Mushroom Desert", LocationCategory.MUSHROOMDESERT), + DESERTSETTLEMENT("desertsettlement", "Desert Settlement", LocationCategory.MUSHROOMDESERT), OASIS("oasis", "Oasis", LocationCategory.MUSHROOMDESERT), - MUSHROOMGORGE( - "mushroomgorge", - "Mushroom Gorge", - LocationCategory.MUSHROOMDESERT - ), - SHEPHERDSKEEP( - "shepherdskeep", - "Shepherds Keep", - LocationCategory.MUSHROOMDESERT - ), + MUSHROOMGORGE("mushroomgorge", "Mushroom Gorge", LocationCategory.MUSHROOMDESERT), + SHEPHERDSKEEP("shepherdskeep", "Shepherds Keep", LocationCategory.MUSHROOMDESERT), JAKESHOUSE("jakeshouse", "Jake's House", LocationCategory.MUSHROOMDESERT), - TREASUREHUNTERCAMP( - "treasurehuntercamp", - "Treasure Hunter Camp", - LocationCategory.MUSHROOMDESERT - ), - GLOWINGMUSHROOMCAVE( - "glowingmushroomcave", - "Glowing Mushroom Cave", - LocationCategory.MUSHROOMDESERT - ), + TREASUREHUNTERCAMP("treasurehuntercamp", "Treasure Hunter Camp", LocationCategory.MUSHROOMDESERT), + GLOWINGMUSHROOMCAVE("glowingmushroomcave", "Glowing Mushroom Cave", LocationCategory.MUSHROOMDESERT), TRAPPERSDEN("trappersden", "Trappers Den", LocationCategory.MUSHROOMDESERT), - OVERGROWNMUSHROOMCAVE( - "overgrownmushroomcave", - "Overgrown Mushroom Cave", - LocationCategory.MUSHROOMDESERT - ), + OVERGROWNMUSHROOMCAVE("overgrownmushroomcave", "Overgrown Mushroom Cave", LocationCategory.MUSHROOMDESERT), //GOLD MINE GOLDMINE("goldmine", "Gold Mine", LocationCategory.GOLDMINE), //DEEP CAVERNS DEEPCAVERNS("deepcaverns", "Deep Caverns", LocationCategory.DEEPCAVERNS), - GUNPOWDERMINES( - "gunpowdermines", - "Gunpowder Mines", - LocationCategory.DEEPCAVERNS - ), + GUNPOWDERMINES("gunpowdermines", "Gunpowder Mines", LocationCategory.DEEPCAVERNS), LAPISQUARRY("lapisquarry", "Lapis Quarry", LocationCategory.DEEPCAVERNS), PIGMANSDEN("pigmansden", "Pigman's Den", LocationCategory.DEEPCAVERNS), SLIMEHILL("slimehill", "Slimehill", LocationCategory.DEEPCAVERNS), - DIAMONDRESERVE( - "diamondreserve", - "Diamond Reserve", - LocationCategory.DEEPCAVERNS - ), - OBSIDIANSANCTUARY( - "obsidiansanctuary", - "Obsidian Sanctuary", - LocationCategory.DEEPCAVERNS - ), + DIAMONDRESERVE("diamondreserve", "Diamond Reserve", LocationCategory.DEEPCAVERNS), + OBSIDIANSANCTUARY("obsidiansanctuary", "Obsidian Sanctuary", LocationCategory.DEEPCAVERNS), //SPIDERS DEN SPIDERSDEN("spidersden", "Spider's Den", LocationCategory.SPIDERSDEN), @@ -119,142 +71,50 @@ public enum Locations { BIRCHPARK("birchpark", "Birch Park", LocationCategory.PARK), SPRUCEWOODS("sprucewoods", "Spruce Woods", LocationCategory.PARK), DARKTHICKET("darkthicket", "Dark Thicket", LocationCategory.PARK), - SAVANNAWOODLAND( - "savannawoodland", - "Savanna Woodland", - LocationCategory.PARK - ), + SAVANNAWOODLAND("savannawoodland", "Savanna Woodland", LocationCategory.PARK), JUNGLEISLAND("jungleisland", "Jungle Island", LocationCategory.PARK), //BLAZING FORTRESS - BLAZINGFORTRESS( - "blazingfortress", - "Blazing Fortress", - LocationCategory.FORTRESS - ), + BLAZINGFORTRESS("blazingfortress", "Blazing Fortress", LocationCategory.FORTRESS), //DUNGEONS DUNGEONHUB("dungeonhub", "Dungeon Hub", LocationCategory.DUNGEONHUB), CATACOMBS("catacombs", "The Catacombs", LocationCategory.DUNGEONHUB), - CATACOMBSENTRANCE( - "catacombsentrance", - "Catacombs Entrance", - LocationCategory.DUNGEONHUB - ), + CATACOMBSENTRANCE("catacombsentrance", "Catacombs Entrance", LocationCategory.DUNGEONHUB), //JERRYISLAND - JERRYSWORKSHOP( - "jerrysworkshop", - "Jerry's Workshop", - LocationCategory.JERRY - ), + JERRYSWORKSHOP("jerrysworkshop", "Jerry's Workshop", LocationCategory.JERRY), JERRYPOND("jerrypond", "Jerry Pond", LocationCategory.JERRY), //DWARVENMINES THELIFT("thelift", "The Lift", LocationCategory.DWARVENMINES), - DWARVENVILLAGE( - "dwarvenvillage", - "Dwarven Village", - LocationCategory.DWARVENMINES - ), - DWARVENMINES( - "dwarvenmines", - "Dwarven Mines", - LocationCategory.DWARVENMINES - ), + DWARVENVILLAGE("dwarvenvillage", "Dwarven Village", LocationCategory.DWARVENMINES), + DWARVENMINES("dwarvenmines", "Dwarven Mines", LocationCategory.DWARVENMINES), LAVASPRINGS("lavasprings", "Lava Springs", LocationCategory.DWARVENMINES), - PALACEBRIDGE( - "palacebridge", - "Palace Bridge", - LocationCategory.DWARVENMINES - ), + PALACEBRIDGE("palacebridge", "Palace Bridge", LocationCategory.DWARVENMINES), ROYALPALACE("royalpalace", "Royal Palace", LocationCategory.DWARVENMINES), - GRANDLIBRARY( - "grandlibrary", - "Grand Library", - LocationCategory.DWARVENMINES - ), - ROYALQUARTERS( - "royalquarters", - "Royal Quarters", - LocationCategory.DWARVENMINES - ), - BARRACKSOFHEROES( - "barracksofheroes", - "Barracks of Heroes", - LocationCategory.DWARVENMINES - ), - HANGINGCOURT( - "hangingcourt", - "Hanging Court", - LocationCategory.DWARVENMINES - ), - GREATICEWALL( - "greaticewall", - "Great Ice Wall", - LocationCategory.DWARVENMINES - ), - GOBLINBURROWS( - "goblinburrows", - "Goblin Burrows", - LocationCategory.DWARVENMINES - ), + GRANDLIBRARY("grandlibrary", "Grand Library", LocationCategory.DWARVENMINES), + ROYALQUARTERS("royalquarters", "Royal Quarters", LocationCategory.DWARVENMINES), + BARRACKSOFHEROES("barracksofheroes", "Barracks of Heroes", LocationCategory.DWARVENMINES), + HANGINGCOURT("hangingcourt", "Hanging Court", LocationCategory.DWARVENMINES), + GREATICEWALL("greaticewall", "Great Ice Wall", LocationCategory.DWARVENMINES), + GOBLINBURROWS("goblinburrows", "Goblin Burrows", LocationCategory.DWARVENMINES), FARRESERVE("farreserve", "Far Reserve", LocationCategory.DWARVENMINES), - CCMINECARTSCO( - "ccminecartco", - "Minecart Co.", - LocationCategory.DWARVENMINES - ), + CCMINECARTSCO("ccminecartco", "Minecart Co.", LocationCategory.DWARVENMINES), UPPERMINES("uppermines", "Upper Mines", LocationCategory.DWARVENMINES), - RAMPARTSQUARRY( - "rampartsquarry", - "Ramparts Quarry", - LocationCategory.DWARVENMINES - ), - GATESTOTHEMINES( - "gatestothemines", - "Gates to The Mines", - LocationCategory.DWARVENMINES - ), + RAMPARTSQUARRY("rampartsquarry", "Ramparts Quarry", LocationCategory.DWARVENMINES), + GATESTOTHEMINES("gatestothemines", "Gates to The Mines", LocationCategory.DWARVENMINES), FORGEBASIN("forgebasin", "Forge Basin", LocationCategory.DWARVENMINES), THEFORGE("theforge", "The Forge", LocationCategory.DWARVENMINES), - CLIFFSIDEVEINS( - "cliffsideveins", - "Cliffside Veins", - LocationCategory.DWARVENMINES - ), - DIVANSGATEWAY( - "divansgateway", - "Divan's Gateway", - LocationCategory.DWARVENMINES - ), + CLIFFSIDEVEINS("cliffsideveins", "Cliffside Veins", LocationCategory.DWARVENMINES), + DIVANSGATEWAY("divansgateway", "Divan's Gateway", LocationCategory.DWARVENMINES), THEMIST("themist", "The Mist", LocationCategory.DWARVENMINES), ROYALMINES("royalmines", "Royal Mines", LocationCategory.DWARVENMINES), - ARISTOCRATPASSAGE( - "aristocratpassage", - "Aristocrat Passage", - LocationCategory.DWARVENMINES - ), + ARISTOCRATPASSAGE("aristocratpassage", "Aristocrat Passage", LocationCategory.DWARVENMINES), MINERSGUILD("minersguild", "Miner's Guild", LocationCategory.DWARVENMINES), //CRYSTALHOLLOWS JUNGLE("jungle", "Jungle", LocationCategory.CRYSTALHOLLOWS), MAMGAFIELDS("magmafields", "Magma Fields", LocationCategory.CRYSTALHOLLOWS), - GOBLINHOLDOUT( - "goblinholdout", - "Goblin Holdout", - LocationCategory.CRYSTALHOLLOWS - ), - CRYSTALNUCLEUS( - "crystalnucleus", - "Crystal Nucleus", - LocationCategory.CRYSTALHOLLOWS - ), - PERCURSORREMNANTS( - "precursorremnants", - "Precursor Remnants", - LocationCategory.CRYSTALHOLLOWS - ), - MITHRILDEPOSITS( - "mithrildeposits", - "Mithril Deposits", - LocationCategory.CRYSTALHOLLOWS - ); + GOBLINHOLDOUT("goblinholdout", "Goblin Holdout", LocationCategory.CRYSTALHOLLOWS), + CRYSTALNUCLEUS("crystalnucleus", "Crystal Nucleus", LocationCategory.CRYSTALHOLLOWS), + PERCURSORREMNANTS("precursorremnants", "Precursor Remnants", LocationCategory.CRYSTALHOLLOWS), + MITHRILDEPOSITS("mithrildeposits", "Mithril Deposits", LocationCategory.CRYSTALHOLLOWS); private final String name; private final String displayName; diff --git a/src/main/java/com/thatgravyboat/skyblockhud/location/ParkIslandHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/location/ParkIslandHandler.java index 5d5f756..b9628d0 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/location/ParkIslandHandler.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/location/ParkIslandHandler.java @@ -12,10 +12,8 @@ public class ParkIslandHandler { isRaining = false; rainTime = ""; } else if (tabLine.toLowerCase().contains("rain:")) { - if (tabLine.toLowerCase().contains("no rain")) isRaining = - false; else { - rainTime = - tabLine.toLowerCase().replace("rain:", "").replace(" ", ""); + if (tabLine.toLowerCase().contains("no rain")) isRaining = false; else { + rainTime = tabLine.toLowerCase().replace("rain:", "").replace(" ", ""); isRaining = true; } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinEndermanRenderer.java b/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinEndermanRenderer.java index d29b6f5..330b915 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinEndermanRenderer.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinEndermanRenderer.java @@ -14,10 +14,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(RenderEnderman.class) public class MixinEndermanRenderer { - @Inject( - method = "doRender(Lnet/minecraft/entity/monster/EntityEnderman;DDDFF)V", - at = @At("HEAD") - ) + @Inject(method = "doRender(Lnet/minecraft/entity/monster/EntityEnderman;DDDFF)V", at = @At("HEAD")) public void onRender( EntityEnderman entity, double x, @@ -28,15 +25,8 @@ public class MixinEndermanRenderer { CallbackInfo ci ) { if (EntityTypeHelper.isZealot(entity)) { - Color color = new Color( - SpecialColour.specialToChromaRGB("255:255:0:48:255") - ); - GlStateManager.color( - color.getRed() / 255f, - color.getGreen() / 255f, - color.getBlue() / 255f, - 255f - ); + Color color = new Color(SpecialColour.specialToChromaRGB("255:255:0:48:255")); + GlStateManager.color(color.getRed() / 255f, color.getGreen() / 255f, color.getBlue() / 255f, 255f); } } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinEntityArrow.java b/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinEntityArrow.java index 3641876..2204995 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinEntityArrow.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinEntityArrow.java @@ -23,12 +23,9 @@ public class MixinEntityArrow { position != null && position.entityHit != null && this.shootingEntity != null && - this.shootingEntity.getUniqueID() - .equals(Minecraft.getMinecraft().thePlayer.getUniqueID()) + this.shootingEntity.getUniqueID().equals(Minecraft.getMinecraft().thePlayer.getUniqueID()) ) { - KillTrackerHandler.attackedEntities.add( - position.entityHit.getUniqueID() - ); + KillTrackerHandler.attackedEntities.add(position.entityHit.getUniqueID()); } return position; } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinGuiIngameForge.java b/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinGuiIngameForge.java index d6e0ac6..9886ba0 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinGuiIngameForge.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinGuiIngameForge.java @@ -18,119 +18,63 @@ public class MixinGuiIngameForge { @Shadow(remap = false) private RenderGameOverlayEvent eventParent; - @Inject( - method = "renderArmor", - at = @At("HEAD"), - cancellable = true, - remap = false - ) + @Inject(method = "renderArmor", at = @At("HEAD"), cancellable = true, remap = false) public void onRenderArmor(int width, int height, CallbackInfo ci) { - if ( - SkyblockHud.config.renderer.hideArmor && - SkyblockHud.hasSkyblockScoreboard() - ) { + if (SkyblockHud.config.renderer.hideArmor && SkyblockHud.hasSkyblockScoreboard()) { ci.cancel(); if (pre(ARMOR)) return; post(ARMOR); } } - @Inject( - method = "renderHealth", - at = @At("HEAD"), - cancellable = true, - remap = false - ) + @Inject(method = "renderHealth", at = @At("HEAD"), cancellable = true, remap = false) public void onRenderHealth(int width, int height, CallbackInfo ci) { - if ( - SkyblockHud.config.renderer.hideHearts && - SkyblockHud.hasSkyblockScoreboard() - ) { + if (SkyblockHud.config.renderer.hideHearts && SkyblockHud.hasSkyblockScoreboard()) { ci.cancel(); if (pre(HEALTH)) return; post(HEALTH); } } - @Inject( - method = "renderAir", - at = @At("HEAD"), - cancellable = true, - remap = false - ) + @Inject(method = "renderAir", at = @At("HEAD"), cancellable = true, remap = false) public void onRenderAir(int width, int height, CallbackInfo ci) { - if ( - SkyblockHud.config.renderer.hideAir && - SkyblockHud.hasSkyblockScoreboard() - ) { + if (SkyblockHud.config.renderer.hideAir && SkyblockHud.hasSkyblockScoreboard()) { ci.cancel(); if (pre(AIR)) return; post(AIR); } } - @Inject( - method = "renderHealthMount", - at = @At("HEAD"), - cancellable = true, - remap = false - ) + @Inject(method = "renderHealthMount", at = @At("HEAD"), cancellable = true, remap = false) public void onRenderHealthMount(int width, int height, CallbackInfo ci) { - if ( - SkyblockHud.config.renderer.hideAnimalHearts && - SkyblockHud.hasSkyblockScoreboard() - ) { + if (SkyblockHud.config.renderer.hideAnimalHearts && SkyblockHud.hasSkyblockScoreboard()) { ci.cancel(); if (pre(HEALTHMOUNT)) return; post(HEALTHMOUNT); } } - @Inject( - method = "renderExperience", - at = @At("HEAD"), - cancellable = true, - remap = false - ) + @Inject(method = "renderExperience", at = @At("HEAD"), cancellable = true, remap = false) public void onRenderExperience(int width, int height, CallbackInfo ci) { - if ( - SkyblockHud.config.renderer.hideXpBar && - SkyblockHud.hasSkyblockScoreboard() - ) { + if (SkyblockHud.config.renderer.hideXpBar && SkyblockHud.hasSkyblockScoreboard()) { ci.cancel(); if (pre(EXPERIENCE)) return; post(EXPERIENCE); } } - @Inject( - method = "renderJumpBar", - at = @At("HEAD"), - cancellable = true, - remap = false - ) + @Inject(method = "renderJumpBar", at = @At("HEAD"), cancellable = true, remap = false) public void onRenderJumpBar(int width, int height, CallbackInfo ci) { - if ( - SkyblockHud.config.renderer.hideXpBar && - SkyblockHud.hasSkyblockScoreboard() - ) { + if (SkyblockHud.config.renderer.hideXpBar && SkyblockHud.hasSkyblockScoreboard()) { ci.cancel(); if (pre(JUMPBAR)) return; post(JUMPBAR); } } - @Inject( - method = "renderFood", - at = @At("HEAD"), - cancellable = true, - remap = false - ) + @Inject(method = "renderFood", at = @At("HEAD"), cancellable = true, remap = false) public void onRenderFood(int width, int height, CallbackInfo ci) { - if ( - SkyblockHud.config.renderer.hideFood && - SkyblockHud.hasSkyblockScoreboard() - ) { + if (SkyblockHud.config.renderer.hideFood && SkyblockHud.hasSkyblockScoreboard()) { ci.cancel(); if (pre(FOOD)) return; post(FOOD); @@ -138,14 +82,10 @@ public class MixinGuiIngameForge { } private boolean pre(RenderGameOverlayEvent.ElementType type) { - return MinecraftForge.EVENT_BUS.post( - new RenderGameOverlayEvent.Pre(eventParent, type) - ); + return MinecraftForge.EVENT_BUS.post(new RenderGameOverlayEvent.Pre(eventParent, type)); } private void post(RenderGameOverlayEvent.ElementType type) { - MinecraftForge.EVENT_BUS.post( - new RenderGameOverlayEvent.Post(eventParent, type) - ); + MinecraftForge.EVENT_BUS.post(new RenderGameOverlayEvent.Post(eventParent, type)); } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinNetHandlerPlayClient.java b/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinNetHandlerPlayClient.java index 5cb4036..c97a1f9 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinNetHandlerPlayClient.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinNetHandlerPlayClient.java @@ -55,15 +55,8 @@ public class MixinNetHandlerPlayClient { ), cancellable = true ) - public void handleTeams( - S3EPacketTeams packetIn, - CallbackInfo ci, - Scoreboard scoreboard - ) { + public void handleTeams(S3EPacketTeams packetIn, CallbackInfo ci, Scoreboard scoreboard) { //This stops Hypixel from being stupid and spamming our logs because they dont have different ids for things. - if ( - scoreboard.getTeam(packetIn.getName()) != null && - packetIn.getAction() == 0 - ) ci.cancel(); + if (scoreboard.getTeam(packetIn.getName()) != null && packetIn.getAction() == 0) ci.cancel(); } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/overlay/DungeonOverlay.java b/src/main/java/com/thatgravyboat/skyblockhud/overlay/DungeonOverlay.java index 9d8556d..b4eb8db 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/overlay/DungeonOverlay.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/overlay/DungeonOverlay.java @@ -24,40 +24,21 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; public class DungeonOverlay extends Gui { - private static final FontRenderer font = Minecraft.getMinecraft() - .fontRendererObj; + 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 - ) { + 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 - ); + 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 - ); + drawString(font, healthString, x + 50, y + font.FONT_HEIGHT + 9, 0xFF2B2B); GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); } } @@ -69,50 +50,15 @@ public class DungeonOverlay extends Gui { 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 - ); + 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 - ); + 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 - ) + + (dungeonTimeMin > 9 ? String.valueOf(dungeonTimeMin) : "0" + dungeonTimeMin) + ":" + - ( - dungeonTimeSec > 9 - ? String.valueOf(dungeonTimeSec) - : "0" + dungeonTimeSec - ); - drawCenteredString( - font, - dungeonTimeElapsed, - (width / 2), - offset + (bossBarVisible ? 40 : 23), - 0xFFFF55 - ); + (dungeonTimeSec > 9 ? String.valueOf(dungeonTimeSec) : "0" + dungeonTimeSec); + drawCenteredString(font, dungeonTimeElapsed, (width / 2), offset + (bossBarVisible ? 40 : 23), 0xFFFF55); //KEYS drawString( font, @@ -134,11 +80,7 @@ public class DungeonOverlay extends Gui { int clearPercent = DungeonHandler.getDungeonCleared(); String clearPercentage = "Dungeon Cleared: \u00A7" + - ( - clearPercent <= 20 - ? "4" - : clearPercent <= 50 ? "6" : clearPercent <= 80 ? "e" : "a" - ) + + (clearPercent <= 20 ? "4" : clearPercent <= 50 ? "6" : clearPercent <= 80 ? "e" : "a") + clearPercent + "%"; drawTexturedModalRect( @@ -157,13 +99,7 @@ public class DungeonOverlay extends Gui { 4, 14 ); - drawString( - font, - clearPercentage, - (width / 2) + 18, - offset + (bossBarVisible ? 23 : 6), - 0xAAAAAA - ); + drawString(font, clearPercentage, (width / 2) + 18, offset + (bossBarVisible ? 23 : 6), 0xAAAAAA); //DEATHS GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); @@ -186,13 +122,7 @@ public class DungeonOverlay extends Gui { 4, 14 ); - drawString( - font, - deathText, - (width / 2) + 18, - offset + (bossBarVisible ? 38 : 21), - 0xAAAAAA - ); + drawString(font, deathText, (width / 2) + 18, offset + (bossBarVisible ? 38 : 21), 0xAAAAAA); //SECRETS GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); @@ -200,14 +130,7 @@ public class DungeonOverlay extends Gui { int maxSecrets = DungeonHandler.getMaxSecrets(); int secrets = DungeonHandler.getSecrets(); int totalSecrets = DungeonHandler.getTotalSecrets(); - String secretsText = - "Secrets: " + - secrets + - "/" + - maxSecrets + - " (" + - totalSecrets + - ")"; + String secretsText = "Secrets: " + secrets + "/" + maxSecrets + " (" + totalSecrets + ")"; drawTexturedModalRect( (width / 2) - 17 - (font.getStringWidth(secretsText)) - 4, offset + (bossBarVisible ? 20 : 3), @@ -295,9 +218,7 @@ public class DungeonOverlay extends Gui { ) ) { bossBarVisible = - BossStatus.statusBarTime > 0 && - GuiIngameForge.renderBossHealth && - BossbarHandler.bossBarRendered; + BossStatus.statusBarTime > 0 && GuiIngameForge.renderBossHealth && BossbarHandler.bossBarRendered; GlStateManager.enableBlend(); drawUltimateBar(mc, event.resolution); @@ -310,19 +231,8 @@ public class DungeonOverlay extends Gui { 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]; + 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 { @@ -347,10 +257,7 @@ public class DungeonOverlay extends Gui { } drawDungeonClock( event.resolution.getScaledWidth(), - SkyblockHud.config.main.mainHudPos.getAbsY( - event.resolution, - 34 - ), + 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 45fd243..b249362 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/overlay/GenericOverlays.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/overlay/GenericOverlays.java @@ -22,9 +22,7 @@ public class GenericOverlays extends Gui { ) { if (SkyblockHud.hasSkyblockScoreboard()) { mc.renderEngine.bindTexture(GuiTextures.bars); - Color color = new Color( - percentage == max ? fullColor : loadingColor - ); + Color color = new Color(percentage == max ? fullColor : loadingColor); RenderUtils.drawTexturedModalRect(x, y, 0, 0, 182, 5); GlStateManager.color( @@ -34,23 +32,9 @@ public class GenericOverlays extends Gui { color.getAlpha() / 255f ); RenderUtils.drawTexturedModalRect(x, y, 0, 30, 182, 5); - RenderUtils.drawTexturedModalRect( - x, - y, - 0, - 5, - (int) (182 * percentage), - 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, 5 + (barStyle * 5), 182, 5); } } } @@ -67,9 +51,7 @@ public class GenericOverlays extends Gui { ) { if (SkyblockHud.hasSkyblockScoreboard()) { mc.renderEngine.bindTexture(GuiTextures.bars); - Color color = new Color( - percentage == max ? fullColor : loadingColor - ); + Color color = new Color(percentage == max ? fullColor : loadingColor); GlStateManager.enableBlend(); RenderUtils.drawTexturedModalRect(x, y, 0, 35, 62, 5); GlStateManager.color( @@ -79,23 +61,9 @@ public class GenericOverlays extends Gui { color.getAlpha() / 255f ); RenderUtils.drawTexturedModalRect(x, y, 0, 65, 62, 5); - RenderUtils.drawTexturedModalRect( - x, - y, - 0, - 40, - (int) (62 * percentage), - 5 - ); + RenderUtils.drawTexturedModalRect(x, y, 0, 40, (int) (62 * percentage), 5); if (barStyle != 0) { - RenderUtils.drawTexturedModalRect( - x, - y, - 0, - 45 + (barStyle * 5), - 62, - 5 - ); + 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 cba60eb..5560ff7 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/overlay/OverlayHud.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/overlay/OverlayHud.java @@ -25,8 +25,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; public class OverlayHud extends Gui { - private static final FontRenderer font = Minecraft.getMinecraft() - .fontRendererObj; + private static final FontRenderer font = Minecraft.getMinecraft().fontRendererObj; //STATS private static boolean eventToggle; @@ -41,8 +40,7 @@ public class OverlayHud extends Gui { int timeMin = (int) (TimeHandler.time / 60); int timeHour = timeMin / 60; timeMin = timeMin - (timeHour * 60); - String militaryTime = - timeHour + ":" + (timeMin == 0 ? timeMin + "0" : timeMin); + String militaryTime = timeHour + ":" + (timeMin == 0 ? timeMin + "0" : timeMin); int time12Hour = timeHour >= 12 ? timeHour - 12 : timeHour; String normalTime = (time12Hour == 0 ? "00" : String.valueOf(time12Hour)) + @@ -50,14 +48,7 @@ public class OverlayHud extends Gui { (timeMin == 0 ? "00" : timeMin) + (timeHour >= 12 ? "pm" : "am"); - drawTexturedModalRect( - (width / 2) - 17, - offset + (bossBarVisible ? 17 : 0), - 0, - 0, - 34, - 34 - ); + drawTexturedModalRect((width / 2) - 17, offset + (bossBarVisible ? 17 : 0), 0, 0, 34, 34); drawTexturedModalRect( (width / 2) - 4, offset + (bossBarVisible ? 24 : 7), @@ -94,43 +85,20 @@ public class OverlayHud extends Gui { //EXTRA SLOT if (LocationHandler.getCurrentLocation().equals(Locations.YOURISLAND)) { - if (IslandHandler.flightTime > 0) drawFlightDuration( - width, - offset, - mc - ); - } else if ( - LocationHandler - .getCurrentLocation() - .getCategory() - .equals(LocationCategory.MUSHROOMDESERT) - ) { + 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 - ) { + } 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) && + LocationHandler.getCurrentLocation().getCategory().equals(LocationCategory.PARK) && ParkIslandHandler.isRaining() ) { - if ( - LocationHandler - .getCurrentLocation() - .equals(Locations.HOWLINGCAVE) - ) { + if (LocationHandler.getCurrentLocation().equals(Locations.HOWLINGCAVE)) { drawSlayer(width, offset, mc); } else drawRainDuration(width, offset, mc); } else if (SlayerHandler.isDoingSlayer) { @@ -141,9 +109,7 @@ public class OverlayHud extends Gui { 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 % 100 == 0 && eventToggle) eventToggle = false; if (mc.thePlayer.ticksExisted % 600 == 0) eventToggle = true; mc.renderEngine.bindTexture(GuiTextures.overlay); String dateText = SeasonDateHandler.getFancySeasonAndDate(); @@ -152,9 +118,7 @@ public class OverlayHud extends Gui { !SeasonDateHandler.getCurrentEvent().isEmpty() && !SeasonDateHandler.getCurrentEventTime().isEmpty() ) dateText = - SeasonDateHandler.getCurrentEvent().trim() + - " " + - SeasonDateHandler.getCurrentEventTime().trim(); + SeasonDateHandler.getCurrentEvent().trim() + " " + SeasonDateHandler.getCurrentEventTime().trim(); drawTexturedModalRect( (width / 2) + 17, offset + (bossBarVisible ? 20 : 3), @@ -179,13 +143,7 @@ public class OverlayHud extends Gui { 8, 8 ); - drawString( - font, - dateText, - (width / 2) + 18, - offset + (bossBarVisible ? 23 : 6), - 0xffffff - ); + drawString(font, dateText, (width / 2) + 18, offset + (bossBarVisible ? 23 : 6), 0xffffff); } } @@ -193,13 +151,7 @@ public class OverlayHud extends Gui { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); mc.renderEngine.bindTexture(GuiTextures.overlay); drawTexturedModalRect( - (width / 2) - - 33 - - ( - font.getStringWidth( - LocationHandler.getCurrentLocation().getDisplayName() - ) - ), + (width / 2) - 33 - (font.getStringWidth(LocationHandler.getCurrentLocation().getDisplayName())), offset + (bossBarVisible ? 20 : 3), 0, 34, @@ -207,36 +159,15 @@ public class OverlayHud extends Gui { 14 ); drawTexturedModalRect( - ( - (width / 2) - - 33 - - ( - font.getStringWidth( - LocationHandler.getCurrentLocation().getDisplayName() - ) - ) - ) + - 2, + ((width / 2) - 33 - (font.getStringWidth(LocationHandler.getCurrentLocation().getDisplayName()))) + 2, offset + (bossBarVisible ? 20 : 3), 2, 34, - font.getStringWidth( - LocationHandler.getCurrentLocation().getDisplayName() - ) + - 14, + font.getStringWidth(LocationHandler.getCurrentLocation().getDisplayName()) + 14, 14 ); drawTexturedModalRect( - ( - (width / 2) - - 33 - - ( - font.getStringWidth( - LocationHandler.getCurrentLocation().getDisplayName() - ) - ) - ) + - 4, + ((width / 2) - 33 - (font.getStringWidth(LocationHandler.getCurrentLocation().getDisplayName()))) + 4, offset + (bossBarVisible ? 23 : 6), LocationHandler.getCurrentLocation().getCategory().getTexturePos(), 8, @@ -246,13 +177,7 @@ public class OverlayHud extends Gui { drawString( font, LocationHandler.getCurrentLocation().getDisplayName(), - (width / 2) - - 19 - - ( - font.getStringWidth( - LocationHandler.getCurrentLocation().getDisplayName() - ) - ), + (width / 2) - 19 - (font.getStringWidth(LocationHandler.getCurrentLocation().getDisplayName())), offset + (bossBarVisible ? 23 : 6), 0xFFFFFF ); @@ -263,29 +188,10 @@ public class OverlayHud extends Gui { 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 - ); + : 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 + "%", @@ -310,21 +216,8 @@ public class OverlayHud extends Gui { 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 - ); + 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; @@ -339,14 +232,7 @@ public class OverlayHud extends Gui { font.getStringWidth(CurrencyHandler.getBitsFormatted()) + 11, 14 ); - drawTexturedModalRect( - xPos + 1, - offset + (bossBarVisible ? 37 : 20), - 75, - 0, - 8, - 8 - ); + drawTexturedModalRect(xPos + 1, offset + (bossBarVisible ? 37 : 20), 75, 0, 8, 8); drawString( font, CurrencyHandler.getBitsFormatted(), @@ -356,40 +242,25 @@ public class OverlayHud extends Gui { ); GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); mc.renderEngine.bindTexture(GuiTextures.overlay); - xPos += - font.getStringWidth(CurrencyHandler.getBitsFormatted()) + 11; + xPos += font.getStringWidth(CurrencyHandler.getBitsFormatted()) + 11; } - drawTexturedModalRect( - xPos, - offset + (bossBarVisible ? 35 : 18), - 252, - 34, - 4, - 14 - ); + 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) - ); + DecimalFormat flightFormat = new DecimalFormat("#.#", DecimalFormatSymbols.getInstance(Locale.CANADA)); String duration; - if (IslandHandler.flightTime < 60) duration = - IslandHandler.flightTime + "s"; else if ( + 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"; + ) 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)), @@ -426,12 +297,7 @@ public class OverlayHud extends Gui { } public void drawRainDuration(int width, int offset, Minecraft mc) { - if ( - LocationHandler - .getCurrentLocation() - .getCategory() - .equals(LocationCategory.PARK) - ) { + 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(); @@ -536,12 +402,7 @@ public class OverlayHud extends Gui { } public void drawMithril(int width, int offset, Minecraft mc) { - if ( - LocationHandler - .getCurrentLocation() - .getCategory() - .equals(LocationCategory.DWARVENMINES) - ) { + 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(); @@ -580,12 +441,7 @@ public class OverlayHud extends Gui { } public void drawTrapperOrPelts(int width, int offset, Minecraft mc) { - if ( - LocationHandler - .getCurrentLocation() - .getCategory() - .equals(LocationCategory.MUSHROOMDESERT) - ) { + 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 @@ -626,19 +482,11 @@ public class OverlayHud extends Gui { } public void drawDwarvenEvent(int width, int offset, Minecraft mc) { - if ( - LocationHandler - .getCurrentLocation() - .getCategory() - .equals(LocationCategory.DWARVENMINES) - ) { + 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; + String duration = DwarvenMineHandler.eventProgress + "/" + DwarvenMineHandler.eventMax; drawTexturedModalRect( (width / 2) - 33 - (font.getStringWidth(duration)), offset + (bossBarVisible ? 35 : 18), @@ -709,25 +557,15 @@ public class OverlayHud extends Gui { @SubscribeEvent public void renderOverlay(RenderGameOverlayEvent.Post event) { - if ( - Utils.overlayShouldRender( - event.type, - SkyblockHud.hasSkyblockScoreboard() - ) - ) { + if (Utils.overlayShouldRender(event.type, SkyblockHud.hasSkyblockScoreboard())) { bossBarVisible = - BossStatus.statusBarTime > 0 && - GuiIngameForge.renderBossHealth && - BossbarHandler.bossBarRendered; + 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 - ), + SkyblockHud.config.main.mainHudPos.getAbsY(event.resolution, 34), mc ); } @@ -735,21 +573,9 @@ public class OverlayHud extends Gui { } } - public void drawScaledString( - float factor, - int x, - int y, - String text, - int color - ) { + 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 - ); + 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 885ff7a..dce51a9 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/overlay/RPGHud.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/overlay/RPGHud.java @@ -40,15 +40,10 @@ public class RPGHud extends Gui { } public static void manaPredictionUpdate(boolean isIncrease, int decrease) { - mana = - isIncrease - ? Math.min(mana + (maxMana / 50), maxMana) - : mana - decrease; + mana = isIncrease ? Math.min(mana + (maxMana / 50), maxMana) : mana - decrease; } - private static final DecimalFormat decimalFormat = new DecimalFormat( - "#.##" - ); + private static final DecimalFormat decimalFormat = new DecimalFormat("#.##"); static { decimalFormat.setGroupingUsed(true); @@ -65,10 +60,7 @@ public class RPGHud extends Gui { ) ) MinecraftForge.EVENT_BUS.post( new RenderGameOverlayEvent.Post( - new RenderGameOverlayEvent( - event.partialTicks, - event.resolution - ), + new RenderGameOverlayEvent(event.partialTicks, event.resolution), RenderGameOverlayEvent.ElementType.EXPERIENCE ) ); @@ -84,17 +76,7 @@ public class RPGHud extends Gui { 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 - ); + health = Math.max((int) (maxHealth * (mc.thePlayer.getHealth() / mc.thePlayer.getMaxHealth())), health); } mc.renderEngine.bindTexture(GuiTextures.playerStat); @@ -107,10 +89,7 @@ public class RPGHud extends Gui { drawTexturedModalRect(x, y, rightAligned ? 131 : 5, 6, 120, 47); - float manaWidth = Math.min( - 57 * ((float) mana / (float) maxMana), - 57 - ); + float manaWidth = Math.min(57 * ((float) mana / (float) maxMana), 57); drawTexturedModalRect( rightAligned ? x + 16 : 47 + x, 17 + y, @@ -120,10 +99,7 @@ public class RPGHud extends Gui { 4 ); - float healthWidth = Math.min( - 70 * ((float) health / (float) maxHealth), - 70 - ); + float healthWidth = Math.min(70 * ((float) health / (float) maxHealth), 70); drawTexturedModalRect( rightAligned ? x + 3 : 47 + x, 22 + y, @@ -134,10 +110,7 @@ public class RPGHud extends Gui { ); if (health > maxHealth) { - float absorptionWidth = Math.min( - 70 * ((float) (health - maxHealth) / (float) maxHealth), - 70 - ); + float absorptionWidth = Math.min(70 * ((float) (health - maxHealth) / (float) maxHealth), 70); drawTexturedModalRect( rightAligned ? x + 3 : 47 + x, 22 + y, @@ -149,27 +122,13 @@ public class RPGHud extends Gui { } float xpWidth = 67 * mc.thePlayer.experience; - drawTexturedModalRect( - rightAligned ? x + 7 : 45 + x, - 28 + y, - rightAligned ? 189 : 0, - 73, - (int) xpWidth, - 4 - ); + 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 + 17 : 39 + x, 33 + y, rightAligned ? 192 : 0, 82, 64, 6); drawTexturedModalRect( rightAligned ? x + 19 : 41 + x, 33 + y, diff --git a/src/main/java/com/thatgravyboat/skyblockhud/playerstats/ActionBarParsing.java b/src/main/java/com/thatgravyboat/skyblockhud/playerstats/ActionBarParsing.java index a37726f..44a250f 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/playerstats/ActionBarParsing.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/playerstats/ActionBarParsing.java @@ -18,43 +18,23 @@ public class ActionBarParsing { private static String lastLowActionBar = ""; private static IChatComponent lastLowEditedActionBar = null; - private static final Pattern HealthRegex = Pattern.compile( - "([0-9]+)/([0-9]+)\u2764" - ); - private static final Pattern HealingRegex = Pattern.compile( - "\\+([0-9]+)[\u2586\u2585\u2584\u2583\u2582\u2581]" - ); - private static final Pattern DefenseRegex = Pattern.compile( - "([0-9]+)\u2748 Defense" - ); - private static final Pattern ManaRegex = Pattern.compile( - "([0-9]+)/([0-9]+)\u270E Mana" - ); - private static final Pattern ManaOverflowRegex = Pattern.compile( - "([0-9]+)/([0-9]+)\u270E ([0-9]+)\u02AC" - ); - private static final Pattern ManaDecreaseRegex = Pattern.compile( - "-([0-9]+) Mana \\(" - ); + private static final Pattern HealthRegex = Pattern.compile("([0-9]+)/([0-9]+)\u2764"); + private static final Pattern HealingRegex = Pattern.compile("\\+([0-9]+)[\u2586\u2585\u2584\u2583\u2582\u2581]"); + private static final Pattern DefenseRegex = Pattern.compile("([0-9]+)\u2748 Defense"); + private static final Pattern ManaRegex = Pattern.compile("([0-9]+)/([0-9]+)\u270E Mana"); + private static final Pattern ManaOverflowRegex = Pattern.compile("([0-9]+)/([0-9]+)\u270E ([0-9]+)\u02AC"); + private static final Pattern ManaDecreaseRegex = Pattern.compile("-([0-9]+) Mana \\("); private static final Pattern XpGainRegex = Pattern.compile( "\\+(\\d*\\.?\\d*) (Farming|Mining|Combat|Foraging|Fishing|Enchanting|Alchemy|Carpentry|Runecrafting) \\((\\d*\\.?\\d*)%\\)" ); - private static final Pattern HealthReplaceRegex = Pattern.compile( - "\u00A7c([0-9]+)/([0-9]+)\u2764" - ); + private static final Pattern HealthReplaceRegex = Pattern.compile("\u00A7c([0-9]+)/([0-9]+)\u2764"); private static final Pattern HealingReplaceRegex = Pattern.compile( "\\+\u00A7c([0-9]+)[\u2586\u2585\u2584\u2583\u2582\u2581]" ); - private static final Pattern HealthAbsorptionReplaceRegex = Pattern.compile( - "\u00A76([0-9]+)/([0-9]+)\u2764" - ); - private static final Pattern DefenseReplaceRegex = Pattern.compile( - "\u00A7a([0-9]+)\u00A7a\u2748 Defense" - ); - private static final Pattern ManaReplaceRegex = Pattern.compile( - "\u00A7b([0-9]+)/([0-9]+)\u270E Mana" - ); + private static final Pattern HealthAbsorptionReplaceRegex = Pattern.compile("\u00A76([0-9]+)/([0-9]+)\u2764"); + private static final Pattern DefenseReplaceRegex = Pattern.compile("\u00A7a([0-9]+)\u00A7a\u2748 Defense"); + private static final Pattern ManaReplaceRegex = Pattern.compile("\u00A7b([0-9]+)/([0-9]+)\u270E Mana"); private static final Pattern ManaOverflowReplaceRegex = Pattern.compile( "\u00A7b([0-9]+)/([0-9]+)\u270E \u00A73([0-9]+)\u02AC" ); @@ -66,10 +46,7 @@ public class ActionBarParsing { public void tick(TickEvent.ClientTickEvent event) { if (predict) { ticksSinceLastPrediction++; - if ( - ticksSinceLastPrediction == 20 && - SkyblockHud.config.rpg.showRpgHud - ) { + if (ticksSinceLastPrediction == 20 && SkyblockHud.config.rpg.showRpgHud) { ticksSinceLastPrediction = 0; RPGHud.manaPredictionUpdate(true, 0); } @@ -78,37 +55,22 @@ public class ActionBarParsing { @SubscribeEvent(priority = EventPriority.HIGHEST) public void onStatusBarHigh(ClientChatReceivedEvent event) { - if ( - event.type == 2 && - SkyblockHud.hasSkyblockScoreboard() && - SkyblockHud.config.rpg.showRpgHud - ) { + if (event.type == 2 && SkyblockHud.hasSkyblockScoreboard() && SkyblockHud.config.rpg.showRpgHud) { parseActionBar(event.message.getUnformattedText()); } } @SubscribeEvent(priority = EventPriority.LOW) public void onStatusBarLow(ClientChatReceivedEvent event) { - if ( - event.type == 2 && - SkyblockHud.hasSkyblockScoreboard() && - SkyblockHud.config.rpg.showRpgHud - ) { + if (event.type == 2 && SkyblockHud.hasSkyblockScoreboard() && SkyblockHud.config.rpg.showRpgHud) { String message = event.message.getUnformattedText(); - if ( - lastLowEditedActionBar == null || - !lastLowActionBar.equals(message) - ) { + if (lastLowEditedActionBar == null || !lastLowActionBar.equals(message)) { lastLowActionBar = message; message = HealthReplaceRegex.matcher(message).replaceAll(""); - message = - HealthAbsorptionReplaceRegex - .matcher(message) - .replaceAll(""); + message = HealthAbsorptionReplaceRegex.matcher(message).replaceAll(""); message = DefenseReplaceRegex.matcher(message).replaceAll(""); message = ManaReplaceRegex.matcher(message).replaceAll(""); - message = - ManaOverflowReplaceRegex.matcher(message).replaceAll(""); + message = ManaOverflowReplaceRegex.matcher(message).replaceAll(""); lastLowEditedActionBar = new ChatComponentText(message.trim()); } @@ -145,19 +107,14 @@ public class ActionBarParsing { } if (defenseFound) { try { - RPGHud.updateDefense( - Integer.parseInt(DefenseMatcher.group(1)) - ); + RPGHud.updateDefense(Integer.parseInt(DefenseMatcher.group(1))); } catch (Exception ignored) {} } else if (!xpFound && !manaUseFound) { RPGHud.updateDefense(0); } if (manaFound) { try { - RPGHud.updateMana( - Integer.parseInt(ManaMatcher.group(1)), - Integer.parseInt(ManaMatcher.group(2)) - ); + RPGHud.updateMana(Integer.parseInt(ManaMatcher.group(1)), Integer.parseInt(ManaMatcher.group(2))); } catch (Exception ignored) {} } if (!manaFound && manaOverflowFound) { @@ -166,18 +123,13 @@ public class ActionBarParsing { Integer.parseInt(ManaOverflowMatcher.group(1)), Integer.parseInt(ManaOverflowMatcher.group(2)) ); - RPGHud.updateOverflow( - Integer.parseInt(ManaOverflowMatcher.group(3)) - ); + RPGHud.updateOverflow(Integer.parseInt(ManaOverflowMatcher.group(3))); } catch (Exception ignored) {} } if (!manaFound) { if (manaUseFound) { try { - RPGHud.manaPredictionUpdate( - false, - Integer.parseInt(ManaUseMatcher.group(1)) - ); + RPGHud.manaPredictionUpdate(false, Integer.parseInt(ManaUseMatcher.group(1))); } catch (Exception ignored) {} } RPGHud.manaPredictionUpdate(true, 0); diff --git a/src/main/java/com/thatgravyboat/skyblockhud/seasons/SeasonDateHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/seasons/SeasonDateHandler.java index 609b3b7..ef61b43 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/seasons/SeasonDateHandler.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/seasons/SeasonDateHandler.java @@ -14,25 +14,10 @@ public class SeasonDateHandler { @SubscribeEvent public void onSidebarLineUpdate(SidebarLineUpdateEvent event) { - if ( - Season.get( - SeasonDateHandler - .removeDate(event.formattedLine.toLowerCase()) - .toUpperCase() - ) != - Season.ERROR - ) { + if (Season.get(SeasonDateHandler.removeDate(event.formattedLine.toLowerCase()).toUpperCase()) != Season.ERROR) { SeasonDateHandler.setCurrentDateAndSeason( - SeasonDateHandler.removeSeason( - Utils.removeColor(event.formattedLine.toLowerCase().trim()) - ), - SeasonDateHandler - .removeDate( - Utils.removeColor( - event.formattedLine.toLowerCase().trim() - ) - ) - .toUpperCase() + SeasonDateHandler.removeSeason(Utils.removeColor(event.formattedLine.toLowerCase().trim())), + SeasonDateHandler.removeDate(Utils.removeColor(event.formattedLine.toLowerCase().trim())).toUpperCase() ); } } @@ -70,12 +55,7 @@ public class SeasonDateHandler { } public static String getFancySeasonAndDate() { - return ( - currentSeason.getDisplayName() + - " " + - currentDate + - getDataSuffix(currentDate) - ); + return (currentSeason.getDisplayName() + " " + currentDate + getDataSuffix(currentDate)); } public static String getCurrentEvent() { @@ -96,12 +76,6 @@ public class SeasonDateHandler { } public static int removeSeason(String seasonDate) { - return Integer.parseInt( - Pattern - .compile("[^0-9]") - .matcher(seasonDate.toLowerCase()) - .replaceAll("") - .trim() - ); + return Integer.parseInt(Pattern.compile("[^0-9]").matcher(seasonDate.toLowerCase()).replaceAll("").trim()); } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/tracker/KillTrackerHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/tracker/KillTrackerHandler.java index 552837b..8f0608d 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/tracker/KillTrackerHandler.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/tracker/KillTrackerHandler.java @@ -34,9 +34,7 @@ public class KillTrackerHandler { NBTTagCompound tag = new NBTTagCompound(); event.entity.writeToNBT(tag); System.out.println("Tag : " + tag); - System.out.println( - "Damage : " + getDamageSourceString(event.source) - ); + System.out.println("Damage : " + getDamageSourceString(event.source)); System.out.println( "----------------------------------------------------------------------------------------------------------------" ); @@ -74,11 +72,7 @@ public class KillTrackerHandler { @SubscribeEvent public void onWorldChange(EntityJoinWorldEvent event) { if (event.entity != null) { - if ( - event.entity - .getUniqueID() - .equals(Minecraft.getMinecraft().thePlayer.getUniqueID()) - ) { + if (event.entity.getUniqueID().equals(Minecraft.getMinecraft().thePlayer.getUniqueID())) { attackedEntities.clear(); } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/tracker/TrackerFileLoader.java b/src/main/java/com/thatgravyboat/skyblockhud/tracker/TrackerFileLoader.java index 7035fee..ba22101 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/tracker/TrackerFileLoader.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/tracker/TrackerFileLoader.java @@ -23,24 +23,15 @@ public class TrackerFileLoader { public static ItemStack getDisplayItem(JsonObject jsonObject) { int meta = jsonObject.get("meta").getAsInt(); String displayItemId = jsonObject.get("item").getAsString(); - Item item = Item.itemRegistry.getObject( - new ResourceLocation(displayItemId) - ); + Item item = Item.itemRegistry.getObject(new ResourceLocation(displayItemId)); ItemStack stack = new ItemStack(item, 0, meta); - if ( - jsonObject.has("skullData") && - displayItemId.equals("minecraft:skull") && - meta == 3 - ) { - stack.setTagInfo( - "SkullOwner", - getSkullTag(jsonObject.getAsJsonObject("skullData")) - ); + if (jsonObject.has("skullData") && displayItemId.equals("minecraft:skull") && meta == 3) { + stack.setTagInfo("SkullOwner", getSkullTag(jsonObject.getAsJsonObject("skullData"))); } - if ( - jsonObject.has("enchanted") && - jsonObject.get("enchanted").getAsBoolean() - ) stack.setTagInfo("ench", new NBTTagList()); + if (jsonObject.has("enchanted") && jsonObject.get("enchanted").getAsBoolean()) stack.setTagInfo( + "ench", + new NBTTagList() + ); return stack; } @@ -65,10 +56,7 @@ public class TrackerFileLoader { for (JsonElement element : object.get("trackers").getAsJsonArray()) { JsonObject tracker = element.getAsJsonObject(); StringBuilder builder = new StringBuilder(); - tracker - .get("location") - .getAsJsonArray() - .forEach(loc -> builder.append(loc.getAsString())); + tracker.get("location").getAsJsonArray().forEach(loc -> builder.append(loc.getAsString())); String location = builder.toString(); Map stacks = new HashMap<>(); @@ -76,42 +64,27 @@ public class TrackerFileLoader { JsonObject dropObject = drop.getAsJsonObject(); //Display Item Creation - ItemStack stack = getDisplayItem( - dropObject.getAsJsonObject("displayItem") - ); + ItemStack stack = getDisplayItem(dropObject.getAsJsonObject("displayItem")); String itemId = dropObject.get("id").getAsString(); stacks.put(itemId, stack); } - String event = tracker.has("event") - ? tracker.get("event").getAsString() - : null; + String event = tracker.has("event") ? tracker.get("event").getAsString() : null; Map> events = new HashMap<>(); events.put(event, stacks); if (TrackerHandler.trackers.containsKey(location)) { - TrackerHandler.trackers - .get(location) - .dropTrackers.put(event, stacks); + TrackerHandler.trackers.get(location).dropTrackers.put(event, stacks); } else { - TrackerHandler.trackers.putIfAbsent( - location, - new TrackerHandler.TrackerData(events) - ); + TrackerHandler.trackers.putIfAbsent(location, new TrackerHandler.TrackerData(events)); } tracker .get("location") .getAsJsonArray() - .forEach( - loc -> - TrackerHandler.trackerIds.put( - Locations.get(loc.getAsString()), - location - ) - ); + .forEach(loc -> TrackerHandler.trackerIds.put(Locations.get(loc.getAsString()), location)); } } @@ -124,16 +97,13 @@ public class TrackerFileLoader { JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("location", locations); - if (event == null) jsonObject.add( + if (event == null) jsonObject.add("event", new JsonNull()); else jsonObject.addProperty( "event", - new JsonNull() - ); else jsonObject.addProperty("event", event); + event + ); JsonObject dropsData = new JsonObject(); - drops.forEach( - (s, stack) -> - dropsData.addProperty(s, stack.stackSize) - ); + drops.forEach((s, stack) -> dropsData.addProperty(s, stack.stackSize)); jsonObject.add("drops", dropsData); trackerStats.add(jsonObject); } @@ -146,20 +116,10 @@ public class TrackerFileLoader { public static void loadTrackersFile() { try { - ResourceLocation trackers = new ResourceLocation( - "skyblockhud:data/trackers.json" - ); - InputStream is = Minecraft - .getMinecraft() - .getResourceManager() - .getResource(trackers) - .getInputStream(); + ResourceLocation trackers = new ResourceLocation("skyblockhud:data/trackers.json"); + InputStream is = Minecraft.getMinecraft().getResourceManager().getResource(trackers).getInputStream(); - try ( - BufferedReader reader = new BufferedReader( - new InputStreamReader(is, StandardCharsets.UTF_8) - ) - ) { + try (BufferedReader reader = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8))) { loadTrackers(gson.fromJson(reader, JsonObject.class)); } } catch (Exception ignored) {} @@ -175,10 +135,7 @@ public class TrackerFileLoader { try ( BufferedReader reader = new BufferedReader( - new InputStreamReader( - new FileInputStream(configFile), - StandardCharsets.UTF_8 - ) + new InputStreamReader(new FileInputStream(configFile), StandardCharsets.UTF_8) ) ) { JsonObject json = gson.fromJson(reader, JsonObject.class); @@ -189,37 +146,25 @@ public class TrackerFileLoader { element -> { if (element.isJsonObject()) { JsonObject object = element.getAsJsonObject(); - String location = object - .get("location") - .getAsString(); - Map> trackers = TrackerHandler.trackers.get( - location - ) + String location = object.get("location").getAsString(); + Map> trackers = TrackerHandler.trackers.get(location) .dropTrackers; JsonElement event = object.get("event"); - String eventString = event == null || - event.isJsonNull() + String eventString = event == null || event.isJsonNull() ? null : event.getAsString(); - Map drops = trackers.get( - eventString - ); + Map drops = trackers.get(eventString); if (drops != null) { for (Map.Entry drop : object .getAsJsonObject("drops") .entrySet()) { - if ( - drops.containsKey(drop.getKey()) - ) { - drops.get(drop.getKey()) - .stackSize = - drop.getValue().getAsInt(); + if (drops.containsKey(drop.getKey())) { + drops.get(drop.getKey()).stackSize = drop.getValue().getAsInt(); } } - drops = - TrackerHandler.sortTrackers(drops); + drops = TrackerHandler.sortTrackers(drops); trackers.put(eventString, drops); } } @@ -239,10 +184,7 @@ public class TrackerFileLoader { try ( BufferedWriter writer = new BufferedWriter( - new OutputStreamWriter( - new FileOutputStream(configFile), - StandardCharsets.UTF_8 - ) + new OutputStreamWriter(new FileOutputStream(configFile), StandardCharsets.UTF_8) ) ) { JsonObject json = new JsonObject(); diff --git a/src/main/java/com/thatgravyboat/skyblockhud/tracker/TrackerHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/tracker/TrackerHandler.java index 8c8a521..2d5607f 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/tracker/TrackerHandler.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/tracker/TrackerHandler.java @@ -37,30 +37,16 @@ public class TrackerHandler { } private boolean eventGoing() { - return SeasonDateHandler - .getCurrentEventTime() - .trim() - .toLowerCase() - .contains("ends in"); + return SeasonDateHandler.getCurrentEventTime().trim().toLowerCase().contains("ends in"); } } public static Map trackers = new HashMap<>(); public static Map trackerIds = new HashMap<>(); - public static Map sortTrackers( - Map map - ) { - List> list = new ArrayList<>( - map.entrySet() - ); - list.sort( - (entry1, entry2) -> - Integer.compare( - entry2.getValue().stackSize, - entry1.getValue().stackSize - ) - ); + public static Map sortTrackers(Map map) { + List> list = new ArrayList<>(map.entrySet()); + list.sort((entry1, entry2) -> Integer.compare(entry2.getValue().stackSize, entry1.getValue().stackSize)); Map result = new LinkedHashMap<>(); for (Map.Entry entry : list) { @@ -70,26 +56,12 @@ public class TrackerHandler { return result; } - public static void onItemAdded( - String id, - int amount, - String enchant, - int level - ) { - if ( - SkyblockHud.hasSkyblockScoreboard() && - trackerIds.containsKey(LocationHandler.getCurrentLocation()) - ) { - String trackerId = trackerIds.get( - LocationHandler.getCurrentLocation() - ); + public static void onItemAdded(String id, int amount, String enchant, int level) { + if (SkyblockHud.hasSkyblockScoreboard() && trackerIds.containsKey(LocationHandler.getCurrentLocation())) { + String trackerId = trackerIds.get(LocationHandler.getCurrentLocation()); TrackerData tracked = trackers.get(trackerId); - String dropTrackerId = tracked.getDropId( - SeasonDateHandler.getCurrentEvent() - ); - Map tracker = tracked.dropTrackers.get( - dropTrackerId - ); + String dropTrackerId = tracked.getDropId(SeasonDateHandler.getCurrentEvent()); + Map tracker = tracked.dropTrackers.get(dropTrackerId); String dropId = id; if (enchant != null) { dropId = enchant.toUpperCase() + ";" + level; @@ -123,9 +95,7 @@ public class TrackerHandler { !SkyblockHud.config.trackers.hideTracker ) ) { - String trackerId = trackerIds.get( - LocationHandler.getCurrentLocation() - ); + String trackerId = trackerIds.get(LocationHandler.getCurrentLocation()); Minecraft mc = Minecraft.getMinecraft(); TrackerData tracked = trackers.get(trackerId); @@ -134,29 +104,16 @@ public class TrackerHandler { ); if (tracker != null) { Position pos = SkyblockHud.config.trackers.trackerPosition; - int startPos = pos.getAbsX( - event.resolution, - (tracker.size() >= 6 ? 120 : tracker.size() * 20) - ); - int y = pos.getAbsY( - event.resolution, - (int) (10 + Math.ceil(tracker.size() / 5d) * 20) - ); + int startPos = pos.getAbsX(event.resolution, (tracker.size() >= 6 ? 120 : tracker.size() * 20)); + int y = pos.getAbsY(event.resolution, (int) (10 + Math.ceil(tracker.size() / 5d) * 20)); Gui.drawRect(startPos, y, startPos + 120, y + 10, -1072689136); - mc.fontRendererObj.drawString( - "Tracker", - startPos + 4, - y + 1, - 0xffffff, - false - ); + mc.fontRendererObj.drawString("Tracker", startPos + 4, y + 1, 0xffffff, false); y += 10; Gui.drawRect( startPos, y, - startPos + - (tracker.size() >= 6 ? 120 : tracker.size() * 20), + startPos + (tracker.size() >= 6 ? 120 : tracker.size() * 20), (int) (y + (Math.ceil(tracker.size() / 5d) * 20)), 1610612736 ); @@ -170,9 +127,7 @@ public class TrackerHandler { GlStateManager.disableBlend(); mc.fontRendererObj.drawStringWithShadow( s, - (float) ( - x + 19 - 2 - mc.fontRendererObj.getStringWidth(s) - ), + (float) (x + 19 - 2 - mc.fontRendererObj.getStringWidth(s)), (float) (y + 9), stack.stackSize < 1 ? 16733525 : 16777215 ); -- cgit From 98ee5a2ae8090c061b1e61e7955d793416991822 Mon Sep 17 00:00:00 2001 From: TymanWasTaken Date: Tue, 6 Jul 2021 17:24:20 -0400 Subject: 140? --- .prettierrc.yml | 2 +- .../skyblockhud/ComponentHandler.java | 47 ++----- .../com/thatgravyboat/skyblockhud/GuiTextures.java | 28 +--- .../com/thatgravyboat/skyblockhud/SkyblockHud.java | 21 +-- .../java/com/thatgravyboat/skyblockhud/Utils.java | 66 ++------- .../skyblockhud/api/LeaderboardGetter.java | 9 +- .../skyblockhud/config/SBHConfig.java | 14 +- .../skyblockhud/config/SBHConfigEditor.java | 75 +++------- .../skyblockhud/core/GuiElementBoolean.java | 7 +- .../skyblockhud/core/GuiElementColour.java | 64 ++------- .../skyblockhud/core/GuiElementTextField.java | 42 ++---- .../core/config/gui/GuiOptionEditor.java | 10 +- .../core/config/gui/GuiOptionEditorButton.java | 14 +- .../config/gui/GuiOptionEditorDraggableList.java | 24 +--- .../core/config/gui/GuiOptionEditorDropdown.java | 61 ++------ .../core/config/gui/GuiOptionEditorSlider.java | 18 +-- .../core/config/gui/GuiOptionEditorText.java | 13 +- .../core/config/struct/ConfigProcessor.java | 42 ++---- .../skyblockhud/core/util/GuiElementSlider.java | 8 +- .../skyblockhud/core/util/MiscUtils.java | 4 +- .../skyblockhud/core/util/render/RenderUtils.java | 28 +--- .../core/util/render/TextRenderUtils.java | 29 +--- .../skyblockhud/dungeons/DungeonHandler.java | 25 +--- .../skyblockhud/handlers/HeldItemHandler.java | 8 +- .../skyblockhud/handlers/MapHandler.java | 87 ++---------- .../skyblockhud/handlers/SlayerHandler.java | 4 +- .../skyblockhud/handlers/TimeHandler.java | 7 +- .../handlers/sbentities/EntityTypeHelper.java | 5 +- .../skyblockhud/location/DwarvenMineHandler.java | 36 +---- .../skyblockhud/location/EndIslandHandler.java | 4 +- .../skyblockhud/mixins/MixinEndermanRenderer.java | 10 +- .../skyblockhud/overlay/DungeonOverlay.java | 87 ++---------- .../skyblockhud/overlay/GenericOverlays.java | 14 +- .../skyblockhud/overlay/OverlayHud.java | 154 +++------------------ .../thatgravyboat/skyblockhud/overlay/RPGHud.java | 50 +------ .../skyblockhud/playerstats/ActionBarParsing.java | 18 +-- .../skyblockhud/seasons/SeasonDateHandler.java | 7 +- .../skyblockhud/tracker/TrackerFileLoader.java | 29 +--- .../skyblockhud/tracker/TrackerHandler.java | 11 +- 39 files changed, 201 insertions(+), 981 deletions(-) (limited to 'src/main/java/com/thatgravyboat/skyblockhud/overlay/DungeonOverlay.java') diff --git a/.prettierrc.yml b/.prettierrc.yml index 38071d1..ddd6ee5 100644 --- a/.prettierrc.yml +++ b/.prettierrc.yml @@ -6,4 +6,4 @@ overrides: trailingComma: none tabWidth: 4 endOfLine: lf - printWidth: 120 \ No newline at end of file + printWidth: 140 \ No newline at end of file diff --git a/src/main/java/com/thatgravyboat/skyblockhud/ComponentHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/ComponentHandler.java index 0f4713f..ad7b1e8 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/ComponentHandler.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/ComponentHandler.java @@ -33,8 +33,7 @@ public class ComponentHandler { boolean eventPass = false; if (mc.theWorld != null) { List players = sortingList.sortedCopy(mc.thePlayer.sendQueue.getPlayerInfoMap()); - GuiIngameForge.renderObjective = - !SkyblockHud.hasSkyblockScoreboard() || !SkyblockHud.config.misc.hideScoreboard; + GuiIngameForge.renderObjective = !SkyblockHud.hasSkyblockScoreboard() || !SkyblockHud.config.misc.hideScoreboard; if (players != null && SkyblockHud.hasSkyblockScoreboard()) { if (ticksExisted % 60 == 0) { for (NetworkPlayerInfo player : players) { @@ -43,33 +42,24 @@ public class ComponentHandler { .matcher(Utils.removeColor(player.getDisplayName().getFormattedText())) .replaceAll(""); if (LocationHandler.getCurrentLocation().equals(Locations.CATACOMBS)) { - if ( - formattedTabListPlayer.toLowerCase().contains("secrets found:") - ) DungeonHandler.parseTotalSecrets(formattedTabListPlayer); - if ( - formattedTabListPlayer.toLowerCase().contains("deaths:") - ) DungeonHandler.parseDeaths(formattedTabListPlayer); - if ( - formattedTabListPlayer.toLowerCase().contains("crypts:") - ) DungeonHandler.parseCrypts(formattedTabListPlayer); - } else if ( - LocationHandler.getCurrentLocation().getCategory().equals(LocationCategory.DWARVENMINES) - ) { + if (formattedTabListPlayer.toLowerCase().contains("secrets found:")) DungeonHandler.parseTotalSecrets( + formattedTabListPlayer + ); + if (formattedTabListPlayer.toLowerCase().contains("deaths:")) DungeonHandler.parseDeaths( + formattedTabListPlayer + ); + if (formattedTabListPlayer.toLowerCase().contains("crypts:")) DungeonHandler.parseCrypts( + formattedTabListPlayer + ); + } else if (LocationHandler.getCurrentLocation().getCategory().equals(LocationCategory.DWARVENMINES)) { if (formattedTabListPlayer.toLowerCase().contains("mithril powder:")) { DwarvenMineHandler.parseMithril(formattedTabListPlayer); } - } else if ( - LocationHandler - .getCurrentLocation() - .getCategory() - .equals(LocationCategory.MUSHROOMDESERT) - ) { + } else if (LocationHandler.getCurrentLocation().getCategory().equals(LocationCategory.MUSHROOMDESERT)) { if (formattedTabListPlayer.toLowerCase().contains("pelts:")) { try { FarmingIslandHandler.pelts = - Integer.parseInt( - formattedTabListPlayer.toLowerCase().replace("pelts:", "").trim() - ); + Integer.parseInt(formattedTabListPlayer.toLowerCase().replace("pelts:", "").trim()); } catch (Exception ignored) {} } } @@ -85,16 +75,9 @@ public class ComponentHandler { if (i < 80) { if (players.get(i + 1).getDisplayName() != null) { String secondLine = SCOREBOARD_CHARACTERS - .matcher( - Utils.removeColor( - players.get(i + 1).getDisplayName().getFormattedText() - ) - ) + .matcher(Utils.removeColor(players.get(i + 1).getDisplayName().getFormattedText())) .replaceAll(""); - SeasonDateHandler.setCurrentEvent( - formattedTabListPlayer.replace("Event:", ""), - secondLine - ); + SeasonDateHandler.setCurrentEvent(formattedTabListPlayer.replace("Event:", ""), secondLine); eventPass = true; } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/GuiTextures.java b/src/main/java/com/thatgravyboat/skyblockhud/GuiTextures.java index af6b49c..9198433 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/GuiTextures.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/GuiTextures.java @@ -20,27 +20,13 @@ public class GuiTextures { public static final ResourceLocation THREE = new ResourceLocation("skyblockhud:core/toggle_3.png"); public static final ResourceLocation ON = new ResourceLocation("skyblockhud:core/toggle_on.png"); - public static final ResourceLocation slider_off_cap = new ResourceLocation( - "skyblockhud:core/slider/slider_off_cap.png" - ); - public static final ResourceLocation slider_off_notch = new ResourceLocation( - "skyblockhud:core/slider/slider_off_notch.png" - ); - public static final ResourceLocation slider_off_segment = new ResourceLocation( - "skyblockhud:core/slider/slider_off_segment.png" - ); - public static final ResourceLocation slider_on_cap = new ResourceLocation( - "skyblockhud:core/slider/slider_on_cap.png" - ); - public static final ResourceLocation slider_on_notch = new ResourceLocation( - "skyblockhud:core/slider/slider_on_notch.png" - ); - public static final ResourceLocation slider_on_segment = new ResourceLocation( - "skyblockhud:core/slider/slider_on_segment.png" - ); - public static final ResourceLocation slider_button_new = new ResourceLocation( - "skyblockhud:core/slider/slider_button.png" - ); + public static final ResourceLocation slider_off_cap = new ResourceLocation("skyblockhud:core/slider/slider_off_cap.png"); + public static final ResourceLocation slider_off_notch = new ResourceLocation("skyblockhud:core/slider/slider_off_notch.png"); + public static final ResourceLocation slider_off_segment = new ResourceLocation("skyblockhud:core/slider/slider_off_segment.png"); + public static final ResourceLocation slider_on_cap = new ResourceLocation("skyblockhud:core/slider/slider_on_cap.png"); + public static final ResourceLocation slider_on_notch = new ResourceLocation("skyblockhud:core/slider/slider_on_notch.png"); + public static final ResourceLocation slider_on_segment = new ResourceLocation("skyblockhud:core/slider/slider_on_segment.png"); + public static final ResourceLocation slider_button_new = new ResourceLocation("skyblockhud:core/slider/slider_button.png"); public static final ResourceLocation overlay = new ResourceLocation("skyblockhud", "stats.png"); public static final ResourceLocation dungeon = new ResourceLocation("skyblockhud", "dungeon.png"); diff --git a/src/main/java/com/thatgravyboat/skyblockhud/SkyblockHud.java b/src/main/java/com/thatgravyboat/skyblockhud/SkyblockHud.java index 8cd8baf..071d120 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/SkyblockHud.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/SkyblockHud.java @@ -51,10 +51,7 @@ public class SkyblockHud { private File configFile; - private static final Set SKYBLOCK_IN_ALL_LANGUAGES = Sets.newHashSet( - "SKYBLOCK", - "\u7A7A\u5C9B\u751F\u5B58" - ); + private static final Set SKYBLOCK_IN_ALL_LANGUAGES = Sets.newHashSet("SKYBLOCK", "\u7A7A\u5C9B\u751F\u5B58"); private final Gson gson = new GsonBuilder().setPrettyPrinting().excludeFieldsWithoutExposeAnnotation().create(); @@ -90,9 +87,7 @@ public class SkyblockHud { if (configFile.exists()) { try ( - BufferedReader reader = new BufferedReader( - new InputStreamReader(new FileInputStream(configFile), StandardCharsets.UTF_8) - ) + BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(configFile), StandardCharsets.UTF_8)) ) { config = gson.fromJson(reader, SBHConfig.class); } catch (Exception ignored) {} @@ -114,9 +109,7 @@ public class SkyblockHud { configFile.createNewFile(); try ( - BufferedWriter writer = new BufferedWriter( - new OutputStreamWriter(new FileOutputStream(configFile), StandardCharsets.UTF_8) - ) + BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(configFile), StandardCharsets.UTF_8)) ) { writer.write(gson.toJson(config)); } @@ -181,13 +174,7 @@ public class SkyblockHud { @SubscribeEvent(priority = EventPriority.HIGHEST) public void onStatusBar(ClientChatReceivedEvent event) { - if ( - Utils - .removeColor(event.message.getUnformattedText()) - .toLowerCase() - .trim() - .startsWith("your profile was changed to:") - ) { + if (Utils.removeColor(event.message.getUnformattedText()).toLowerCase().trim().startsWith("your profile was changed to:")) { MinecraftForge.EVENT_BUS.post(new ProfileSwitchedEvent()); } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/Utils.java b/src/main/java/com/thatgravyboat/skyblockhud/Utils.java index f03c6c0..56b5f56 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/Utils.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/Utils.java @@ -39,12 +39,7 @@ public class Utils { public static boolean isPlayerHoldingRedstone(EntityPlayerSP player) { if (!SkyblockHud.config.main.requireRedstone) return true; ArrayList redstoneItems = new ArrayList<>( - Arrays.asList( - Items.redstone, - Items.repeater, - Items.comparator, - Item.getByNameOrId("minecraft:redstone_torch") - ) + Arrays.asList(Items.redstone, Items.repeater, Items.comparator, Item.getByNameOrId("minecraft:redstone_torch")) ); if (player.getHeldItem() != null) return redstoneItems.contains(player.getHeldItem().getItem()); return false; @@ -138,15 +133,7 @@ public class Utils { return (shouldRender && ((type == null && Loader.isModLoaded("labymod")) || type == checkType)); } - public static void drawStringScaledMaxWidth( - String str, - FontRenderer fr, - float x, - float y, - boolean shadow, - int len, - int colour - ) { + public static void drawStringScaledMaxWidth(String str, FontRenderer fr, float x, float y, boolean shadow, int len, int colour) { int strLen = fr.getStringWidth(str); float factor = len / (float) strLen; factor = Math.min(1, factor); @@ -154,29 +141,13 @@ public class Utils { drawStringScaled(str, fr, x, y, shadow, colour, factor); } - public static void drawStringScaled( - String str, - FontRenderer fr, - float x, - float y, - boolean shadow, - int colour, - float factor - ) { + public static void drawStringScaled(String str, FontRenderer fr, float x, float y, boolean shadow, int colour, float factor) { GlStateManager.scale(factor, factor, 1); fr.drawString(str, x / factor, y / factor, colour, shadow); GlStateManager.scale(1 / factor, 1 / factor, 1); } - public static void drawStringCenteredScaled( - String str, - FontRenderer fr, - float x, - float y, - boolean shadow, - int len, - int colour - ) { + public static void drawStringCenteredScaled(String str, FontRenderer fr, float x, float y, boolean shadow, int len, int colour) { int strLen = fr.getStringWidth(str); float factor = len / (float) strLen; float fontHeight = 8 * factor; @@ -197,12 +168,7 @@ public class Utils { ) { GlStateManager.enableTexture2D(); GlStateManager.enableBlend(); - GL14.glBlendFuncSeparate( - GL11.GL_SRC_ALPHA, - GL11.GL_ONE_MINUS_SRC_ALPHA, - GL11.GL_ONE, - GL11.GL_ONE_MINUS_SRC_ALPHA - ); + GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, filter); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, filter); @@ -230,16 +196,7 @@ public class Utils { drawTexturedRect(x, y, width, height, 0, 1, 0, 1, filter); } - public static void drawTexturedRect( - float x, - float y, - float width, - float height, - float uMin, - float uMax, - float vMin, - float vMax - ) { + public static void drawTexturedRect(float x, float y, float width, float height, float uMin, float uMax, float vMin, float vMax) { drawTexturedRect(x, y, width, height, uMin, uMax, vMin, vMax, GL11.GL_LINEAR); } @@ -271,9 +228,7 @@ public class Utils { } } - int newScale = guiScales.size() > 0 - ? Math.max(0, Math.min(4, guiScales.peek())) - : Minecraft.getMinecraft().gameSettings.guiScale; + int newScale = guiScales.size() > 0 ? Math.max(0, Math.min(4, guiScales.peek())) : Minecraft.getMinecraft().gameSettings.guiScale; if (newScale == 0) newScale = Minecraft.getMinecraft().gameSettings.guiScale; int oldScale = Minecraft.getMinecraft().gameSettings.guiScale; @@ -282,12 +237,7 @@ public class Utils { Minecraft.getMinecraft().gameSettings.guiScale = oldScale; if (guiScales.size() > 0) { - GlStateManager.viewport( - 0, - 0, - Minecraft.getMinecraft().displayWidth, - Minecraft.getMinecraft().displayHeight - ); + GlStateManager.viewport(0, 0, Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight); GlStateManager.matrixMode(GL11.GL_PROJECTION); GlStateManager.loadIdentity(); GlStateManager.ortho( diff --git a/src/main/java/com/thatgravyboat/skyblockhud/api/LeaderboardGetter.java b/src/main/java/com/thatgravyboat/skyblockhud/api/LeaderboardGetter.java index 8d6002b..db9ad38 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/api/LeaderboardGetter.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/api/LeaderboardGetter.java @@ -35,14 +35,9 @@ public class LeaderboardGetter { Scoreboard scoreboard = mc.theWorld.getScoreboard(); ScoreObjective sidebarObjective = scoreboard.getObjectiveInDisplaySlot(1); - if ( - sidebarObjective != null && - !MinecraftForge.EVENT_BUS.post(new SidebarPreGetEvent(scoreboard, sidebarObjective)) - ) { + if (sidebarObjective != null && !MinecraftForge.EVENT_BUS.post(new SidebarPreGetEvent(scoreboard, sidebarObjective))) { Collection scoreList = sidebarObjective.getScoreboard().getSortedScores(sidebarObjective); - Map scores = scoreList - .stream() - .collect(Collectors.toMap(Score::getScorePoints, this::getLine)); + Map scores = scoreList.stream().collect(Collectors.toMap(Score::getScorePoints, this::getLine)); if (!cachedScores.equals(scores)) { scores.forEach( diff --git a/src/main/java/com/thatgravyboat/skyblockhud/config/SBHConfig.java b/src/main/java/com/thatgravyboat/skyblockhud/config/SBHConfig.java index 84e5483..c8f6d53 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/config/SBHConfig.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/config/SBHConfig.java @@ -21,9 +21,7 @@ public class SBHConfig extends Config { height, () -> {}, () -> {}, - () -> - SkyblockHud.screenToOpen = - new GuiScreenElementWrapper(new SBHConfigEditor(SkyblockHud.config, activeConfig)) + () -> SkyblockHud.screenToOpen = new GuiScreenElementWrapper(new SBHConfigEditor(SkyblockHud.config, activeConfig)) ) ); } @@ -113,10 +111,7 @@ public class SBHConfig extends Config { public Position mainHudPos = new Position(0, 1, true, false); @Expose - @ConfigOption( - name = "Twelve Hour Clock", - desc = "Allows you to change the clock to be 12 hour instead of 24 hour." - ) + @ConfigOption(name = "Twelve Hour Clock", desc = "Allows you to change the clock to be 12 hour instead of 24 hour.") @ConfigEditorBoolean public boolean twelveHourClock = false; @@ -196,10 +191,7 @@ public class SBHConfig extends Config { public boolean hideDungeonPlayers = false; @Expose - @ConfigOption( - name = "Dungeon Player Opacity", - desc = "Allows you to change the opacity of the dungeon players." - ) + @ConfigOption(name = "Dungeon Player Opacity", desc = "Allows you to change the opacity of the dungeon players.") @ConfigEditorSlider(minValue = 0, maxValue = 100, minStep = 1) @ConfigAccordionId(id = 1) public int dungeonPlayerOpacity = 0; diff --git a/src/main/java/com/thatgravyboat/skyblockhud/config/SBHConfigEditor.java b/src/main/java/com/thatgravyboat/skyblockhud/config/SBHConfigEditor.java index 3bac8ac..7dee8e6 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/config/SBHConfigEditor.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/config/SBHConfigEditor.java @@ -30,10 +30,7 @@ import org.lwjgl.opengl.GL11; public class SBHConfigEditor extends GuiElement { private static final ResourceLocation[] socialsIco = new ResourceLocation[] { DISCORD, TWITTER }; - private static final String[] socialsLink = new String[] { - "https://discord.gg/moulberry", - "https://twitter.com/thatgravytboat/" - }; + private static final String[] socialsLink = new String[] { "https://discord.gg/moulberry", "https://twitter.com/thatgravytboat/" }; private final long openedMillis; @@ -89,9 +86,7 @@ public class SBHConfigEditor extends GuiElement { return new LinkedHashMap<>(processedConfig); } - private LinkedHashMap getOptionsInCategory( - ConfigProcessor.ProcessedCategory cat - ) { + private LinkedHashMap getOptionsInCategory(ConfigProcessor.ProcessedCategory cat) { return new LinkedHashMap<>(cat.options); } @@ -217,10 +212,7 @@ public class SBHConfigEditor extends GuiElement { TextRenderUtils.drawStringCenteredScaledMaxWidth(catName, fr, x + 75, y + 70 + catY, false, 100, -1); catY += 15; if (catY > 0) { - catBarSize = - LerpUtils.clampZeroOne( - (float) (innerBottom - innerTop - 2) / (catY + 5 + categoryScroll.getValue()) - ); + catBarSize = LerpUtils.clampZeroOne((float) (innerBottom - innerTop - 2) / (catY + 5 + categoryScroll.getValue())); } } @@ -231,16 +223,12 @@ public class SBHConfigEditor extends GuiElement { if (categoryScroll.getTarget() / (float) (catY + categoryScroll.getValue()) + catBarSize < 1) { int target = optionsScroll.getTarget(); categoryScroll.setValue( - (int) Math.ceil( - (catY + 5 + categoryScroll.getValue()) - catBarSize * (catY + 5 + categoryScroll.getValue()) - ) + (int) Math.ceil((catY + 5 + categoryScroll.getValue()) - catBarSize * (catY + 5 + categoryScroll.getValue())) ); categoryScroll.setTarget(target); } else { categoryScroll.setValue( - (int) Math.ceil( - (catY + 5 + categoryScroll.getValue()) - catBarSize * (catY + 5 + categoryScroll.getValue()) - ) + (int) Math.ceil((catY + 5 + categoryScroll.getValue()) - catBarSize * (catY + 5 + categoryScroll.getValue())) ); } } @@ -322,10 +310,7 @@ public class SBHConfigEditor extends GuiElement { } GlStateManager.disableDepth(); if (optionY > 0) { - barSize = - LerpUtils.clampZeroOne( - (float) (innerBottom - innerTop - 2) / (optionY + 5 + optionsScroll.getValue()) - ); + barSize = LerpUtils.clampZeroOne((float) (innerBottom - innerTop - 2) / (optionY + 5 + optionsScroll.getValue())); } } @@ -360,15 +345,8 @@ public class SBHConfigEditor extends GuiElement { } } int optionHeight = editor.getHeight(); - if ( - innerTop + 5 + optionYOverlay + optionHeight > innerTop + 1 && - innerTop + 5 + optionYOverlay < innerBottom - 1 - ) { - editor.renderOverlay( - (innerLeft + innerRight - optionWidth) / 2 - 5, - innerTop + 5 + optionYOverlay, - optionWidth - ); + if (innerTop + 5 + optionYOverlay + optionHeight > innerTop + 1 && innerTop + 5 + optionYOverlay < innerBottom - 1) { + editor.renderOverlay((innerLeft + innerRight - optionWidth) / 2 - 5, innerTop + 5 + optionYOverlay, optionWidth); } optionYOverlay += optionHeight + 5; } @@ -384,16 +362,12 @@ public class SBHConfigEditor extends GuiElement { if (optionsScroll.getTarget() / (float) (optionY + optionsScroll.getValue()) + barSize < 1) { int target = optionsScroll.getTarget(); optionsScroll.setValue( - (int) Math.ceil( - (optionY + 5 + optionsScroll.getValue()) - barSize * (optionY + 5 + optionsScroll.getValue()) - ) + (int) Math.ceil((optionY + 5 + optionsScroll.getValue()) - barSize * (optionY + 5 + optionsScroll.getValue())) ); optionsScroll.setTarget(target); } else { optionsScroll.setValue( - (int) Math.ceil( - (optionY + 5 + optionsScroll.getValue()) - barSize * (optionY + 5 + optionsScroll.getValue()) - ) + (int) Math.ceil((optionY + 5 + optionsScroll.getValue()) - barSize * (optionY + 5 + optionsScroll.getValue())) ); } } @@ -415,9 +389,7 @@ public class SBHConfigEditor extends GuiElement { if (mouseX >= socialLeft && mouseX <= socialLeft + 16 && mouseY >= y + 6 && mouseY <= y + 23) { tooltipToDisplay = - Lists.newArrayList( - EnumChatFormatting.YELLOW + "Go to: " + EnumChatFormatting.RESET + socialsLink[socialIndex] - ); + Lists.newArrayList(EnumChatFormatting.YELLOW + "Go to: " + EnumChatFormatting.RESET + socialsLink[socialIndex]); } } @@ -465,16 +437,14 @@ public class SBHConfigEditor extends GuiElement { float catBarSize = 1; int catY = -newTarget; - for (Map.Entry entry : getCurrentConfigEditing() - .entrySet()) { + for (Map.Entry entry : getCurrentConfigEditing().entrySet()) { if (getSelectedCategory() == null) { setSelectedCategory(entry.getKey()); } catY += 15; if (catY > 0) { - catBarSize = - LerpUtils.clampZeroOne((float) (innerBottom - innerTop - 2) / (catY + 5 + newTarget)); + catBarSize = LerpUtils.clampZeroOne((float) (innerBottom - innerTop - 2) / (catY + 5 + newTarget)); } } @@ -519,10 +489,7 @@ public class SBHConfigEditor extends GuiElement { optionY += editor.getHeight() + 5; if (optionY > 0) { - barSize = - LerpUtils.clampZeroOne( - (float) (innerBottom - innerTop - 2) / (optionY + 5 + newTarget) - ); + barSize = LerpUtils.clampZeroOne((float) (innerBottom - innerTop - 2) / (optionY + 5 + newTarget)); } } } @@ -531,26 +498,18 @@ public class SBHConfigEditor extends GuiElement { if (newTarget > barMax) { newTarget = barMax; } - optionsScroll.setTimeToReachTarget( - Math.min(150, Math.max(10, 5 * Math.abs(newTarget - optionsScroll.getValue()))) - ); + optionsScroll.setTimeToReachTarget(Math.min(150, Math.max(10, 5 * Math.abs(newTarget - optionsScroll.getValue())))); optionsScroll.resetTimer(); optionsScroll.setTarget(newTarget); } } else if (Mouse.getEventButtonState() && Mouse.getEventButton() == 0) { if (getCurrentConfigEditing() != null) { int catY = -categoryScroll.getValue(); - for (Map.Entry entry : getCurrentConfigEditing() - .entrySet()) { + for (Map.Entry entry : getCurrentConfigEditing().entrySet()) { if (getSelectedCategory() == null) { setSelectedCategory(entry.getKey()); } - if ( - mouseX >= x + 5 && - mouseX <= x + 145 && - mouseY >= y + 70 + catY - 7 && - mouseY <= y + 70 + catY + 7 - ) { + if (mouseX >= x + 5 && mouseX <= x + 145 && mouseY >= y + 70 + catY - 7 && mouseY <= y + 70 + catY + 7) { setSelectedCategory(entry.getKey()); return true; } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElementBoolean.java b/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElementBoolean.java index e41b7b3..8daf4b1 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElementBoolean.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElementBoolean.java @@ -96,12 +96,7 @@ public class GuiElementBoolean extends GuiElement { @Override public boolean mouseInput(int mouseX, int mouseY) { - if ( - mouseX > x - clickRadius && - mouseX < x + xSize + clickRadius && - mouseY > y - clickRadius && - mouseY < y + ySize + clickRadius - ) { + if (mouseX > x - clickRadius && mouseX < x + xSize + clickRadius && mouseY > y - clickRadius && mouseY < y + ySize + clickRadius) { if (Mouse.getEventButton() == 0) { if (Mouse.getEventButtonState()) { previewValue = !value; diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElementColour.java b/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElementColour.java index a7db23b..7f8b9ba 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElementColour.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElementColour.java @@ -18,26 +18,14 @@ import org.lwjgl.opengl.GL11; public class GuiElementColour extends GuiElement { - public static final ResourceLocation colour_selector_dot = new ResourceLocation( - "skyblockhud:core/colour_selector_dot.png" - ); - public static final ResourceLocation colour_selector_bar = new ResourceLocation( - "skyblockhud:core/colour_selector_bar.png" - ); - public static final ResourceLocation colour_selector_bar_alpha = new ResourceLocation( - "skyblockhud:core/colour_selector_bar_alpha.png" - ); - public static final ResourceLocation colour_selector_chroma = new ResourceLocation( - "skyblockhud:core/colour_selector_chroma.png" - ); + public static final ResourceLocation colour_selector_dot = new ResourceLocation("skyblockhud:core/colour_selector_dot.png"); + public static final ResourceLocation colour_selector_bar = new ResourceLocation("skyblockhud:core/colour_selector_bar.png"); + public static final ResourceLocation colour_selector_bar_alpha = new ResourceLocation("skyblockhud:core/colour_selector_bar_alpha.png"); + public static final ResourceLocation colour_selector_chroma = new ResourceLocation("skyblockhud:core/colour_selector_chroma.png"); private static final ResourceLocation colourPickerLocation = new ResourceLocation("mbcore:dynamic/colourpicker"); - private static final ResourceLocation colourPickerBarValueLocation = new ResourceLocation( - "mbcore:dynamic/colourpickervalue" - ); - private static final ResourceLocation colourPickerBarOpacityLocation = new ResourceLocation( - "mbcore:dynamic/colourpickeropacity" - ); + private static final ResourceLocation colourPickerBarValueLocation = new ResourceLocation("mbcore:dynamic/colourpickervalue"); + private static final ResourceLocation colourPickerBarOpacityLocation = new ResourceLocation("mbcore:dynamic/colourpickeropacity"); private final GuiElementTextField hexField = new GuiElementTextField( "", GuiElementTextField.SCALE_TEXT | GuiElementTextField.FORCE_CAPS | GuiElementTextField.NO_SPACE @@ -57,13 +45,7 @@ public class GuiElementColour extends GuiElement { private Runnable closeCallback; private String colour; - public GuiElementColour( - int x, - int y, - String initialColour, - Consumer colourChangedCallback, - Runnable closeCallback - ) { + public GuiElementColour(int x, int y, String initialColour, Consumer colourChangedCallback, Runnable closeCallback) { final ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); this.y = Math.max(10, Math.min(scaledResolution.getScaledHeight() - ySize - 10, y)); @@ -147,18 +129,12 @@ public class GuiElementColour extends GuiElement { GlStateManager.color(1, 1, 1, 1); RenderUtils.drawTexturedRect(x + 5 + 64 + 5 + 10 + 5, y + 5, 10, 64, GL11.GL_NEAREST); - Minecraft - .getMinecraft() - .getTextureManager() - .loadTexture(colourPickerBarValueLocation, new DynamicTexture(bufferedImageValue)); + Minecraft.getMinecraft().getTextureManager().loadTexture(colourPickerBarValueLocation, new DynamicTexture(bufferedImageValue)); Minecraft.getMinecraft().getTextureManager().bindTexture(colourPickerBarValueLocation); GlStateManager.color(1, 1, 1, 1); RenderUtils.drawTexturedRect(x + 5 + 64 + 5, y + 5, 10, 64, GL11.GL_NEAREST); - Minecraft - .getMinecraft() - .getTextureManager() - .loadTexture(colourPickerBarOpacityLocation, new DynamicTexture(bufferedImageOpacity)); + Minecraft.getMinecraft().getTextureManager().loadTexture(colourPickerBarOpacityLocation, new DynamicTexture(bufferedImageOpacity)); Minecraft.getMinecraft().getTextureManager().bindTexture(colourPickerBarOpacityLocation); GlStateManager.color(1, 1, 1, 1); RenderUtils.drawTexturedRect(x + 5 + 64 + 5 + 10 + 5, y + 5, 10, 64, GL11.GL_NEAREST); @@ -182,11 +158,7 @@ public class GuiElementColour extends GuiElement { y + 5 + 27 + 1, x + 5 + 64 + 5 + 10 + 5 + 10 + 5 + 10 - 1, y + 5 + 37 - 1, - Color.HSBtoRGB( - (hsvChroma[0] + (System.currentTimeMillis() - ChromaColour.startTime) / 1000f) % 1, - 0.8f, - 0.8f - ) + Color.HSBtoRGB((hsvChroma[0] + (System.currentTimeMillis() - ChromaColour.startTime) / 1000f) % 1, 0.8f, 0.8f) ); } @@ -226,10 +198,7 @@ public class GuiElementColour extends GuiElement { ); } - Minecraft - .getMinecraft() - .getTextureManager() - .loadTexture(colourPickerLocation, new DynamicTexture(bufferedImage)); + Minecraft.getMinecraft().getTextureManager().loadTexture(colourPickerLocation, new DynamicTexture(bufferedImage)); Minecraft.getMinecraft().getTextureManager().bindTexture(colourPickerLocation); GlStateManager.color(1, 1, 1, 1); RenderUtils.drawTexturedRect(x + 1, y + 1, 72, 72, GL11.GL_LINEAR); @@ -283,9 +252,7 @@ public class GuiElementColour extends GuiElement { public boolean mouseInput(int mouseX, int mouseY) { ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); - float mouseXF = (float) ( - Mouse.getX() * scaledResolution.getScaledWidth_double() / Minecraft.getMinecraft().displayWidth - ); + float mouseXF = (float) (Mouse.getX() * scaledResolution.getScaledWidth_double() / Minecraft.getMinecraft().displayWidth); float mouseYF = (float) ( scaledResolution.getScaledHeight_double() - Mouse.getY() * @@ -366,9 +333,7 @@ public class GuiElementColour extends GuiElement { float angle = (float) Math.toDegrees(Math.atan((32 - xWheel) / (yWheel - 32 + 1E-5)) + Math.PI / 2); xWheel = Math.max(0, Math.min(64, xWheel)); yWheel = Math.max(0, Math.min(64, yWheel)); - float radius = (float) Math.sqrt( - ((xWheel - 32) * (xWheel - 32) + (yWheel - 32) * (yWheel - 32)) / 1024f - ); + float radius = (float) Math.sqrt(((xWheel - 32) * (xWheel - 32) + (yWheel - 32) * (yWheel - 32)) / 1024f); if (yWheel < 32) angle += 180; this.wheelAngle = angle; @@ -391,8 +356,7 @@ public class GuiElementColour extends GuiElement { } if (clickedComponent == 2) { - colour = - ChromaColour.special(ChromaColour.getSpeed(colour), 255 - Math.round(y / 64f * 255), currentColour); + colour = ChromaColour.special(ChromaColour.getSpeed(colour), 255 - Math.round(y / 64f * 255), currentColour); colourChangedCallback.accept(colour); return true; } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElementTextField.java b/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElementTextField.java index cc002b2..54db59b 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElementTextField.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElementTextField.java @@ -249,10 +249,7 @@ public class GuiElementTextField { int colorCodes = org.apache.commons.lang3.StringUtils.countMatches(textNCBeforeCursor, "\u00B6"); String textBeforeCursor = text.substring(0, textField.getSelectionEnd() + colorCodes * 2); - int numLinesBeforeCursor = org.apache.commons.lang3.StringUtils.countMatches( - textBeforeCursor, - "\n" - ); + int numLinesBeforeCursor = org.apache.commons.lang3.StringUtils.countMatches(textBeforeCursor, "\n"); String[] split = textBeforeCursor.split("\n"); int textBeforeCursorWidth; @@ -265,14 +262,11 @@ public class GuiElementTextField { } else if (split.length > 1) { thisLineBeforeCursor = split[split.length - 1]; lineBefore = split[split.length - 2]; - textBeforeCursorWidth = - Minecraft.getMinecraft().fontRendererObj.getStringWidth(thisLineBeforeCursor); + textBeforeCursorWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(thisLineBeforeCursor); } else { return; } - String trimmed = Minecraft - .getMinecraft() - .fontRendererObj.trimStringToWidth(lineBefore, textBeforeCursorWidth); + String trimmed = Minecraft.getMinecraft().fontRendererObj.trimStringToWidth(lineBefore, textBeforeCursorWidth); int linePos = strLenNoColor(trimmed); if (linePos != strLenNoColor(lineBefore)) { char after = lineBefore.charAt(linePos); @@ -283,11 +277,7 @@ public class GuiElementTextField { } } int newPos = - textField.getSelectionEnd() - - strLenNoColor(thisLineBeforeCursor) - - strLenNoColor(lineBefore) - - 1 + - linePos; + textField.getSelectionEnd() - strLenNoColor(thisLineBeforeCursor) - strLenNoColor(lineBefore) - 1 + linePos; if (GuiScreen.isShiftKeyDown()) { textField.setSelectionPos(newPos); @@ -299,10 +289,7 @@ public class GuiElementTextField { int colorCodes = org.apache.commons.lang3.StringUtils.countMatches(textNCBeforeCursor, "\u00B6"); String textBeforeCursor = text.substring(0, textField.getSelectionEnd() + colorCodes * 2); - int numLinesBeforeCursor = org.apache.commons.lang3.StringUtils.countMatches( - textBeforeCursor, - "\n" - ); + int numLinesBeforeCursor = org.apache.commons.lang3.StringUtils.countMatches(textBeforeCursor, "\n"); String[] split = textBeforeCursor.split("\n"); String thisLineBeforeCursor; @@ -312,8 +299,7 @@ public class GuiElementTextField { textBeforeCursorWidth = 0; } else if (split.length > 0) { thisLineBeforeCursor = split[split.length - 1]; - textBeforeCursorWidth = - Minecraft.getMinecraft().fontRendererObj.getStringWidth(thisLineBeforeCursor); + textBeforeCursorWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(thisLineBeforeCursor); } else { return; } @@ -321,9 +307,7 @@ public class GuiElementTextField { String[] split2 = textNoColour.split("\n"); if (split2.length > numLinesBeforeCursor + 1) { String lineAfter = split2[numLinesBeforeCursor + 1]; - String trimmed = Minecraft - .getMinecraft() - .fontRendererObj.trimStringToWidth(lineAfter, textBeforeCursorWidth); + String trimmed = Minecraft.getMinecraft().fontRendererObj.trimStringToWidth(lineAfter, textBeforeCursorWidth); int linePos = strLenNoColor(trimmed); if (linePos != strLenNoColor(lineAfter)) { char after = lineAfter.charAt(linePos); @@ -447,13 +431,8 @@ public class GuiElementTextField { for (int yOffI = 0; yOffI < texts.length; yOffI++) { int yOff = yOffI * extraSize; - if ( - isScaling() && - Minecraft.getMinecraft().fontRendererObj.getStringWidth(texts[yOffI]) > searchBarXSize - 10 - ) { - scale = - (searchBarXSize - 2) / - (float) Minecraft.getMinecraft().fontRendererObj.getStringWidth(texts[yOffI]); + if (isScaling() && Minecraft.getMinecraft().fontRendererObj.getStringWidth(texts[yOffI]) > searchBarXSize - 10) { + scale = (searchBarXSize - 2) / (float) Minecraft.getMinecraft().fontRendererObj.getStringWidth(texts[yOffI]); if (scale > 1) scale = 1; float newLen = Minecraft.getMinecraft().fontRendererObj.getStringWidth(texts[yOffI]) * scale; xStartOffset = (int) ((searchBarXSize - newLen) / 2f); @@ -495,8 +474,7 @@ public class GuiElementTextField { if (split.length <= numLinesBeforeCursor || split.length == 0) { textBeforeCursorWidth = 0; } else { - textBeforeCursorWidth = - (int) (Minecraft.getMinecraft().fontRendererObj.getStringWidth(split[split.length - 1]) * scale); + textBeforeCursorWidth = (int) (Minecraft.getMinecraft().fontRendererObj.getStringWidth(split[split.length - 1]) * scale); } Gui.drawRect( x + xStartOffset + textBeforeCursorWidth, diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditor.java b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditor.java index 85aa0b7..6cae226 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditor.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditor.java @@ -21,15 +21,7 @@ public abstract class GuiOptionEditor { FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; RenderUtils.drawFloatingRectDark(x, y, width, height, true); - TextRenderUtils.drawStringCenteredScaledMaxWidth( - option.name, - fr, - x + width / 6f, - y + 13, - true, - width / 3 - 10, - 0xc0c0c0 - ); + TextRenderUtils.drawStringCenteredScaledMaxWidth(option.name, fr, x + width / 6f, y + 13, true, width / 3 - 10, 0xc0c0c0); int maxLines = 5; float scale = 1; diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorButton.java b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorButton.java index 7868ece..d3dc74f 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorButton.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorButton.java @@ -17,12 +17,7 @@ public class GuiOptionEditorButton extends GuiOptionEditor { private String buttonText; private Config config; - public GuiOptionEditorButton( - ConfigProcessor.ProcessedOption option, - String runnableId, - String buttonText, - Config config - ) { + public GuiOptionEditorButton(ConfigProcessor.ProcessedOption option, String runnableId, String buttonText, Config config) { super(option); this.runnableId = runnableId; this.config = config; @@ -58,12 +53,7 @@ public class GuiOptionEditorButton extends GuiOptionEditor { public boolean mouseInput(int x, int y, int width, int mouseX, int mouseY) { if (Mouse.getEventButtonState()) { int height = getHeight(); - if ( - mouseX > x + width / 6 - 24 && - mouseX < x + width / 6 + 24 && - mouseY > y + height - 7 - 14 && - mouseY < y + height - 7 + 2 - ) { + if (mouseX > x + width / 6 - 24 && mouseX < x + width / 6 + 24 && mouseY > y + height - 7 - 14 && mouseY < y + height - 7 + 2) { config.executeRunnable(runnableId); return true; } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorDraggableList.java b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorDraggableList.java index 11175a3..6de0223 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorDraggableList.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorDraggableList.java @@ -74,9 +74,7 @@ public class GuiOptionEditorDraggableList extends GuiOptionEditor { ); long currentTime = System.currentTimeMillis(); - float greenBlue = LerpUtils.clampZeroOne( - ((trashHoverTime < 0 ? 250 : 0) + trashHoverTime - currentTime) / 250f - ); + float greenBlue = LerpUtils.clampZeroOne(((trashHoverTime < 0 ? 250 : 0) + trashHoverTime - currentTime) / 250f); GlStateManager.color(1, greenBlue, greenBlue, 1); Minecraft.getMinecraft().getTextureManager().bindTexture(DELETE); Utils.drawTexturedRect(x + width / 6f + 27, y + 45 - 7 - 13, 11, 14, GL11.GL_NEAREST); @@ -106,9 +104,7 @@ public class GuiOptionEditorDraggableList extends GuiOptionEditor { 0xffffffff ); } - Minecraft - .getMinecraft() - .fontRendererObj.drawString("\u2261", x + 10, y + 50 + yOff + ySize / 2f - 4, 0xffffff, true); + Minecraft.getMinecraft().fontRendererObj.drawString("\u2261", x + 10, y + 50 + yOff + ySize / 2f - 4, 0xffffff, true); } yOff += ySize; @@ -202,13 +198,7 @@ public class GuiOptionEditorDraggableList extends GuiOptionEditor { Minecraft .getMinecraft() - .fontRendererObj.drawString( - "\u2261", - dragOffsetX + mouseX, - dragOffsetY + mouseY + ySize / 2f - 4, - 0xffffff, - true - ); + .fontRendererObj.drawString("\u2261", dragOffsetX + mouseX, dragOffsetY + mouseY + ySize / 2f - 4, 0xffffff, true); } } @@ -292,13 +282,7 @@ public class GuiOptionEditorDraggableList extends GuiOptionEditor { return true; } - if ( - Mouse.getEventButton() == 0 && - mouseX > x + 5 && - mouseX < x + width - 5 && - mouseY > y + 45 && - mouseY < y + height - 6 - ) { + if (Mouse.getEventButton() == 0 && mouseX > x + 5 && mouseX < x + width - 5 && mouseY > y + 45 && mouseY < y + height - 6) { int yOff = 0; int i = 0; for (int strIndex : activeText) { diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorDropdown.java b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorDropdown.java index 43a04d7..260c2ad 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorDropdown.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorDropdown.java @@ -17,12 +17,7 @@ public class GuiOptionEditorDropdown extends GuiOptionEditor { private int selected; private boolean open = false; - public GuiOptionEditorDropdown( - ConfigProcessor.ProcessedOption option, - String[] values, - int selected, - boolean useOrdinal - ) { + public GuiOptionEditorDropdown(ConfigProcessor.ProcessedOption option, String[] values, int selected, boolean useOrdinal) { super(option); if (selected >= values.length) selected = values.length; this.values = values; @@ -48,25 +43,9 @@ public class GuiOptionEditorDropdown extends GuiOptionEditor { } RenderUtils.drawFloatingRectDark(left, top, dropdownWidth, 14, false); - TextRenderUtils.drawStringScaled( - "\u25BC", - fr, - left + dropdownWidth - 10, - y + height - 7 - 15, - false, - 0xffa0a0a0, - 2 - ); - - TextRenderUtils.drawStringScaledMaxWidth( - selectedString, - fr, - left + 3, - top + 3, - false, - dropdownWidth - 16, - 0xffa0a0a0 - ); + TextRenderUtils.drawStringScaled("\u25BC", fr, left + dropdownWidth - 10, y + height - 7 - 15, false, 0xffa0a0a0, 2); + + TextRenderUtils.drawStringScaledMaxWidth(selectedString, fr, left + 3, top + 3, false, dropdownWidth - 16, 0xffa0a0a0); } } @@ -102,37 +81,13 @@ public class GuiOptionEditorDropdown extends GuiOptionEditor { if (option.isEmpty()) { option = ""; } - TextRenderUtils.drawStringScaledMaxWidth( - option, - fr, - left + 3, - top + 3 + dropdownY, - false, - dropdownWidth - 6, - 0xffa0a0a0 - ); + TextRenderUtils.drawStringScaledMaxWidth(option, fr, left + 3, top + 3 + dropdownY, false, dropdownWidth - 6, 0xffa0a0a0); dropdownY += 12; } - TextRenderUtils.drawStringScaled( - "\u25B2", - fr, - left + dropdownWidth - 10, - y + height - 7 - 15, - false, - 0xffa0a0a0, - 2 - ); - - TextRenderUtils.drawStringScaledMaxWidth( - selectedString, - fr, - left + 3, - top + 3, - false, - dropdownWidth - 16, - 0xffa0a0a0 - ); + TextRenderUtils.drawStringScaled("\u25B2", fr, left + dropdownWidth - 10, y + height - 7 - 15, false, 0xffa0a0a0, 2); + + TextRenderUtils.drawStringScaledMaxWidth(selectedString, fr, left + 3, top + 3, false, dropdownWidth - 16, 0xffa0a0a0); } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorSlider.java b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorSlider.java index 2932e34..1e27684 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorSlider.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorSlider.java @@ -13,12 +13,7 @@ public class GuiOptionEditorSlider extends GuiOptionEditor { private final GuiElementSlider slider; private final GuiElementTextField textField; - public GuiOptionEditorSlider( - ConfigProcessor.ProcessedOption option, - float minValue, - float maxValue, - float minStep - ) { + public GuiOptionEditorSlider(ConfigProcessor.ProcessedOption option, float minValue, float maxValue, float minStep) { super(option); if (minStep < 0) minStep = 0.01f; @@ -81,9 +76,7 @@ public class GuiOptionEditorSlider extends GuiOptionEditor { textField.setSize(Minecraft.getMinecraft().fontRendererObj.getStringWidth(textField.getText()) + 10, 16); } else { textField.setSize(textFieldWidth, 16); - textField.setOptions( - GuiElementTextField.NO_SPACE | GuiElementTextField.NUM_ONLY | GuiElementTextField.SCALE_TEXT - ); + textField.setOptions(GuiElementTextField.NO_SPACE | GuiElementTextField.NUM_ONLY | GuiElementTextField.SCALE_TEXT); } textField.render(x + width / 6 - fullWidth / 2 + sliderWidth + 5, y + height - 7 - 14); @@ -114,12 +107,7 @@ public class GuiOptionEditorSlider extends GuiOptionEditor { textField.setSize(textFieldWidth, 16); if (Mouse.getEventButtonState() && (Mouse.getEventButton() == 0 || Mouse.getEventButton() == 1)) { - if ( - mouseX > textFieldX && - mouseX < textFieldX + textFieldWidth && - mouseY > textFieldY && - mouseY < textFieldY + 16 - ) { + if (mouseX > textFieldX && mouseX < textFieldX + textFieldWidth && mouseY > textFieldY && mouseY < textFieldY + 16) { textField.mouseClicked(mouseX, mouseY, Mouse.getEventButton()); return true; } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorText.java b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorText.java index da39ca1..e2f96f9 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorText.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorText.java @@ -26,8 +26,7 @@ public class GuiOptionEditorText extends GuiOptionEditor { int textFieldX = x + width / 6 - fullWidth / 2; if (textField.getFocus()) { - fullWidth = - Math.max(fullWidth, Minecraft.getMinecraft().fontRendererObj.getStringWidth(textField.getText()) + 10); + fullWidth = Math.max(fullWidth, Minecraft.getMinecraft().fontRendererObj.getStringWidth(textField.getText()) + 10); } textField.setSize(fullWidth, 16); @@ -44,20 +43,14 @@ public class GuiOptionEditorText extends GuiOptionEditor { int textFieldX = x + width / 6 - fullWidth / 2; if (textField.getFocus()) { - fullWidth = - Math.max(fullWidth, Minecraft.getMinecraft().fontRendererObj.getStringWidth(textField.getText()) + 10); + fullWidth = Math.max(fullWidth, Minecraft.getMinecraft().fontRendererObj.getStringWidth(textField.getText()) + 10); } int textFieldY = y + height - 7 - 14; textField.setSize(fullWidth, 16); if (Mouse.getEventButtonState() && (Mouse.getEventButton() == 0 || Mouse.getEventButton() == 1)) { - if ( - mouseX > textFieldX && - mouseX < textFieldX + fullWidth && - mouseY > textFieldY && - mouseY < textFieldY + 16 - ) { + if (mouseX > textFieldX && mouseX < textFieldX + fullWidth && mouseY > textFieldY && mouseY < textFieldY + 16) { textField.mouseClicked(mouseX, mouseY, Mouse.getEventButton()); return true; } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/config/struct/ConfigProcessor.java b/src/main/java/com/thatgravyboat/skyblockhud/core/config/struct/ConfigProcessor.java index e989b61..5b51f34 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/config/struct/ConfigProcessor.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/config/struct/ConfigProcessor.java @@ -106,9 +106,7 @@ public class ConfigProcessor { GuiOptionEditor editor = null; Class optionType = optionField.getType(); if (optionField.isAnnotationPresent(ConfigEditorButton.class)) { - ConfigEditorButton configEditorAnnotation = optionField.getAnnotation( - ConfigEditorButton.class - ); + ConfigEditorButton configEditorAnnotation = optionField.getAnnotation(ConfigEditorButton.class); editor = new GuiOptionEditorButton( option, @@ -117,33 +115,17 @@ public class ConfigProcessor { config ); } - if ( - optionType.isAssignableFrom(boolean.class) && - optionField.isAnnotationPresent(ConfigEditorBoolean.class) - ) { + if (optionType.isAssignableFrom(boolean.class) && optionField.isAnnotationPresent(ConfigEditorBoolean.class)) { editor = new GuiOptionEditorBoolean(option); } - if ( - optionType.isAssignableFrom(boolean.class) && - optionField.isAnnotationPresent(ConfigEditorAccordion.class) - ) { - ConfigEditorAccordion configEditorAnnotation = optionField.getAnnotation( - ConfigEditorAccordion.class - ); + if (optionType.isAssignableFrom(boolean.class) && optionField.isAnnotationPresent(ConfigEditorAccordion.class)) { + ConfigEditorAccordion configEditorAnnotation = optionField.getAnnotation(ConfigEditorAccordion.class); editor = new GuiOptionEditorAccordion(option, configEditorAnnotation.id()); } if (optionType.isAssignableFrom(int.class)) { if (optionField.isAnnotationPresent(ConfigEditorDropdown.class)) { - ConfigEditorDropdown configEditorAnnotation = optionField.getAnnotation( - ConfigEditorDropdown.class - ); - editor = - new GuiOptionEditorDropdown( - option, - configEditorAnnotation.values(), - (int) option.get(), - true - ); + ConfigEditorDropdown configEditorAnnotation = optionField.getAnnotation(ConfigEditorDropdown.class); + editor = new GuiOptionEditorDropdown(option, configEditorAnnotation.values(), (int) option.get(), true); } } if (optionType.isAssignableFrom(List.class)) { @@ -156,9 +138,7 @@ public class ConfigProcessor { } if (optionType.isAssignableFrom(String.class)) { if (optionField.isAnnotationPresent(ConfigEditorDropdown.class)) { - ConfigEditorDropdown configEditorAnnotation = optionField.getAnnotation( - ConfigEditorDropdown.class - ); + ConfigEditorDropdown configEditorAnnotation = optionField.getAnnotation(ConfigEditorDropdown.class); editor = new GuiOptionEditorDropdown( option, @@ -178,9 +158,7 @@ public class ConfigProcessor { optionType.isAssignableFrom(double.class) ) { if (optionField.isAnnotationPresent(ConfigEditorSlider.class)) { - ConfigEditorSlider configEditorAnnotation = optionField.getAnnotation( - ConfigEditorSlider.class - ); + ConfigEditorSlider configEditorAnnotation = optionField.getAnnotation(ConfigEditorSlider.class); editor = new GuiOptionEditorSlider( option, @@ -192,9 +170,7 @@ public class ConfigProcessor { } if (optionType.isAssignableFrom(String.class)) { if (optionField.isAnnotationPresent(ConfigEditorDropdown.class)) { - ConfigEditorDropdown configEditorAnnotation = optionField.getAnnotation( - ConfigEditorDropdown.class - ); + ConfigEditorDropdown configEditorAnnotation = optionField.getAnnotation(ConfigEditorDropdown.class); editor = new GuiOptionEditorDropdown(option, configEditorAnnotation.values(), 0, false); } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/util/GuiElementSlider.java b/src/main/java/com/thatgravyboat/skyblockhud/core/util/GuiElementSlider.java index fd7d3b3..bc9a694 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/util/GuiElementSlider.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/util/GuiElementSlider.java @@ -86,10 +86,7 @@ public class GuiElementSlider extends GuiElement { for (int i = 1; i < 4; i++) { int notchX = x + width * i / 4 - 1; - Minecraft - .getMinecraft() - .getTextureManager() - .bindTexture(notchX > x + sliderAmountI ? slider_off_notch : slider_on_notch); + Minecraft.getMinecraft().getTextureManager().bindTexture(notchX > x + sliderAmountI ? slider_off_notch : slider_on_notch); Utils.drawTexturedRect(notchX, y + (HEIGHT - 4) / 2f, 2, 4, GL11.GL_NEAREST); } @@ -104,8 +101,7 @@ public class GuiElementSlider extends GuiElement { } if (Mouse.getEventButton() == 0) { - clicked = - Mouse.getEventButtonState() && mouseX > x && mouseX < x + width && mouseY > y && mouseY < y + HEIGHT; + clicked = Mouse.getEventButtonState() && mouseX > x && mouseX < x + width && mouseY > y && mouseY < y + HEIGHT; if (clicked) { value = (mouseX - x) * (maxValue - minValue) / width + minValue; value = Math.max(minValue, Math.min(maxValue, value)); diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/util/MiscUtils.java b/src/main/java/com/thatgravyboat/skyblockhud/core/util/MiscUtils.java index 5c59853..0ee34a1 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/util/MiscUtils.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/util/MiscUtils.java @@ -82,9 +82,7 @@ public class MiscUtils { } currentCursor = loc.getResourcePath(); try { - BufferedImage image = ImageIO.read( - Minecraft.getMinecraft().getResourceManager().getResource(loc).getInputStream() - ); + BufferedImage image = ImageIO.read(Minecraft.getMinecraft().getResourceManager().getResource(loc).getInputStream()); int maxSize = Cursor.getMaxCursorSize(); IntBuffer buffer = BufferUtils.createIntBuffer(maxSize * maxSize); for (int i = 0; i < maxSize * maxSize; i++) { diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/util/render/RenderUtils.java b/src/main/java/com/thatgravyboat/skyblockhud/core/util/render/RenderUtils.java index 518b928..963e1f7 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/util/render/RenderUtils.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/util/render/RenderUtils.java @@ -91,16 +91,7 @@ public class RenderUtils { drawTexturedRect(x, y, width, height, 0, 1, 0, 1, filter); } - public static void drawTexturedRect( - float x, - float y, - float width, - float height, - float uMin, - float uMax, - float vMin, - float vMax - ) { + public static void drawTexturedRect(float x, float y, float width, float height, float uMin, float uMax, float vMin, float vMax) { drawTexturedRect(x, y, width, height, uMin, uMax, vMin, vMax, GL11.GL_NEAREST); } @@ -116,12 +107,7 @@ public class RenderUtils { int filter ) { GlStateManager.enableBlend(); - GL14.glBlendFuncSeparate( - GL11.GL_SRC_ALPHA, - GL11.GL_ONE_MINUS_SRC_ALPHA, - GL11.GL_ONE, - GL11.GL_ONE_MINUS_SRC_ALPHA - ); + GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); drawTexturedRectNoBlend(x, y, width, height, uMin, uMax, vMin, vMax, filter); @@ -157,15 +143,7 @@ public class RenderUtils { GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST); } - public static void drawGradientRect( - int zLevel, - int left, - int top, - int right, - int bottom, - int startColor, - int endColor - ) { + public static void drawGradientRect(int zLevel, int left, int top, int right, int bottom, int startColor, int endColor) { float startAlpha = (float) (startColor >> 24 & 255) / 255.0F; float startRed = (float) (startColor >> 16 & 255) / 255.0F; float startGreen = (float) (startColor >> 8 & 255) / 255.0F; diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/util/render/TextRenderUtils.java b/src/main/java/com/thatgravyboat/skyblockhud/core/util/render/TextRenderUtils.java index 478414e..f160c04 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/util/render/TextRenderUtils.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/util/render/TextRenderUtils.java @@ -46,15 +46,7 @@ public class TextRenderUtils { } } - public static void drawStringScaledMaxWidth( - String str, - FontRenderer fr, - float x, - float y, - boolean shadow, - int len, - int colour - ) { + public static void drawStringScaledMaxWidth(String str, FontRenderer fr, float x, float y, boolean shadow, int len, int colour) { int strLen = fr.getStringWidth(str); float factor = len / (float) strLen; factor = Math.min(1, factor); @@ -73,15 +65,7 @@ public class TextRenderUtils { GL11.glTranslatef(-x2, -y2, 0); } - public static void drawStringScaled( - String str, - FontRenderer fr, - float x, - float y, - boolean shadow, - int colour, - float factor - ) { + public static void drawStringScaled(String str, FontRenderer fr, float x, float y, boolean shadow, int colour, float factor) { GlStateManager.scale(factor, factor, 1); fr.drawString(str, x / factor, y / factor, colour, shadow); GlStateManager.scale(1 / factor, 1 / factor, 1); @@ -106,14 +90,7 @@ public class TextRenderUtils { drawStringScaled(str, fr, x - newLen / 2, y - fontHeight / 2, shadow, colour, factor); } - public static void renderToolTip( - ItemStack stack, - int mouseX, - int mouseY, - int screenWidth, - int screenHeight, - FontRenderer fontStd - ) { + public static void renderToolTip(ItemStack stack, int mouseX, int mouseY, int screenWidth, int screenHeight, FontRenderer fontStd) { List list = stack.getTooltip( Minecraft.getMinecraft().thePlayer, Minecraft.getMinecraft().gameSettings.advancedItemTooltips diff --git a/src/main/java/com/thatgravyboat/skyblockhud/dungeons/DungeonHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/dungeons/DungeonHandler.java index 4fd0fd4..aff9c1e 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/dungeons/DungeonHandler.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/dungeons/DungeonHandler.java @@ -56,12 +56,7 @@ public class DungeonHandler { healthNum = Integer.parseInt(health); } catch (NumberFormatException ignored) {} } - DungeonPlayer player = new DungeonPlayer( - playerClass, - displayName, - healthNum, - health.equalsIgnoreCase("dead") - ); + DungeonPlayer player = new DungeonPlayer(playerClass, displayName, healthNum, health.equalsIgnoreCase("dead")); dungeonPlayersMap.put(displayName.toLowerCase(), player); } } @@ -82,12 +77,7 @@ public class DungeonHandler { public static void checkForDungeonCleared(String scoreline) { if (scoreline.toLowerCase().trim().contains("dungeon cleared:")) { - String dungeonClearedText = scoreline - .toLowerCase() - .trim() - .replace("dungeon cleared:", "") - .replace(" ", "") - .replace("%", ""); + String dungeonClearedText = scoreline.toLowerCase().trim().replace("dungeon cleared:", "").replace(" ", "").replace("%", ""); try { dungeonCleared = Integer.parseInt(dungeonClearedText); } catch (NumberFormatException ignored) {} @@ -96,12 +86,7 @@ public class DungeonHandler { public static void checkForDungeonKeys(String scoreline, String rawString) { if (scoreline.toLowerCase().trim().contains("keys:")) { - String dungeonClearedText = scoreline - .toLowerCase() - .trim() - .replace("keys:", "") - .replace(" ", "") - .replace("x", ""); + String dungeonClearedText = scoreline.toLowerCase().trim().replace("keys:", "").replace(" ", "").replace("x", ""); bloodKey = rawString.contains("\u2713"); try { witherKeys = Integer.parseInt(dungeonClearedText); @@ -130,9 +115,7 @@ public class DungeonHandler { public static void parseTotalSecrets(String playerName) { if (playerName.toLowerCase().contains("secrets found:")) { - String totalSecret = Utils - .removeColor(playerName.toLowerCase().replace("secrets found:", "")) - .replace(" ", ""); + String totalSecret = Utils.removeColor(playerName.toLowerCase().replace("secrets found:", "")).replace(" ", ""); try { totalSecrets = Integer.parseInt(totalSecret); } catch (NumberFormatException ignored) {} diff --git a/src/main/java/com/thatgravyboat/skyblockhud/handlers/HeldItemHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/handlers/HeldItemHandler.java index fa0d21c..da27590 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/handlers/HeldItemHandler.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/handlers/HeldItemHandler.java @@ -14,13 +14,7 @@ public class HeldItemHandler extends Gui { public void drawFuelBar(Minecraft mc, int current, int max) { GenericOverlays.drawSmallBar(mc, 100, 100, (double) current / (double) max, 1.0d, 0xff00ff, 0xffff00, 0); - drawString( - mc.fontRendererObj, - "Fuel - " + Math.round(((double) current / (double) max) * 100) + "%", - 100, - 100, - 0xffffff - ); + drawString(mc.fontRendererObj, "Fuel - " + Math.round(((double) current / (double) max) * 100) + "%", 100, 100, 0xffffff); } public boolean isDrill(ItemStack stack) { diff --git a/src/main/java/com/thatgravyboat/skyblockhud/handlers/MapHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/handlers/MapHandler.java index 5bc90d8..c8ef43b 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/handlers/MapHandler.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/handlers/MapHandler.java @@ -68,72 +68,12 @@ public class MapHandler { public enum Maps { HUB(0.5f, 494, 444, 294, 218, 294, 224, new ResourceLocation("skyblockhud", "maps/hub.png"), HubIcons.hubIcons), - MUSHROOM( - 1.0f, - 318, - 316, - -84, - 605, - -84, - 612, - new ResourceLocation("skyblockhud", "maps/mushroom.png"), - Collections.emptyList() - ), - SPIDERS( - 1.0f, - 270, - 238, - 400, - 362, - 400, - 364, - new ResourceLocation("skyblockhud", "maps/spidersden.png"), - Collections.emptyList() - ), - NETHER( - 0.5f, - 257, - 371, - 436, - 732, - 433, - 736, - new ResourceLocation("skyblockhud", "maps/fort.png"), - Collections.emptyList() - ), - BARN( - 1.5f, - 135, - 130, - -82, - 320, - -81, - 318, - new ResourceLocation("skyblockhud", "maps/barn.png"), - Collections.emptyList() - ), - DWARVEN( - 0.5f, - 409, - 461, - 206, - 160, - 202, - 166, - new ResourceLocation("skyblockhud", "maps/dwarven.png"), - DwarvenIcons.dwarvenIcons - ), - PARK( - 1.0f, - 211, - 230, - 480, - 133, - 478, - 134, - new ResourceLocation("skyblockhud", "maps/park.png"), - Collections.emptyList() - ); + MUSHROOM(1.0f, 318, 316, -84, 605, -84, 612, new ResourceLocation("skyblockhud", "maps/mushroom.png"), Collections.emptyList()), + SPIDERS(1.0f, 270, 238, 400, 362, 400, 364, new ResourceLocation("skyblockhud", "maps/spidersden.png"), Collections.emptyList()), + NETHER(0.5f, 257, 371, 436, 732, 433, 736, new ResourceLocation("skyblockhud", "maps/fort.png"), Collections.emptyList()), + BARN(1.5f, 135, 130, -82, 320, -81, 318, new ResourceLocation("skyblockhud", "maps/barn.png"), Collections.emptyList()), + DWARVEN(0.5f, 409, 461, 206, 160, 202, 166, new ResourceLocation("skyblockhud", "maps/dwarven.png"), DwarvenIcons.dwarvenIcons), + PARK(1.0f, 211, 230, 480, 133, 478, 134, new ResourceLocation("skyblockhud", "maps/park.png"), Collections.emptyList()); public float scaleFactor; public int width; @@ -170,13 +110,7 @@ public class MapHandler { @SubscribeEvent public void renderOverlay(RenderGameOverlayEvent.Post event) { - if ( - Utils.overlayShouldRender( - event.type, - SkyblockHud.hasSkyblockScoreboard(), - SkyblockHud.config.map.showMiniMap - ) - ) { + if (Utils.overlayShouldRender(event.type, SkyblockHud.hasSkyblockScoreboard(), SkyblockHud.config.map.showMiniMap)) { Minecraft mc = Minecraft.getMinecraft(); if (mc.currentScreen instanceof MapScreen) return; if (LocationHandler.getCurrentLocation().getCategory().getMap() == null) return; @@ -298,12 +232,7 @@ public class MapHandler { if (this.mc.thePlayer != null && SkyblockHud.config.map.showPlayerLocation) { int x = this.mc.thePlayer.getPosition().getX() + map.xOffset; int z = this.mc.thePlayer.getPosition().getZ() + map.yOffset; - fontRendererObj.drawString( - "\u2022", - (int) (x * map.scaleFactor + mapX), - (int) (z * map.scaleFactor + mapY), - 0xff0000 - ); + fontRendererObj.drawString("\u2022", (int) (x * map.scaleFactor + mapX), (int) (z * map.scaleFactor + mapY), 0xff0000); } GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f); onTooltip(mouseX, mouseY, (int) mapX, (int) mapY); diff --git a/src/main/java/com/thatgravyboat/skyblockhud/handlers/SlayerHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/handlers/SlayerHandler.java index 627be26..b25733b 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/handlers/SlayerHandler.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/handlers/SlayerHandler.java @@ -82,9 +82,7 @@ public class SlayerHandler { } SlayerHandler.currentSlayer = selectedSlayer; SlayerHandler.slayerTier = - Utils.whatRomanNumeral( - slayer.replace(selectedSlayer.getDisplayName().toLowerCase(), "").replace(" ", "") - ); + Utils.whatRomanNumeral(slayer.replace(selectedSlayer.getDisplayName().toLowerCase(), "").replace(" ", "")); break; } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/handlers/TimeHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/handlers/TimeHandler.java index 91b3835..f1aa222 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/handlers/TimeHandler.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/handlers/TimeHandler.java @@ -17,12 +17,9 @@ public class TimeHandler { if (Pattern.matches("([0-9]*):([0-9]*)(pm|am)", event.formattedLine.toLowerCase().trim())) { boolean isPm = event.formattedLine.toLowerCase().trim().endsWith("pm"); SimpleDateFormat parseFormat = new SimpleDateFormat("hh:mm a", Locale.CANADA); - String currentTimeString = event.formattedLine - .replace(" ", "") - .replace(isPm ? "pm" : "am", isPm ? " pm" : " am"); + String currentTimeString = event.formattedLine.replace(" ", "").replace(isPm ? "pm" : "am", isPm ? " pm" : " am"); try { - time = - (parseFormat.parse(currentTimeString).getTime() - parseFormat.parse("00:00 am").getTime()) / 1000L; + time = (parseFormat.parse(currentTimeString).getTime() - parseFormat.parse("00:00 am").getTime()) / 1000L; } catch (ParseException ignored) { LogManager.getLogger().warn("timeformat error: " + currentTimeString); } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/handlers/sbentities/EntityTypeHelper.java b/src/main/java/com/thatgravyboat/skyblockhud/handlers/sbentities/EntityTypeHelper.java index eda0b6f..a59b0db 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/handlers/sbentities/EntityTypeHelper.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/handlers/sbentities/EntityTypeHelper.java @@ -11,10 +11,7 @@ public class EntityTypeHelper { public static boolean isZealot(Entity entity) { if (entity instanceof EntityEnderman) { EntityEnderman enderman = ((EntityEnderman) entity); - double maxHealthBase = enderman - .getAttributeMap() - .getAttributeInstanceByName("generic.maxHealth") - .getBaseValue(); + double maxHealthBase = enderman.getAttributeMap().getAttributeInstanceByName("generic.maxHealth").getBaseValue(); if ( maxHealthBase == 13000d || (maxHealthBase == 2000d && enderman.getHeldBlockState().getBlock().equals(Blocks.end_portal_frame)) diff --git a/src/main/java/com/thatgravyboat/skyblockhud/location/DwarvenMineHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/location/DwarvenMineHandler.java index 7df5667..faec015 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/location/DwarvenMineHandler.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/location/DwarvenMineHandler.java @@ -30,10 +30,7 @@ public class DwarvenMineHandler { public static int eventProgress; public static Event currentEvent; - private static final DecimalFormat formatter = new DecimalFormat( - "#,###", - DecimalFormatSymbols.getInstance(Locale.CANADA) - ); + private static final DecimalFormat formatter = new DecimalFormat("#,###", DecimalFormatSymbols.getInstance(Locale.CANADA)); public static String getMithrilFormatted() { String output = formatter.format(mithril); @@ -62,44 +59,25 @@ public class DwarvenMineHandler { } } if (DwarvenMineHandler.currentEvent != Event.NONE) { - if ( - DwarvenMineHandler.currentEvent == Event.TICKET && - event.formattedLine.toLowerCase().contains("tickets:") - ) { + if (DwarvenMineHandler.currentEvent == Event.TICKET && event.formattedLine.toLowerCase().contains("tickets:")) { if (event.formattedLine.toLowerCase().contains("pool:")) { try { - eventMax = - Integer.parseInt( - event.formattedLine.toLowerCase().replace("pool:", "").trim().split("/")[0].trim() - ); + eventMax = Integer.parseInt(event.formattedLine.toLowerCase().replace("pool:", "").trim().split("/")[0].trim()); } catch (Exception ignored) {} } else if (event.formattedLine.toLowerCase().contains("tickets:")) { try { - eventProgress = - Integer.parseInt( - event.formattedLine.toLowerCase().replace("tickets:", "").split("\\(")[0].trim() - ); + eventProgress = Integer.parseInt(event.formattedLine.toLowerCase().replace("tickets:", "").split("\\(")[0].trim()); } catch (Exception ignored) {} } } else if (DwarvenMineHandler.currentEvent == Event.GOBLIN) { if (event.formattedLine.toLowerCase().contains("remaining:")) { try { eventMax = - Integer.parseInt( - event.formattedLine - .toLowerCase() - .replace("goblins", "") - .replace("remaining:", "") - .trim() - ); + Integer.parseInt(event.formattedLine.toLowerCase().replace("goblins", "").replace("remaining:", "").trim()); } catch (Exception ignored) {} - } else if ( - event.formattedLine.toLowerCase().contains("your kills:") && - !event.formattedLine.toLowerCase().contains("(") - ) { + } else if (event.formattedLine.toLowerCase().contains("your kills:") && !event.formattedLine.toLowerCase().contains("(")) { try { - eventProgress = - Integer.parseInt(event.formattedLine.toLowerCase().replace("your kills:", "").trim()); + eventProgress = Integer.parseInt(event.formattedLine.toLowerCase().replace("your kills:", "").trim()); } catch (Exception ignored) {} } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/location/EndIslandHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/location/EndIslandHandler.java index c989cb4..505db19 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/location/EndIslandHandler.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/location/EndIslandHandler.java @@ -31,9 +31,7 @@ public class EndIslandHandler { public static dragonTypes findDragon(String input) { if (input.contains(" ")) { try { - return dragonTypes.valueOf( - input.toLowerCase().replace("dragon", "").replace(" ", "").toUpperCase() - ); + return dragonTypes.valueOf(input.toLowerCase().replace("dragon", "").replace(" ", "").toUpperCase()); } catch (IllegalArgumentException ignored) { return NODRAGON; } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinEndermanRenderer.java b/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinEndermanRenderer.java index 330b915..7363a45 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinEndermanRenderer.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinEndermanRenderer.java @@ -15,15 +15,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; public class MixinEndermanRenderer { @Inject(method = "doRender(Lnet/minecraft/entity/monster/EntityEnderman;DDDFF)V", at = @At("HEAD")) - public void onRender( - EntityEnderman entity, - double x, - double y, - double z, - float entityYaw, - float partialTicks, - CallbackInfo ci - ) { + public void onRender(EntityEnderman entity, double x, double y, double z, float entityYaw, float partialTicks, CallbackInfo ci) { if (EntityTypeHelper.isZealot(entity)) { Color color = new Color(SpecialColour.specialToChromaRGB("255:255:0:48:255")); GlStateManager.color(color.getRed() / 255f, color.getGreen() / 255f, color.getBlue() / 255f, 255f); diff --git a/src/main/java/com/thatgravyboat/skyblockhud/overlay/DungeonOverlay.java b/src/main/java/com/thatgravyboat/skyblockhud/overlay/DungeonOverlay.java index b4eb8db..462896d 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/overlay/DungeonOverlay.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/overlay/DungeonOverlay.java @@ -67,13 +67,7 @@ public class DungeonOverlay extends Gui { offset + (bossBarVisible ? 19 : 2), (DungeonHandler.hasBloodkey() ? 0x55FF55 : 0xAA0000) ); - drawString( - font, - DungeonHandler.getWitherKeys() + "x", - (width / 2), - offset + (bossBarVisible ? 30 : 13), - 0x555555 - ); + 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); @@ -83,14 +77,7 @@ public class DungeonOverlay extends Gui { (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, offset + (bossBarVisible ? 20 : 3), 2, 34, font.getStringWidth(clearPercentage) + 3, 14); drawTexturedModalRect( ((width / 2) + 17) + font.getStringWidth(clearPercentage) + 3, offset + (bossBarVisible ? 20 : 3), @@ -106,22 +93,8 @@ public class DungeonOverlay extends Gui { 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 - ); + 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 @@ -131,14 +104,7 @@ public class DungeonOverlay extends Gui { 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)) - 4, offset + (bossBarVisible ? 20 : 3), 0, 34, 2, 14); drawTexturedModalRect( ((width / 2) - 17 - (font.getStringWidth(secretsText))) - 2, offset + (bossBarVisible ? 20 : 3), @@ -147,27 +113,14 @@ public class DungeonOverlay extends Gui { font.getStringWidth(secretsText) + 2, 14 ); - drawString( - font, - secretsText, - (width / 2) - 17 - (font.getStringWidth(secretsText)), - offset + (bossBarVisible ? 23 : 6), - 0xAAAAAA - ); + 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)) - 4, offset + (bossBarVisible ? 35 : 18), 0, 34, 2, 14); drawTexturedModalRect( ((width / 2) - 17 - (font.getStringWidth(cryptText))) - 2, offset + (bossBarVisible ? 35 : 18), @@ -176,13 +129,7 @@ public class DungeonOverlay extends Gui { font.getStringWidth(cryptText) + 2, 14 ); - drawString( - font, - cryptText, - (width / 2) - 17 - (font.getStringWidth(cryptText)), - offset + (bossBarVisible ? 38 : 21), - 0xAAAAAA - ); + drawString(font, cryptText, (width / 2) - 17 - (font.getStringWidth(cryptText)), offset + (bossBarVisible ? 38 : 21), 0xAAAAAA); } public void drawUltimateBar(Minecraft mc, ScaledResolution resolution) { @@ -217,8 +164,7 @@ public class DungeonOverlay extends Gui { LocationHandler.getCurrentLocation().equals(Locations.CATACOMBS) ) ) { - bossBarVisible = - BossStatus.statusBarTime > 0 && GuiIngameForge.renderBossHealth && BossbarHandler.bossBarRendered; + bossBarVisible = BossStatus.statusBarTime > 0 && GuiIngameForge.renderBossHealth && BossbarHandler.bossBarRendered; GlStateManager.enableBlend(); drawUltimateBar(mc, event.resolution); @@ -245,21 +191,10 @@ public class DungeonOverlay extends Gui { } catch (ArrayIndexOutOfBoundsException ignored) { posY = 0; } - drawDungeonPlayer( - player.getName(), - player.getHealth(), - player.isDead(), - player.getDungeonClass(), - posX, - posY - ); + drawDungeonPlayer(player.getName(), player.getHealth(), player.isDead(), player.getDungeonClass(), posX, posY); } } - drawDungeonClock( - event.resolution.getScaledWidth(), - SkyblockHud.config.main.mainHudPos.getAbsY(event.resolution, 34), - mc - ); + 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 b249362..439d857 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/overlay/GenericOverlays.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/overlay/GenericOverlays.java @@ -25,12 +25,7 @@ public class GenericOverlays extends Gui { 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 - ); + 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) { @@ -54,12 +49,7 @@ public class GenericOverlays extends Gui { 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 - ); + 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) { diff --git a/src/main/java/com/thatgravyboat/skyblockhud/overlay/OverlayHud.java b/src/main/java/com/thatgravyboat/skyblockhud/overlay/OverlayHud.java index 5560ff7..530a890 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/overlay/OverlayHud.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/overlay/OverlayHud.java @@ -43,20 +43,10 @@ public class OverlayHud extends Gui { 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"); + (time12Hour == 0 ? "00" : String.valueOf(time12Hour)) + ":" + (timeMin == 0 ? "00" : timeMin) + (timeHour >= 12 ? "pm" : "am"); 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 - ); + 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, @@ -94,10 +84,7 @@ public class OverlayHud extends Gui { } else { drawMithril(width, offset, mc); } - } else if ( - LocationHandler.getCurrentLocation().getCategory().equals(LocationCategory.PARK) && - ParkIslandHandler.isRaining() - ) { + } 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); @@ -114,19 +101,9 @@ public class OverlayHud extends Gui { 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 - ); + 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), @@ -233,13 +210,7 @@ public class OverlayHud extends Gui { 14 ); drawTexturedModalRect(xPos + 1, offset + (bossBarVisible ? 37 : 20), 75, 0, 8, 8); - drawString( - font, - CurrencyHandler.getBitsFormatted(), - xPos + 10, - offset + (bossBarVisible ? 38 : 21), - 0x55FFFF - ); + 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; @@ -262,14 +233,7 @@ public class OverlayHud extends Gui { ) 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)), offset + (bossBarVisible ? 35 : 18), 0, 34, 2, 14); drawTexturedModalRect( ((width / 2) - 33 - (font.getStringWidth(duration))) + 2, offset + (bossBarVisible ? 35 : 18), @@ -286,13 +250,7 @@ public class OverlayHud extends Gui { 8, 8 ); - drawString( - font, - duration, - (width / 2) - 19 - (font.getStringWidth(duration)), - offset + (bossBarVisible ? 38 : 21), - 0xFFFFFF - ); + drawString(font, duration, (width / 2) - 19 - (font.getStringWidth(duration)), offset + (bossBarVisible ? 38 : 21), 0xFFFFFF); } } @@ -301,14 +259,7 @@ public class OverlayHud extends Gui { 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)), offset + (bossBarVisible ? 35 : 18), 0, 34, 2, 14); drawTexturedModalRect( ((width / 2) - 33 - (font.getStringWidth(duration))) + 2, offset + (bossBarVisible ? 35 : 18), @@ -325,13 +276,7 @@ public class OverlayHud extends Gui { 8, 8 ); - drawString( - font, - duration, - (width / 2) - 19 - (font.getStringWidth(duration)), - offset + (bossBarVisible ? 38 : 21), - 0xFFFFFF - ); + drawString(font, duration, (width / 2) - 19 - (font.getStringWidth(duration)), offset + (bossBarVisible ? 38 : 21), 0xFFFFFF); } } @@ -366,14 +311,7 @@ public class OverlayHud extends Gui { 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)), offset + (bossBarVisible ? 35 : 18), 0, 34, 2, 14); drawTexturedModalRect( ((width / 2) - 33 - (font.getStringWidth(text))) + 2, offset + (bossBarVisible ? 35 : 18), @@ -390,13 +328,7 @@ public class OverlayHud extends Gui { 8, 8 ); - drawString( - font, - text, - (width / 2) - 19 - (font.getStringWidth(text)), - offset + (bossBarVisible ? 38 : 21), - 0xFFFFFF - ); + drawString(font, text, (width / 2) - 19 - (font.getStringWidth(text)), offset + (bossBarVisible ? 38 : 21), 0xFFFFFF); } } } @@ -406,14 +338,7 @@ public class OverlayHud extends Gui { 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)), offset + (bossBarVisible ? 35 : 18), 0, 34, 2, 14); drawTexturedModalRect( ((width / 2) - 33 - (font.getStringWidth(mithril))) + 2, offset + (bossBarVisible ? 35 : 18), @@ -430,13 +355,7 @@ public class OverlayHud extends Gui { 8, 8 ); - drawString( - font, - mithril, - (width / 2) - 19 - (font.getStringWidth(mithril)), - offset + (bossBarVisible ? 38 : 21), - 0x00C896 - ); + drawString(font, mithril, (width / 2) - 19 - (font.getStringWidth(mithril)), offset + (bossBarVisible ? 38 : 21), 0x00C896); } } @@ -447,14 +366,7 @@ public class OverlayHud extends Gui { 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)), offset + (bossBarVisible ? 35 : 18), 0, 34, 2, 14); drawTexturedModalRect( ((width / 2) - 33 - (font.getStringWidth(duration))) + 2, offset + (bossBarVisible ? 35 : 18), @@ -471,13 +383,7 @@ public class OverlayHud extends Gui { 8, 8 ); - drawString( - font, - duration, - (width / 2) - 19 - (font.getStringWidth(duration)), - offset + (bossBarVisible ? 38 : 21), - 0xFFFFFF - ); + drawString(font, duration, (width / 2) - 19 - (font.getStringWidth(duration)), offset + (bossBarVisible ? 38 : 21), 0xFFFFFF); } } @@ -520,14 +426,7 @@ public class OverlayHud extends Gui { ); } 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)), offset + (bossBarVisible ? 35 : 18), 0, 34, 2, 14); drawTexturedModalRect( ((width / 2) - 33 - (font.getStringWidth(text))) + 2, offset + (bossBarVisible ? 35 : 18), @@ -544,13 +443,7 @@ public class OverlayHud extends Gui { 8, 8 ); - drawString( - font, - text, - (width / 2) - 19 - (font.getStringWidth(text)), - offset + (bossBarVisible ? 38 : 21), - 0xFFFFFF - ); + drawString(font, text, (width / 2) - 19 - (font.getStringWidth(text)), offset + (bossBarVisible ? 38 : 21), 0xFFFFFF); } } } @@ -558,16 +451,11 @@ public class OverlayHud extends Gui { @SubscribeEvent public void renderOverlay(RenderGameOverlayEvent.Post event) { if (Utils.overlayShouldRender(event.type, SkyblockHud.hasSkyblockScoreboard())) { - bossBarVisible = - BossStatus.statusBarTime > 0 && GuiIngameForge.renderBossHealth && BossbarHandler.bossBarRendered; + 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 - ); + drawClock(event.resolution.getScaledWidth(), SkyblockHud.config.main.mainHudPos.getAbsY(event.resolution, 34), mc); } GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/overlay/RPGHud.java b/src/main/java/com/thatgravyboat/skyblockhud/overlay/RPGHud.java index dce51a9..7c622e4 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/overlay/RPGHud.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/overlay/RPGHud.java @@ -53,24 +53,14 @@ public class RPGHud extends Gui { @SubscribeEvent public void renderOverlay(RenderGameOverlayEvent.Post event) { if ( - Utils.overlayShouldRender( - event.type, - SkyblockHud.hasSkyblockScoreboard(), - SkyblockHud.config.renderer.hideXpBar - ) + 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 - ) - ) { + 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); @@ -90,35 +80,14 @@ public class RPGHud extends Gui { 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 - ); + 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 - ); + 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 - ); + drawTexturedModalRect(rightAligned ? x + 3 : 47 + x, 22 + y, rightAligned ? 186 : 0, 77, (int) absorptionWidth, 5); } float xpWidth = 67 * mc.thePlayer.experience; @@ -129,14 +98,7 @@ public class RPGHud extends Gui { 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 - ); + drawTexturedModalRect(rightAligned ? x + 19 : 41 + x, 33 + y, rightAligned ? 196 : 0, 88, (int) airWidth, 4); } GlStateManager.scale(0.75f, 0.75f, 1); drawCenteredString( diff --git a/src/main/java/com/thatgravyboat/skyblockhud/playerstats/ActionBarParsing.java b/src/main/java/com/thatgravyboat/skyblockhud/playerstats/ActionBarParsing.java index 44a250f..1fc9a77 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/playerstats/ActionBarParsing.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/playerstats/ActionBarParsing.java @@ -29,15 +29,11 @@ public class ActionBarParsing { ); private static final Pattern HealthReplaceRegex = Pattern.compile("\u00A7c([0-9]+)/([0-9]+)\u2764"); - private static final Pattern HealingReplaceRegex = Pattern.compile( - "\\+\u00A7c([0-9]+)[\u2586\u2585\u2584\u2583\u2582\u2581]" - ); + private static final Pattern HealingReplaceRegex = Pattern.compile("\\+\u00A7c([0-9]+)[\u2586\u2585\u2584\u2583\u2582\u2581]"); private static final Pattern HealthAbsorptionReplaceRegex = Pattern.compile("\u00A76([0-9]+)/([0-9]+)\u2764"); private static final Pattern DefenseReplaceRegex = Pattern.compile("\u00A7a([0-9]+)\u00A7a\u2748 Defense"); private static final Pattern ManaReplaceRegex = Pattern.compile("\u00A7b([0-9]+)/([0-9]+)\u270E Mana"); - private static final Pattern ManaOverflowReplaceRegex = Pattern.compile( - "\u00A7b([0-9]+)/([0-9]+)\u270E \u00A73([0-9]+)\u02AC" - ); + private static final Pattern ManaOverflowReplaceRegex = Pattern.compile("\u00A7b([0-9]+)/([0-9]+)\u270E \u00A73([0-9]+)\u02AC"); private static int ticksSinceLastPrediction = 0; private static boolean predict = false; @@ -99,10 +95,7 @@ public class ActionBarParsing { if (healthFound) { try { - RPGHud.updateHealth( - Integer.parseInt(HealthMatcher.group(1)), - Integer.parseInt(HealthMatcher.group(2)) - ); + RPGHud.updateHealth(Integer.parseInt(HealthMatcher.group(1)), Integer.parseInt(HealthMatcher.group(2))); } catch (Exception ignored) {} } if (defenseFound) { @@ -119,10 +112,7 @@ public class ActionBarParsing { } if (!manaFound && manaOverflowFound) { try { - RPGHud.updateMana( - Integer.parseInt(ManaOverflowMatcher.group(1)), - Integer.parseInt(ManaOverflowMatcher.group(2)) - ); + RPGHud.updateMana(Integer.parseInt(ManaOverflowMatcher.group(1)), Integer.parseInt(ManaOverflowMatcher.group(2))); RPGHud.updateOverflow(Integer.parseInt(ManaOverflowMatcher.group(3))); } catch (Exception ignored) {} } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/seasons/SeasonDateHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/seasons/SeasonDateHandler.java index ef61b43..b794eda 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/seasons/SeasonDateHandler.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/seasons/SeasonDateHandler.java @@ -67,12 +67,7 @@ public class SeasonDateHandler { } public static String removeDate(String seasonDate) { - return Pattern - .compile("[^a-zA-Z]") - .matcher(seasonDate.toLowerCase()) - .replaceAll("") - .replaceAll("st|nd|rd|th", "") - .trim(); + return Pattern.compile("[^a-zA-Z]").matcher(seasonDate.toLowerCase()).replaceAll("").replaceAll("st|nd|rd|th", "").trim(); } public static int removeSeason(String seasonDate) { diff --git a/src/main/java/com/thatgravyboat/skyblockhud/tracker/TrackerFileLoader.java b/src/main/java/com/thatgravyboat/skyblockhud/tracker/TrackerFileLoader.java index ba22101..858770a 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/tracker/TrackerFileLoader.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/tracker/TrackerFileLoader.java @@ -28,10 +28,7 @@ public class TrackerFileLoader { if (jsonObject.has("skullData") && displayItemId.equals("minecraft:skull") && meta == 3) { stack.setTagInfo("SkullOwner", getSkullTag(jsonObject.getAsJsonObject("skullData"))); } - if (jsonObject.has("enchanted") && jsonObject.get("enchanted").getAsBoolean()) stack.setTagInfo( - "ench", - new NBTTagList() - ); + if (jsonObject.has("enchanted") && jsonObject.get("enchanted").getAsBoolean()) stack.setTagInfo("ench", new NBTTagList()); return stack; } @@ -97,10 +94,7 @@ public class TrackerFileLoader { JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("location", locations); - if (event == null) jsonObject.add("event", new JsonNull()); else jsonObject.addProperty( - "event", - event - ); + if (event == null) jsonObject.add("event", new JsonNull()); else jsonObject.addProperty("event", event); JsonObject dropsData = new JsonObject(); drops.forEach((s, stack) -> dropsData.addProperty(s, stack.stackSize)); @@ -134,9 +128,7 @@ public class TrackerFileLoader { } try ( - BufferedReader reader = new BufferedReader( - new InputStreamReader(new FileInputStream(configFile), StandardCharsets.UTF_8) - ) + BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(configFile), StandardCharsets.UTF_8)) ) { JsonObject json = gson.fromJson(reader, JsonObject.class); if (json.has("trackerStats")) { @@ -147,19 +139,14 @@ public class TrackerFileLoader { if (element.isJsonObject()) { JsonObject object = element.getAsJsonObject(); String location = object.get("location").getAsString(); - Map> trackers = TrackerHandler.trackers.get(location) - .dropTrackers; + Map> trackers = TrackerHandler.trackers.get(location).dropTrackers; JsonElement event = object.get("event"); - String eventString = event == null || event.isJsonNull() - ? null - : event.getAsString(); + String eventString = event == null || event.isJsonNull() ? null : event.getAsString(); Map drops = trackers.get(eventString); if (drops != null) { - for (Map.Entry drop : object - .getAsJsonObject("drops") - .entrySet()) { + for (Map.Entry drop : object.getAsJsonObject("drops").entrySet()) { if (drops.containsKey(drop.getKey())) { drops.get(drop.getKey()).stackSize = drop.getValue().getAsInt(); } @@ -183,9 +170,7 @@ public class TrackerFileLoader { configFile.createNewFile(); try ( - BufferedWriter writer = new BufferedWriter( - new OutputStreamWriter(new FileOutputStream(configFile), StandardCharsets.UTF_8) - ) + BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(configFile), StandardCharsets.UTF_8)) ) { JsonObject json = new JsonObject(); json.add("trackerStats", getTrackerFile()); diff --git a/src/main/java/com/thatgravyboat/skyblockhud/tracker/TrackerHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/tracker/TrackerHandler.java index 2d5607f..f0a5b90 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/tracker/TrackerHandler.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/tracker/TrackerHandler.java @@ -27,12 +27,7 @@ public class TrackerHandler { } public String getDropId(String event) { - if ( - event == null || - event.isEmpty() || - !eventGoing() || - !dropTrackers.containsKey(event.toLowerCase().trim()) - ) return null; + if (event == null || event.isEmpty() || !eventGoing() || !dropTrackers.containsKey(event.toLowerCase().trim())) return null; return event.toLowerCase().trim(); } @@ -99,9 +94,7 @@ public class TrackerHandler { Minecraft mc = Minecraft.getMinecraft(); TrackerData tracked = trackers.get(trackerId); - Map tracker = tracked.dropTrackers.get( - tracked.getDropId(SeasonDateHandler.getCurrentEvent()) - ); + Map tracker = tracked.dropTrackers.get(tracked.getDropId(SeasonDateHandler.getCurrentEvent())); if (tracker != null) { Position pos = SkyblockHud.config.trackers.trackerPosition; int startPos = pos.getAbsX(event.resolution, (tracker.size() >= 6 ? 120 : tracker.size() * 20)); -- cgit From 804767ebfc26e2a1252bc327def02389b35dfc6e Mon Sep 17 00:00:00 2001 From: TymanWasTaken Date: Tue, 6 Jul 2021 17:27:11 -0400 Subject: fine --- .prettierrc.yml | 2 +- .../skyblockhud/ComponentHandler.java | 48 +--- .../com/thatgravyboat/skyblockhud/SkyblockHud.java | 8 +- .../java/com/thatgravyboat/skyblockhud/Utils.java | 49 +--- .../skyblockhud/api/LeaderboardGetter.java | 18 +- .../api/events/SidebarLineUpdateEvent.java | 9 +- .../skyblockhud/commands/Commands.java | 6 +- .../skyblockhud/config/SBHConfig.java | 33 +-- .../skyblockhud/config/SBHConfigEditor.java | 130 ++------- .../skyblockhud/core/BackgroundBlur.java | 29 +- .../skyblockhud/core/GuiElementColour.java | 87 +----- .../skyblockhud/core/GuiElementTextField.java | 108 +------ .../core/config/gui/GuiOptionEditorAccordion.java | 10 +- .../core/config/gui/GuiOptionEditorButton.java | 10 +- .../core/config/gui/GuiOptionEditorColour.java | 9 +- .../config/gui/GuiOptionEditorDraggableList.java | 78 +----- .../core/config/gui/GuiOptionEditorSlider.java | 6 +- .../core/config/gui/GuiPositionEditor.java | 27 +- .../core/config/struct/ConfigProcessor.java | 42 +-- .../skyblockhud/core/util/GuiElementSlider.java | 11 +- .../skyblockhud/core/util/render/RenderUtils.java | 35 +-- .../core/util/render/TextRenderUtils.java | 115 +------- .../skyblockhud/dungeons/DungeonHandler.java | 6 +- .../skyblockhud/handlers/BossbarHandler.java | 6 +- .../skyblockhud/handlers/CurrencyHandler.java | 21 +- .../skyblockhud/handlers/MapHandler.java | 122 +------- .../skyblockhud/handlers/SlayerHandler.java | 17 +- .../handlers/mapicons/DwarvenIcons.java | 67 +---- .../skyblockhud/handlers/mapicons/HubIcons.java | 309 ++------------------- .../handlers/sbentities/EntityTypeHelper.java | 5 +- .../handlers/sbentities/EntityTypeRegistry.java | 4 +- .../skyblockhud/location/DwarvenMineHandler.java | 3 +- .../skyblockhud/location/IslandHandler.java | 10 +- .../skyblockhud/mixins/MixinEntityArrow.java | 7 +- .../mixins/MixinNetHandlerPlayClient.java | 12 +- .../skyblockhud/overlay/DungeonOverlay.java | 72 +---- .../skyblockhud/overlay/GenericOverlays.java | 22 +- .../skyblockhud/overlay/OverlayHud.java | 260 +++-------------- .../thatgravyboat/skyblockhud/overlay/RPGHud.java | 25 +- .../skyblockhud/playerstats/ActionBarParsing.java | 4 +- .../skyblockhud/seasons/SeasonDateHandler.java | 5 +- .../skyblockhud/tracker/KillTrackerHandler.java | 32 +-- .../skyblockhud/tracker/TrackerFileLoader.java | 13 +- .../skyblockhud/tracker/TrackerHandler.java | 24 +- 44 files changed, 221 insertions(+), 1695 deletions(-) (limited to 'src/main/java/com/thatgravyboat/skyblockhud/overlay/DungeonOverlay.java') diff --git a/.prettierrc.yml b/.prettierrc.yml index ddd6ee5..f1cb8dc 100644 --- a/.prettierrc.yml +++ b/.prettierrc.yml @@ -6,4 +6,4 @@ overrides: trailingComma: none tabWidth: 4 endOfLine: lf - printWidth: 140 \ No newline at end of file + printWidth: 999999999 # >:c fine gravy \ No newline at end of file diff --git a/src/main/java/com/thatgravyboat/skyblockhud/ComponentHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/ComponentHandler.java index ad7b1e8..d56fd30 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/ComponentHandler.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/ComponentHandler.java @@ -38,19 +38,11 @@ public class ComponentHandler { if (ticksExisted % 60 == 0) { for (NetworkPlayerInfo player : players) { if (player.getDisplayName() != null) { - String formattedTabListPlayer = SCOREBOARD_CHARACTERS - .matcher(Utils.removeColor(player.getDisplayName().getFormattedText())) - .replaceAll(""); + String formattedTabListPlayer = SCOREBOARD_CHARACTERS.matcher(Utils.removeColor(player.getDisplayName().getFormattedText())).replaceAll(""); if (LocationHandler.getCurrentLocation().equals(Locations.CATACOMBS)) { - if (formattedTabListPlayer.toLowerCase().contains("secrets found:")) DungeonHandler.parseTotalSecrets( - formattedTabListPlayer - ); - if (formattedTabListPlayer.toLowerCase().contains("deaths:")) DungeonHandler.parseDeaths( - formattedTabListPlayer - ); - if (formattedTabListPlayer.toLowerCase().contains("crypts:")) DungeonHandler.parseCrypts( - formattedTabListPlayer - ); + if (formattedTabListPlayer.toLowerCase().contains("secrets found:")) DungeonHandler.parseTotalSecrets(formattedTabListPlayer); + if (formattedTabListPlayer.toLowerCase().contains("deaths:")) DungeonHandler.parseDeaths(formattedTabListPlayer); + if (formattedTabListPlayer.toLowerCase().contains("crypts:")) DungeonHandler.parseCrypts(formattedTabListPlayer); } else if (LocationHandler.getCurrentLocation().getCategory().equals(LocationCategory.DWARVENMINES)) { if (formattedTabListPlayer.toLowerCase().contains("mithril powder:")) { DwarvenMineHandler.parseMithril(formattedTabListPlayer); @@ -58,8 +50,7 @@ public class ComponentHandler { } else if (LocationHandler.getCurrentLocation().getCategory().equals(LocationCategory.MUSHROOMDESERT)) { if (formattedTabListPlayer.toLowerCase().contains("pelts:")) { try { - FarmingIslandHandler.pelts = - Integer.parseInt(formattedTabListPlayer.toLowerCase().replace("pelts:", "").trim()); + FarmingIslandHandler.pelts = Integer.parseInt(formattedTabListPlayer.toLowerCase().replace("pelts:", "").trim()); } catch (Exception ignored) {} } } @@ -68,15 +59,11 @@ public class ComponentHandler { if (players.size() > 80) { for (int i = 61; i <= 80; i++) { if (players.get(i).getDisplayName() != null) { - String formattedTabListPlayer = SCOREBOARD_CHARACTERS - .matcher(Utils.removeColor(players.get(i).getDisplayName().getFormattedText())) - .replaceAll(""); + String formattedTabListPlayer = SCOREBOARD_CHARACTERS.matcher(Utils.removeColor(players.get(i).getDisplayName().getFormattedText())).replaceAll(""); if (formattedTabListPlayer.toLowerCase().contains("event:")) { if (i < 80) { if (players.get(i + 1).getDisplayName() != null) { - String secondLine = SCOREBOARD_CHARACTERS - .matcher(Utils.removeColor(players.get(i + 1).getDisplayName().getFormattedText())) - .replaceAll(""); + String secondLine = SCOREBOARD_CHARACTERS.matcher(Utils.removeColor(players.get(i + 1).getDisplayName().getFormattedText())).replaceAll(""); SeasonDateHandler.setCurrentEvent(formattedTabListPlayer.replace("Event:", ""), secondLine); eventPass = true; } @@ -93,9 +80,7 @@ public class ComponentHandler { if (players.size() >= 80) { for (int i = 41; i <= 60; i++) { if (players.get(i).getDisplayName() != null) { - String formattedTabListPlayer = SCOREBOARD_CHARACTERS - .matcher(Utils.removeColor(players.get(i).getDisplayName().getFormattedText())) - .replaceAll(""); + String formattedTabListPlayer = SCOREBOARD_CHARACTERS.matcher(Utils.removeColor(players.get(i).getDisplayName().getFormattedText())).replaceAll(""); if (LocationHandler.getCurrentLocation().getCategory().equals(LocationCategory.PARK)) { if (formattedTabListPlayer.toLowerCase().contains("rain:")) { ParkIslandHandler.parseRain(formattedTabListPlayer.toLowerCase()); @@ -114,9 +99,7 @@ public class ComponentHandler { @SubscribeEvent(priority = EventPriority.HIGHEST) public void onStatusBar(ClientChatReceivedEvent event) { if (event.type == 2) { - if (LocationHandler.getCurrentLocation().equals(Locations.CATACOMBS)) DungeonHandler.parseSecrets( - event.message.getFormattedText() - ); + if (LocationHandler.getCurrentLocation().equals(Locations.CATACOMBS)) DungeonHandler.parseSecrets(event.message.getFormattedText()); } } @@ -128,18 +111,7 @@ public class ComponentHandler { public int compare(NetworkPlayerInfo p_compare_1_, NetworkPlayerInfo p_compare_2_) { ScorePlayerTeam scoreplayerteam = p_compare_1_.getPlayerTeam(); ScorePlayerTeam scoreplayerteam1 = p_compare_2_.getPlayerTeam(); - return ComparisonChain - .start() - .compareTrueFirst( - p_compare_1_.getGameType() != WorldSettings.GameType.SPECTATOR, - p_compare_2_.getGameType() != WorldSettings.GameType.SPECTATOR - ) - .compare( - scoreplayerteam != null ? scoreplayerteam.getRegisteredName() : "", - scoreplayerteam1 != null ? scoreplayerteam1.getRegisteredName() : "" - ) - .compare(p_compare_1_.getGameProfile().getName(), p_compare_2_.getGameProfile().getName()) - .result(); + return ComparisonChain.start().compareTrueFirst(p_compare_1_.getGameType() != WorldSettings.GameType.SPECTATOR, p_compare_2_.getGameType() != WorldSettings.GameType.SPECTATOR).compare(scoreplayerteam != null ? scoreplayerteam.getRegisteredName() : "", scoreplayerteam1 != null ? scoreplayerteam1.getRegisteredName() : "").compare(p_compare_1_.getGameProfile().getName(), p_compare_2_.getGameProfile().getName()).result(); } } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/SkyblockHud.java b/src/main/java/com/thatgravyboat/skyblockhud/SkyblockHud.java index 071d120..f461f6d 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/SkyblockHud.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/SkyblockHud.java @@ -86,9 +86,7 @@ public class SkyblockHud { configFile = new File(event.getModConfigurationDirectory(), "sbh-config.json"); if (configFile.exists()) { - try ( - BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(configFile), StandardCharsets.UTF_8)) - ) { + try (BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(configFile), StandardCharsets.UTF_8))) { config = gson.fromJson(reader, SBHConfig.class); } catch (Exception ignored) {} } @@ -108,9 +106,7 @@ public class SkyblockHud { try { configFile.createNewFile(); - try ( - BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(configFile), StandardCharsets.UTF_8)) - ) { + try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(configFile), StandardCharsets.UTF_8))) { writer.write(gson.toJson(config)); } } catch (IOException ignored) {} diff --git a/src/main/java/com/thatgravyboat/skyblockhud/Utils.java b/src/main/java/com/thatgravyboat/skyblockhud/Utils.java index 56b5f56..a7621ef 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/Utils.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/Utils.java @@ -38,9 +38,7 @@ public class Utils { public static boolean isPlayerHoldingRedstone(EntityPlayerSP player) { if (!SkyblockHud.config.main.requireRedstone) return true; - ArrayList redstoneItems = new ArrayList<>( - Arrays.asList(Items.redstone, Items.repeater, Items.comparator, Item.getByNameOrId("minecraft:redstone_torch")) - ); + ArrayList redstoneItems = new ArrayList<>(Arrays.asList(Items.redstone, Items.repeater, Items.comparator, Item.getByNameOrId("minecraft:redstone_torch"))); if (player.getHeldItem() != null) return redstoneItems.contains(player.getHeldItem().getItem()); return false; } @@ -107,12 +105,7 @@ public class Utils { return overlayShouldRender(false, type, RenderGameOverlayEvent.ElementType.HOTBAR, booleans); } - public static boolean overlayShouldRender( - boolean hideOnf3, - RenderGameOverlayEvent.ElementType type, - RenderGameOverlayEvent.ElementType checkType, - boolean... booleans - ) { + public static boolean overlayShouldRender(boolean hideOnf3, RenderGameOverlayEvent.ElementType type, RenderGameOverlayEvent.ElementType checkType, boolean... booleans) { Minecraft mc = Minecraft.getMinecraft(); boolean shouldRender; if (booleans.length > 1) { @@ -120,13 +113,7 @@ public class Utils { shouldRender = true; } else shouldRender = booleans.length != 1 || booleans[0]; if (hideOnf3) { - if ( - mc.gameSettings.showDebugInfo || - ( - mc.gameSettings.keyBindPlayerList.isKeyDown() && - (!mc.isIntegratedServerRunning() || mc.thePlayer.sendQueue.getPlayerInfoMap().size() > 1) - ) - ) { + if (mc.gameSettings.showDebugInfo || (mc.gameSettings.keyBindPlayerList.isKeyDown() && (!mc.isIntegratedServerRunning() || mc.thePlayer.sendQueue.getPlayerInfoMap().size() > 1))) { return false; } } @@ -155,17 +142,7 @@ public class Utils { drawStringScaled(str, fr, x - len / 2f, y - fontHeight / 2f, shadow, colour, factor); } - public static void drawTexturedRect( - float x, - float y, - float width, - float height, - float uMin, - float uMax, - float vMin, - float vMax, - int filter - ) { + public static void drawTexturedRect(float x, float y, float width, float height, float uMin, float uMax, float vMin, float vMax, int filter) { GlStateManager.enableTexture2D(); GlStateManager.enableBlend(); GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); @@ -240,14 +217,7 @@ public class Utils { GlStateManager.viewport(0, 0, Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight); GlStateManager.matrixMode(GL11.GL_PROJECTION); GlStateManager.loadIdentity(); - GlStateManager.ortho( - 0.0D, - scaledresolution.getScaledWidth_double(), - scaledresolution.getScaledHeight_double(), - 0.0D, - 1000.0D, - 3000.0D - ); + GlStateManager.ortho(0.0D, scaledresolution.getScaledWidth_double(), scaledresolution.getScaledHeight_double(), 0.0D, 1000.0D, 3000.0D); GlStateManager.matrixMode(GL11.GL_MODELVIEW); GlStateManager.loadIdentity(); GlStateManager.translate(0.0F, 0.0F, -2000.0F); @@ -260,14 +230,7 @@ public class Utils { } else { GlStateManager.matrixMode(GL11.GL_PROJECTION); GlStateManager.loadIdentity(); - GlStateManager.ortho( - 0.0D, - scaledresolution.getScaledWidth_double(), - scaledresolution.getScaledHeight_double(), - 0.0D, - 1000.0D, - 3000.0D - ); + GlStateManager.ortho(0.0D, scaledresolution.getScaledWidth_double(), scaledresolution.getScaledHeight_double(), 0.0D, 1000.0D, 3000.0D); GlStateManager.matrixMode(GL11.GL_MODELVIEW); GlStateManager.loadIdentity(); GlStateManager.translate(0.0F, 0.0F, -2000.0F); diff --git a/src/main/java/com/thatgravyboat/skyblockhud/api/LeaderboardGetter.java b/src/main/java/com/thatgravyboat/skyblockhud/api/LeaderboardGetter.java index db9ad38..b1115ae 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/api/LeaderboardGetter.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/api/LeaderboardGetter.java @@ -43,26 +43,12 @@ public class LeaderboardGetter { scores.forEach( (score, name) -> { if (cachedScores.get(score) == null || !cachedScores.get(score).equals(name)) { - MinecraftForge.EVENT_BUS.post( - new SidebarLineUpdateEvent( - name, - SCOREBOARD_CHARACTERS.matcher(name).replaceAll("").trim(), - score, - scores.size(), - scoreboard, - sidebarObjective - ) - ); + MinecraftForge.EVENT_BUS.post(new SidebarLineUpdateEvent(name, SCOREBOARD_CHARACTERS.matcher(name).replaceAll("").trim(), score, scores.size(), scoreboard, sidebarObjective)); } } ); cachedScores = scores; - cachedScoresList = - scores - .values() - .stream() - .map(name -> SCOREBOARD_CHARACTERS.matcher(name).replaceAll("").trim()) - .collect(Collectors.toList()); + cachedScoresList = scores.values().stream().map(name -> SCOREBOARD_CHARACTERS.matcher(name).replaceAll("").trim()).collect(Collectors.toList()); } MinecraftForge.EVENT_BUS.post(new SidebarPostEvent(scoreboard, sidebarObjective, cachedScoresList)); } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/api/events/SidebarLineUpdateEvent.java b/src/main/java/com/thatgravyboat/skyblockhud/api/events/SidebarLineUpdateEvent.java index 8a7aa39..2737ee9 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/api/events/SidebarLineUpdateEvent.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/api/events/SidebarLineUpdateEvent.java @@ -12,14 +12,7 @@ public class SidebarLineUpdateEvent extends Event { public Scoreboard scoreboard; public ScoreObjective objective; - public SidebarLineUpdateEvent( - String rawLine, - String formattedLine, - int score, - int max, - Scoreboard scoreboard, - ScoreObjective objective - ) { + public SidebarLineUpdateEvent(String rawLine, String formattedLine, int score, int max, Scoreboard scoreboard, ScoreObjective objective) { this.rawLine = rawLine; this.formattedLine = formattedLine; this.position = max - score; diff --git a/src/main/java/com/thatgravyboat/skyblockhud/commands/Commands.java b/src/main/java/com/thatgravyboat/skyblockhud/commands/Commands.java index 8304906..ef3df57 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/commands/Commands.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/commands/Commands.java @@ -15,8 +15,7 @@ public class Commands { private static final SimpleCommand.ProcessCommandRunnable settingsRunnable = new SimpleCommand.ProcessCommandRunnable() { public void processCommand(ICommandSender sender, String[] args) { if (args.length > 0) { - SkyblockHud.screenToOpen = - new GuiScreenElementWrapper(new SBHConfigEditor(SkyblockHud.config, StringUtils.join(args, " "))); + SkyblockHud.screenToOpen = new GuiScreenElementWrapper(new SBHConfigEditor(SkyblockHud.config, StringUtils.join(args, " "))); } else { SkyblockHud.screenToOpen = new GuiScreenElementWrapper(new SBHConfigEditor(SkyblockHud.config)); } @@ -31,8 +30,7 @@ public class Commands { "sbhmap", new SimpleCommand.ProcessCommandRunnable() { public void processCommand(ICommandSender sender, String[] args) { - if (LocationHandler.getCurrentLocation().getCategory().getMap() != null) SkyblockHud.screenToOpen = - new MapHandler.MapScreen(); + if (LocationHandler.getCurrentLocation().getCategory().getMap() != null) SkyblockHud.screenToOpen = new MapHandler.MapScreen(); } } ); diff --git a/src/main/java/com/thatgravyboat/skyblockhud/config/SBHConfig.java b/src/main/java/com/thatgravyboat/skyblockhud/config/SBHConfig.java index c8f6d53..90f4c19 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/config/SBHConfig.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/config/SBHConfig.java @@ -12,18 +12,7 @@ import net.minecraft.client.Minecraft; public class SBHConfig extends Config { private void editOverlay(String activeConfig, int width, int height, Position position) { - Minecraft - .getMinecraft() - .displayGuiScreen( - new GuiPositionEditor( - position, - width, - height, - () -> {}, - () -> {}, - () -> SkyblockHud.screenToOpen = new GuiScreenElementWrapper(new SBHConfigEditor(SkyblockHud.config, activeConfig)) - ) - ); + Minecraft.getMinecraft().displayGuiScreen(new GuiPositionEditor(position, width, height, () -> {}, () -> {}, () -> SkyblockHud.screenToOpen = new GuiScreenElementWrapper(new SBHConfigEditor(SkyblockHud.config, activeConfig)))); } @Override @@ -121,10 +110,7 @@ public class SBHConfig extends Config { public boolean bossShiftHud = true; @Expose - @ConfigOption( - name = "Require Redstone", - desc = "Allows to make it so that the redstone percentage requires you to hold a redstone item to show." - ) + @ConfigOption(name = "Require Redstone", desc = "Allows to make it so that the redstone percentage requires you to hold a redstone item to show.") @ConfigEditorBoolean public boolean requireRedstone = true; } @@ -230,10 +216,7 @@ public class SBHConfig extends Config { public static class Renderer { @Expose - @ConfigOption( - name = "Hide Boss Bar", - desc = "Hides Boss Bar when certain conditions are met such as the name is just wither or it starts with objective:" - ) + @ConfigOption(name = "Hide Boss Bar", desc = "Hides Boss Bar when certain conditions are met such as the name is just wither or it starts with objective:") @ConfigEditorBoolean public boolean hideBossBar = true; @@ -271,18 +254,12 @@ public class SBHConfig extends Config { public static class Map { @Expose - @ConfigOption( - name = "Show Player Location", - desc = "This feature is off by default as Hypixel's rules are so vague that this would fall under their disallowed modifications." - ) + @ConfigOption(name = "Show Player Location", desc = "This feature is off by default as Hypixel's rules are so vague that this would fall under their disallowed modifications.") @ConfigEditorBoolean public boolean showPlayerLocation = false; @Expose - @ConfigOption( - name = "Show Mini-Map", - desc = "Shows the Mini-Map on your overlay if turned off you can still use /sbhmap to see the map in fullscreen." - ) + @ConfigOption(name = "Show Mini-Map", desc = "Shows the Mini-Map on your overlay if turned off you can still use /sbhmap to see the map in fullscreen.") @ConfigEditorBoolean public boolean showMiniMap = false; diff --git a/src/main/java/com/thatgravyboat/skyblockhud/config/SBHConfigEditor.java b/src/main/java/com/thatgravyboat/skyblockhud/config/SBHConfigEditor.java index 7dee8e6..0496a8f 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/config/SBHConfigEditor.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/config/SBHConfigEditor.java @@ -119,15 +119,7 @@ public class SBHConfigEditor extends GuiElement { int mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1; float opacityFactor = LerpUtils.sigmoidZeroOne(delta / 500f); - RenderUtils.drawGradientRect( - 0, - 0, - 0, - width, - height, - (int) (0x80 * opacityFactor) << 24 | 0x101010, - (int) (0x90 * opacityFactor) << 24 | 0x101010 - ); + RenderUtils.drawGradientRect(0, 0, 0, width, height, (int) (0x80 * opacityFactor) << 24 | 0x101010, (int) (0x90 * opacityFactor) << 24 | 0x101010); int xSize = Math.min(scaledResolution.getScaledWidth() - 100 / scaledResolution.getScaleFactor(), 500); int ySize = Math.min(scaledResolution.getScaledHeight() - 100 / scaledResolution.getScaleFactor(), 400); @@ -145,39 +137,14 @@ public class SBHConfigEditor extends GuiElement { } else if (delta < 300) { openingYSize = 5 + (int) (delta - 150) * (ySize - 5) / 150; } - RenderUtils.drawFloatingRectDark( - (scaledResolution.getScaledWidth() - openingXSize) / 2, - (scaledResolution.getScaledHeight() - openingYSize) / 2, - openingXSize, - openingYSize - ); + RenderUtils.drawFloatingRectDark((scaledResolution.getScaledWidth() - openingXSize) / 2, (scaledResolution.getScaledHeight() - openingYSize) / 2, openingXSize, openingYSize); GlScissorStack.clear(); - GlScissorStack.push( - (scaledResolution.getScaledWidth() - openingXSize) / 2, - (scaledResolution.getScaledHeight() - openingYSize) / 2, - (scaledResolution.getScaledWidth() + openingXSize) / 2, - (scaledResolution.getScaledHeight() + openingYSize) / 2, - scaledResolution - ); + GlScissorStack.push((scaledResolution.getScaledWidth() - openingXSize) / 2, (scaledResolution.getScaledHeight() - openingYSize) / 2, (scaledResolution.getScaledWidth() + openingXSize) / 2, (scaledResolution.getScaledHeight() + openingYSize) / 2, scaledResolution); RenderUtils.drawFloatingRectDark(x + 5, y + 5, xSize - 10, 20, false); FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - TextRenderUtils.drawStringCenteredScaledMaxWidth( - "SkyBlockHud by " + - EnumChatFormatting.RED + - "ThatGravyBoat" + - EnumChatFormatting.RESET + - ", config by " + - EnumChatFormatting.DARK_PURPLE + - "Moulberry", - fr, - x + xSize / 2f, - y + 15, - false, - 200, - 0xa0a0a0 - ); + TextRenderUtils.drawStringCenteredScaledMaxWidth("SkyBlockHud by " + EnumChatFormatting.RED + "ThatGravyBoat" + EnumChatFormatting.RESET + ", config by " + EnumChatFormatting.DARK_PURPLE + "Moulberry", fr, x + xSize / 2f, y + 15, false, 200, 0xa0a0a0); RenderUtils.drawFloatingRectDark(x + 4, y + 49 - 20, 140, ySize - 54 + 20, false); @@ -222,25 +189,15 @@ public class SBHConfigEditor extends GuiElement { catBarEnd = 1; if (categoryScroll.getTarget() / (float) (catY + categoryScroll.getValue()) + catBarSize < 1) { int target = optionsScroll.getTarget(); - categoryScroll.setValue( - (int) Math.ceil((catY + 5 + categoryScroll.getValue()) - catBarSize * (catY + 5 + categoryScroll.getValue())) - ); + categoryScroll.setValue((int) Math.ceil((catY + 5 + categoryScroll.getValue()) - catBarSize * (catY + 5 + categoryScroll.getValue()))); categoryScroll.setTarget(target); } else { - categoryScroll.setValue( - (int) Math.ceil((catY + 5 + categoryScroll.getValue()) - catBarSize * (catY + 5 + categoryScroll.getValue())) - ); + categoryScroll.setValue((int) Math.ceil((catY + 5 + categoryScroll.getValue()) - catBarSize * (catY + 5 + categoryScroll.getValue()))); } } int catDist = innerBottom - innerTop - 12; Gui.drawRect(innerLeft + 2, innerTop + 5, innerLeft + 7, innerBottom - 5, 0xff101010); - Gui.drawRect( - innerLeft + 3, - innerTop + 6 + (int) (catDist * catBarStart), - innerLeft + 6, - innerTop + 6 + (int) (catDist * catBarEnd), - 0xff303030 - ); + Gui.drawRect(innerLeft + 3, innerTop + 6 + (int) (catDist * catBarStart), innerLeft + 6, innerTop + 6 + (int) (catDist * catBarEnd), 0xff303030); GlScissorStack.pop(scaledResolution); @@ -258,15 +215,7 @@ public class SBHConfigEditor extends GuiElement { if (getSelectedCategory() != null && currentConfigEditing.containsKey(getSelectedCategory())) { ConfigProcessor.ProcessedCategory cat = currentConfigEditing.get(getSelectedCategory()); - TextRenderUtils.drawStringScaledMaxWidth( - cat.desc, - fr, - innerLeft + 5, - y + 40, - true, - innerRight - innerLeft - rightStuffLen - 10, - 0xb0b0b0 - ); + TextRenderUtils.drawStringScaledMaxWidth(cat.desc, fr, innerLeft + 5, y + 40, true, innerRight - innerLeft - rightStuffLen - 10, 0xb0b0b0); } Gui.drawRect(innerLeft, innerTop, innerLeft + 1, innerBottom, 0xff08080E); //Left @@ -361,25 +310,15 @@ public class SBHConfigEditor extends GuiElement { barEnd = 1; if (optionsScroll.getTarget() / (float) (optionY + optionsScroll.getValue()) + barSize < 1) { int target = optionsScroll.getTarget(); - optionsScroll.setValue( - (int) Math.ceil((optionY + 5 + optionsScroll.getValue()) - barSize * (optionY + 5 + optionsScroll.getValue())) - ); + optionsScroll.setValue((int) Math.ceil((optionY + 5 + optionsScroll.getValue()) - barSize * (optionY + 5 + optionsScroll.getValue()))); optionsScroll.setTarget(target); } else { - optionsScroll.setValue( - (int) Math.ceil((optionY + 5 + optionsScroll.getValue()) - barSize * (optionY + 5 + optionsScroll.getValue())) - ); + optionsScroll.setValue((int) Math.ceil((optionY + 5 + optionsScroll.getValue()) - barSize * (optionY + 5 + optionsScroll.getValue()))); } } int dist = innerBottom - innerTop - 12; Gui.drawRect(innerRight - 10, innerTop + 5, innerRight - 5, innerBottom - 5, 0xff101010); - Gui.drawRect( - innerRight - 9, - innerTop + 6 + (int) (dist * barStart), - innerRight - 6, - innerTop + 6 + (int) (dist * barEnd), - 0xff303030 - ); + Gui.drawRect(innerRight - 9, innerTop + 6 + (int) (dist * barStart), innerRight - 6, innerTop + 6 + (int) (dist * barEnd), 0xff303030); for (int socialIndex = 0; socialIndex < socialsIco.length; socialIndex++) { Minecraft.getMinecraft().getTextureManager().bindTexture(socialsIco[socialIndex]); @@ -388,8 +327,7 @@ public class SBHConfigEditor extends GuiElement { RenderUtils.drawTexturedRect(socialLeft, y + 7, 16, 16, GL11.GL_LINEAR); if (mouseX >= socialLeft && mouseX <= socialLeft + 16 && mouseY >= y + 6 && mouseY <= y + 23) { - tooltipToDisplay = - Lists.newArrayList(EnumChatFormatting.YELLOW + "Go to: " + EnumChatFormatting.RESET + socialsLink[socialIndex]); + tooltipToDisplay = Lists.newArrayList(EnumChatFormatting.YELLOW + "Go to: " + EnumChatFormatting.RESET + socialsLink[socialIndex]); } } @@ -462,11 +400,7 @@ public class SBHConfigEditor extends GuiElement { float barSize = 1; int optionY = -newTarget; - if ( - getSelectedCategory() != null && - getCurrentConfigEditing() != null && - getCurrentConfigEditing().containsKey(getSelectedCategory()) - ) { + if (getSelectedCategory() != null && getCurrentConfigEditing() != null && getCurrentConfigEditing().containsKey(getSelectedCategory())) { ConfigProcessor.ProcessedCategory cat = getCurrentConfigEditing().get(getSelectedCategory()); Set activeAccordions = new HashSet<>(); for (ConfigProcessor.ProcessedOption option : getOptionsInCategory(cat).values()) { @@ -530,11 +464,7 @@ public class SBHConfigEditor extends GuiElement { } int optionY = -optionsScroll.getValue(); - if ( - getSelectedCategory() != null && - getCurrentConfigEditing() != null && - getCurrentConfigEditing().containsKey(getSelectedCategory()) - ) { + if (getSelectedCategory() != null && getCurrentConfigEditing() != null && getCurrentConfigEditing().containsKey(getSelectedCategory())) { int optionWidthDefault = innerRight - innerLeft - 20; ConfigProcessor.ProcessedCategory cat = getCurrentConfigEditing().get(getSelectedCategory()); Set activeAccordions = new HashSet<>(); @@ -557,15 +487,7 @@ public class SBHConfigEditor extends GuiElement { activeAccordions.add(accordion.getAccordionId()); } } - if ( - editor.mouseInputOverlay( - (innerLeft + innerRight - optionWidth) / 2 - 5, - innerTop + 5 + optionY, - optionWidth, - mouseX, - mouseY - ) - ) { + if (editor.mouseInputOverlay((innerLeft + innerRight - optionWidth) / 2 - 5, innerTop + 5 + optionY, optionWidth, mouseX, mouseY)) { return true; } optionY += editor.getHeight() + 5; @@ -574,11 +496,7 @@ public class SBHConfigEditor extends GuiElement { if (mouseX > innerLeft && mouseX < innerRight && mouseY > innerTop && mouseY < innerBottom) { optionY = -optionsScroll.getValue(); - if ( - getSelectedCategory() != null && - getCurrentConfigEditing() != null && - getCurrentConfigEditing().containsKey(getSelectedCategory()) - ) { + if (getSelectedCategory() != null && getCurrentConfigEditing() != null && getCurrentConfigEditing().containsKey(getSelectedCategory())) { int optionWidthDefault = innerRight - innerLeft - 20; ConfigProcessor.ProcessedCategory cat = getCurrentConfigEditing().get(getSelectedCategory()); Set activeAccordions = new HashSet<>(); @@ -601,15 +519,7 @@ public class SBHConfigEditor extends GuiElement { activeAccordions.add(accordion.getAccordionId()); } } - if ( - editor.mouseInput( - (innerLeft + innerRight - optionWidth) / 2 - 5, - innerTop + 5 + optionY, - optionWidth, - mouseX, - mouseY - ) - ) { + if (editor.mouseInput((innerLeft + innerRight - optionWidth) / 2 - 5, innerTop + 5 + optionY, optionWidth, mouseX, mouseY)) { return true; } optionY += editor.getHeight() + 5; @@ -631,11 +541,7 @@ public class SBHConfigEditor extends GuiElement { int innerPadding = 20 / adjScaleFactor; int innerWidth = xSize - 154 - innerPadding * 2; - if ( - getSelectedCategory() != null && - getCurrentConfigEditing() != null && - getCurrentConfigEditing().containsKey(getSelectedCategory()) - ) { + if (getSelectedCategory() != null && getCurrentConfigEditing() != null && getCurrentConfigEditing().containsKey(getSelectedCategory())) { ConfigProcessor.ProcessedCategory cat = getCurrentConfigEditing().get(getSelectedCategory()); Set activeAccordions = new HashSet<>(); for (ConfigProcessor.ProcessedOption option : getOptionsInCategory(cat).values()) { diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/BackgroundBlur.java b/src/main/java/com/thatgravyboat/skyblockhud/core/BackgroundBlur.java index 7c252ad..a9d9d5d 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/BackgroundBlur.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/BackgroundBlur.java @@ -153,13 +153,7 @@ public class BackgroundBlur { } try { - blurShaderHorz = - new Shader( - Minecraft.getMinecraft().getResourceManager(), - "blur", - Minecraft.getMinecraft().getFramebuffer(), - blurOutputHorz - ); + blurShaderHorz = new Shader(Minecraft.getMinecraft().getResourceManager(), "blur", Minecraft.getMinecraft().getFramebuffer(), blurOutputHorz); blurShaderHorz.getShaderManager().getShaderUniform("BlurDir").set(1, 0); blurShaderHorz.setProjectionMatrix(createProjectionMatrix(width, height)); } catch (Exception ignored) {} @@ -193,15 +187,7 @@ public class BackgroundBlur { } } - public static void renderBlurredBackground( - float blurStrength, - int screenWidth, - int screenHeight, - int x, - int y, - int blurWidth, - int blurHeight - ) { + public static void renderBlurredBackground(float blurStrength, int screenWidth, int screenHeight, int x, int y, int blurWidth, int blurHeight) { renderBlurredBackground(blurStrength, screenWidth, screenHeight, x, y, blurWidth, blurHeight, false); } @@ -209,16 +195,7 @@ public class BackgroundBlur { * Renders a subsection of the blurred framebuffer on to the corresponding section of the screen. * Essentially, this method will "blur" the background inside the bounds specified by [x->x+blurWidth, y->y+blurHeight] */ - public static void renderBlurredBackground( - float blurStrength, - int screenWidth, - int screenHeight, - int x, - int y, - int blurWidth, - int blurHeight, - boolean forcedUpdate - ) { + public static void renderBlurredBackground(float blurStrength, int screenWidth, int screenHeight, int x, int y, int blurWidth, int blurHeight, boolean forcedUpdate) { if (!OpenGlHelper.isFramebufferEnabled() || !OpenGlHelper.areShadersSupported()) return; if (blurStrength < 0.5) return; requestedBlurs.add(blurStrength); diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElementColour.java b/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElementColour.java index 7f8b9ba..2092b31 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElementColour.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElementColour.java @@ -26,10 +26,7 @@ public class GuiElementColour extends GuiElement { private static final ResourceLocation colourPickerLocation = new ResourceLocation("mbcore:dynamic/colourpicker"); private static final ResourceLocation colourPickerBarValueLocation = new ResourceLocation("mbcore:dynamic/colourpickervalue"); private static final ResourceLocation colourPickerBarOpacityLocation = new ResourceLocation("mbcore:dynamic/colourpickeropacity"); - private final GuiElementTextField hexField = new GuiElementTextField( - "", - GuiElementTextField.SCALE_TEXT | GuiElementTextField.FORCE_CAPS | GuiElementTextField.NO_SPACE - ); + private final GuiElementTextField hexField = new GuiElementTextField("", GuiElementTextField.SCALE_TEXT | GuiElementTextField.FORCE_CAPS | GuiElementTextField.NO_SPACE); private int x; private int y; @@ -92,9 +89,7 @@ public class GuiElementColour extends GuiElement { bufferedImage.setRGB(x + 16, y + 16, (int) (blackAlpha * 255) << 24); } else { Color col = Color.getHSBColor(angle / 360f, 1, hsv[2]); - int rgb = (int) (col.getRed() * invBlackAlpha) << 16 | - (int) (col.getGreen() * invBlackAlpha) << 8 | - (int) (col.getBlue() * invBlackAlpha); + int rgb = (int) (col.getRed() * invBlackAlpha) << 16 | (int) (col.getGreen() * invBlackAlpha) << 8 | (int) (col.getBlue() * invBlackAlpha); bufferedImage.setRGB(x + 16, y + 16, 0xff000000 | rgb); } } @@ -145,21 +140,9 @@ public class GuiElementColour extends GuiElement { float hsvChroma[] = Color.RGBtoHSB(cChroma.getRed(), cChroma.getGreen(), cChroma.getBlue(), null); if (chromaSpeed > 0) { - Gui.drawRect( - x + 5 + 64 + 5 + 10 + 5 + 10 + 5 + 1, - y + 5 + 1, - x + 5 + 64 + 5 + 10 + 5 + 10 + 5 + 10 - 1, - y + 5 + 64 - 1, - Color.HSBtoRGB(hsvChroma[0], 0.8f, 0.8f) - ); + Gui.drawRect(x + 5 + 64 + 5 + 10 + 5 + 10 + 5 + 1, y + 5 + 1, x + 5 + 64 + 5 + 10 + 5 + 10 + 5 + 10 - 1, y + 5 + 64 - 1, Color.HSBtoRGB(hsvChroma[0], 0.8f, 0.8f)); } else { - Gui.drawRect( - x + 5 + 64 + 5 + 10 + 5 + 10 + 5 + 1, - y + 5 + 27 + 1, - x + 5 + 64 + 5 + 10 + 5 + 10 + 5 + 10 - 1, - y + 5 + 37 - 1, - Color.HSBtoRGB((hsvChroma[0] + (System.currentTimeMillis() - ChromaColour.startTime) / 1000f) % 1, 0.8f, 0.8f) - ); + Gui.drawRect(x + 5 + 64 + 5 + 10 + 5 + 10 + 5 + 1, y + 5 + 27 + 1, x + 5 + 64 + 5 + 10 + 5 + 10 + 5 + 10 - 1, y + 5 + 37 - 1, Color.HSBtoRGB((hsvChroma[0] + (System.currentTimeMillis() - ChromaColour.startTime) / 1000f) % 1, 0.8f, 0.8f)); } Minecraft.getMinecraft().getTextureManager().bindTexture(colour_selector_bar); @@ -174,28 +157,10 @@ public class GuiElementColour extends GuiElement { RenderUtils.drawTexturedRect(x + 5 + 64 + 5 + 10 + 5 + 10 + 5, y + 5 + 27, 10, 10, GL11.GL_NEAREST); } - Gui.drawRect( - x + 5 + 64 + 5, - y + 5 + 64 - (int) (64 * hsv[2]), - x + 5 + 64 + 5 + 10, - y + 5 + 64 - (int) (64 * hsv[2]) + 1, - 0xFF000000 - ); - Gui.drawRect( - x + 5 + 64 + 5 + 10 + 5, - y + 5 + 64 - c.getAlpha() / 4, - x + 5 + 64 + 5 + 10 + 5 + 10, - y + 5 + 64 - c.getAlpha() / 4 - 1, - 0xFF000000 - ); + Gui.drawRect(x + 5 + 64 + 5, y + 5 + 64 - (int) (64 * hsv[2]), x + 5 + 64 + 5 + 10, y + 5 + 64 - (int) (64 * hsv[2]) + 1, 0xFF000000); + Gui.drawRect(x + 5 + 64 + 5 + 10 + 5, y + 5 + 64 - c.getAlpha() / 4, x + 5 + 64 + 5 + 10 + 5 + 10, y + 5 + 64 - c.getAlpha() / 4 - 1, 0xFF000000); if (chromaSpeed > 0) { - Gui.drawRect( - x + 5 + 64 + 5 + 10 + 5 + 10 + 5, - y + 5 + 64 - (int) (chromaSpeed / 255f * 64), - x + 5 + 64 + 5 + 10 + 5 + 10 + 5 + 10, - y + 5 + 64 - (int) (chromaSpeed / 255f * 64) + 1, - 0xFF000000 - ); + Gui.drawRect(x + 5 + 64 + 5 + 10 + 5 + 10 + 5, y + 5 + 64 - (int) (chromaSpeed / 255f * 64), x + 5 + 64 + 5 + 10 + 5 + 10 + 5 + 10, y + 5 + 64 - (int) (chromaSpeed / 255f * 64) + 1, 0xFF000000); } Minecraft.getMinecraft().getTextureManager().loadTexture(colourPickerLocation, new DynamicTexture(bufferedImage)); @@ -207,34 +172,10 @@ public class GuiElementColour extends GuiElement { GlStateManager.color(1, 1, 1, 1); RenderUtils.drawTexturedRect(x + 5 + 32 + selx - 4, y + 5 + 32 + sely - 4, 8, 8, GL11.GL_NEAREST); - TextRenderUtils.drawStringCenteredScaledMaxWidth( - EnumChatFormatting.GRAY.toString() + Math.round(hsv[2] * 100) + "", - Minecraft.getMinecraft().fontRendererObj, - x + 5 + 64 + 5 + 5 - (Math.round(hsv[2] * 100) == 100 ? 1 : 0), - y + 5 + 64 + 5 + 5, - true, - 13, - -1 - ); - TextRenderUtils.drawStringCenteredScaledMaxWidth( - EnumChatFormatting.GRAY.toString() + Math.round(c.getAlpha() / 255f * 100) + "", - Minecraft.getMinecraft().fontRendererObj, - x + 5 + 64 + 5 + 15 + 5, - y + 5 + 64 + 5 + 5, - true, - 13, - -1 - ); + TextRenderUtils.drawStringCenteredScaledMaxWidth(EnumChatFormatting.GRAY.toString() + Math.round(hsv[2] * 100) + "", Minecraft.getMinecraft().fontRendererObj, x + 5 + 64 + 5 + 5 - (Math.round(hsv[2] * 100) == 100 ? 1 : 0), y + 5 + 64 + 5 + 5, true, 13, -1); + TextRenderUtils.drawStringCenteredScaledMaxWidth(EnumChatFormatting.GRAY.toString() + Math.round(c.getAlpha() / 255f * 100) + "", Minecraft.getMinecraft().fontRendererObj, x + 5 + 64 + 5 + 15 + 5, y + 5 + 64 + 5 + 5, true, 13, -1); if (chromaSpeed > 0) { - TextRenderUtils.drawStringCenteredScaledMaxWidth( - EnumChatFormatting.GRAY.toString() + (int) ChromaColour.getSecondsForSpeed(chromaSpeed) + "s", - Minecraft.getMinecraft().fontRendererObj, - x + 5 + 64 + 5 + 30 + 6, - y + 5 + 64 + 5 + 5, - true, - 13, - -1 - ); + TextRenderUtils.drawStringCenteredScaledMaxWidth(EnumChatFormatting.GRAY.toString() + (int) ChromaColour.getSecondsForSpeed(chromaSpeed) + "s", Minecraft.getMinecraft().fontRendererObj, x + 5 + 64 + 5 + 30 + 6, y + 5 + 64 + 5 + 5, true, 13, -1); } hexField.setSize(48, 10); @@ -253,13 +194,7 @@ public class GuiElementColour extends GuiElement { public boolean mouseInput(int mouseX, int mouseY) { ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); float mouseXF = (float) (Mouse.getX() * scaledResolution.getScaledWidth_double() / Minecraft.getMinecraft().displayWidth); - float mouseYF = (float) ( - scaledResolution.getScaledHeight_double() - - Mouse.getY() * - scaledResolution.getScaledHeight_double() / - Minecraft.getMinecraft().displayHeight - - 1 - ); + float mouseYF = (float) (scaledResolution.getScaledHeight_double() - Mouse.getY() * scaledResolution.getScaledHeight_double() / Minecraft.getMinecraft().displayHeight - 1); if ((Mouse.getEventButton() == 0 || Mouse.getEventButton() == 1) && Mouse.getEventButtonState()) { if (mouseX > x + 5 + 8 && mouseX < x + 5 + 8 + 48) { diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElementTextField.java b/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElementTextField.java index 54db59b..867efc1 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElementTextField.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElementTextField.java @@ -276,8 +276,7 @@ public class GuiElementTextField { linePos++; } } - int newPos = - textField.getSelectionEnd() - strLenNoColor(thisLineBeforeCursor) - strLenNoColor(lineBefore) - 1 + linePos; + int newPos = textField.getSelectionEnd() - strLenNoColor(thisLineBeforeCursor) - strLenNoColor(lineBefore) - 1 + linePos; if (GuiScreen.isShiftKeyDown()) { textField.setSelectionPos(newPos); @@ -317,12 +316,7 @@ public class GuiElementTextField { linePos++; } } - int newPos = - textField.getSelectionEnd() - - strLenNoColor(thisLineBeforeCursor) + - strLenNoColor(split2[numLinesBeforeCursor]) + - 1 + - linePos; + int newPos = textField.getSelectionEnd() - strLenNoColor(thisLineBeforeCursor) + strLenNoColor(split2[numLinesBeforeCursor]) + 1 + linePos; if (GuiScreen.isShiftKeyDown()) { textField.setSelectionPos(newPos); @@ -367,15 +361,7 @@ public class GuiElementTextField { drawTextbox(x, y, searchBarXSize, searchBarYSize, searchBarPadding, textField, focus); } - private void drawTextbox( - int x, - int y, - int searchBarXSize, - int searchBarYSize, - int searchBarPadding, - GuiTextField textField, - boolean focus - ) { + private void drawTextbox(int x, int y, int searchBarXSize, int searchBarYSize, int searchBarPadding, GuiTextField textField, boolean focus) { ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft()); String renderText = prependText + textField.getText(); @@ -396,13 +382,7 @@ public class GuiElementTextField { borderColour = customBorderColour; } //bar background - Gui.drawRect( - x - paddingUnscaled, - y - paddingUnscaled, - x + searchBarXSize + paddingUnscaled, - bottomTextBox + paddingUnscaled, - borderColour - ); + Gui.drawRect(x - paddingUnscaled, y - paddingUnscaled, x + searchBarXSize + paddingUnscaled, bottomTextBox + paddingUnscaled, borderColour); Gui.drawRect(x, y, x + searchBarXSize, bottomTextBox, Color.BLACK.getRGB()); //bar text @@ -437,34 +417,16 @@ public class GuiElementTextField { float newLen = Minecraft.getMinecraft().fontRendererObj.getStringWidth(texts[yOffI]) * scale; xStartOffset = (int) ((searchBarXSize - newLen) / 2f); - TextRenderUtils.drawStringCenteredScaledMaxWidth( - texts[yOffI], - Minecraft.getMinecraft().fontRendererObj, - x + searchBarXSize / 2f, - y + searchBarYSize / 2f + yOff, - false, - searchBarXSize - 2, - Color.WHITE.getRGB() - ); + TextRenderUtils.drawStringCenteredScaledMaxWidth(texts[yOffI], Minecraft.getMinecraft().fontRendererObj, x + searchBarXSize / 2f, y + searchBarYSize / 2f + yOff, false, searchBarXSize - 2, Color.WHITE.getRGB()); } else { - Minecraft - .getMinecraft() - .fontRendererObj.drawString( - StringUtils.trimToWidth(texts[yOffI], searchBarXSize - 10), - x + 5, - y + (searchBarYSize - 8) / 2 + yOff, - Color.WHITE.getRGB() - ); + Minecraft.getMinecraft().fontRendererObj.drawString(StringUtils.trimToWidth(texts[yOffI], searchBarXSize - 10), x + 5, y + (searchBarYSize - 8) / 2 + yOff, Color.WHITE.getRGB()); } } if (focus && System.currentTimeMillis() % 1000 > 500) { String textNCBeforeCursor = textNoColor.substring(0, textField.getCursorPosition() + prependText.length()); int colorCodes = org.apache.commons.lang3.StringUtils.countMatches(textNCBeforeCursor, "\u00B6"); - String textBeforeCursor = text.substring( - 0, - textField.getCursorPosition() + prependText.length() + (((options & COLOUR) != 0) ? colorCodes * 2 : 0) - ); + String textBeforeCursor = text.substring(0, textField.getCursorPosition() + prependText.length() + (((options & COLOUR) != 0) ? colorCodes * 2 : 0)); int numLinesBeforeCursor = org.apache.commons.lang3.StringUtils.countMatches(textBeforeCursor, "\n"); int yOff = numLinesBeforeCursor * extraSize; @@ -476,26 +438,14 @@ public class GuiElementTextField { } else { textBeforeCursorWidth = (int) (Minecraft.getMinecraft().fontRendererObj.getStringWidth(split[split.length - 1]) * scale); } - Gui.drawRect( - x + xStartOffset + textBeforeCursorWidth, - y + (searchBarYSize - 8) / 2 - 1 + yOff, - x + xStartOffset + textBeforeCursorWidth + 1, - y + (searchBarYSize - 8) / 2 + 9 + yOff, - Color.WHITE.getRGB() - ); + Gui.drawRect(x + xStartOffset + textBeforeCursorWidth, y + (searchBarYSize - 8) / 2 - 1 + yOff, x + xStartOffset + textBeforeCursorWidth + 1, y + (searchBarYSize - 8) / 2 + 9 + yOff, Color.WHITE.getRGB()); } String selectedText = textField.getSelectedText(); if (!selectedText.isEmpty()) { System.out.println("Start"); - int leftIndex = Math.min( - textField.getCursorPosition() + prependText.length(), - textField.getSelectionEnd() + prependText.length() - ); - int rightIndex = Math.max( - textField.getCursorPosition() + prependText.length(), - textField.getSelectionEnd() + prependText.length() - ); + int leftIndex = Math.min(textField.getCursorPosition() + prependText.length(), textField.getSelectionEnd() + prependText.length()); + int rightIndex = Math.max(textField.getCursorPosition() + prependText.length(), textField.getSelectionEnd() + prependText.length()); float texX = 0; int texY = 0; @@ -523,13 +473,7 @@ public class GuiElementTextField { if (c == '\n') { if (i >= leftIndex && i < rightIndex) { - Gui.drawRect( - x + xStartOffset + (int) texX, - y + (searchBarYSize - 8) / 2 - 1 + texY, - x + xStartOffset + (int) texX + 3, - y + (searchBarYSize - 8) / 2 + 9 + texY, - Color.LIGHT_GRAY.getRGB() - ); + Gui.drawRect(x + xStartOffset + (int) texX, y + (searchBarYSize - 8) / 2 - 1 + texY, x + xStartOffset + (int) texX + 3, y + (searchBarYSize - 8) / 2 + 9 + texY, Color.LIGHT_GRAY.getRGB()); } texX = 0; @@ -543,33 +487,11 @@ public class GuiElementTextField { int len = Minecraft.getMinecraft().fontRendererObj.getStringWidth(String.valueOf(c)); if (bold) len++; if (i >= leftIndex && i < rightIndex) { - Gui.drawRect( - x + xStartOffset + (int) texX, - y + (searchBarYSize - 8) / 2 - 1 + texY, - x + xStartOffset + (int) (texX + len * scale), - y + (searchBarYSize - 8) / 2 + 9 + texY, - Color.LIGHT_GRAY.getRGB() - ); - - TextRenderUtils.drawStringScaled( - String.valueOf(c), - Minecraft.getMinecraft().fontRendererObj, - x + xStartOffset + texX, - y + searchBarYSize / 2f - scale * 8 / 2f + texY, - false, - Color.BLACK.getRGB(), - scale - ); + Gui.drawRect(x + xStartOffset + (int) texX, y + (searchBarYSize - 8) / 2 - 1 + texY, x + xStartOffset + (int) (texX + len * scale), y + (searchBarYSize - 8) / 2 + 9 + texY, Color.LIGHT_GRAY.getRGB()); + + TextRenderUtils.drawStringScaled(String.valueOf(c), Minecraft.getMinecraft().fontRendererObj, x + xStartOffset + texX, y + searchBarYSize / 2f - scale * 8 / 2f + texY, false, Color.BLACK.getRGB(), scale); if (bold) { - TextRenderUtils.drawStringScaled( - String.valueOf(c), - Minecraft.getMinecraft().fontRendererObj, - x + xStartOffset + texX + 1, - y + searchBarYSize / 2f - scale * 8 / 2f + texY, - false, - Color.BLACK.getRGB(), - scale - ); + TextRenderUtils.drawStringScaled(String.valueOf(c), Minecraft.getMinecraft().fontRendererObj, x + xStartOffset + texX + 1, y + searchBarYSize / 2f - scale * 8 / 2f + texY, false, Color.BLACK.getRGB(), scale); } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorAccordion.java b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorAccordion.java index 7888587..dad85a6 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorAccordion.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorAccordion.java @@ -60,15 +60,7 @@ public class GuiOptionEditorAccordion extends GuiOptionEditor { GlStateManager.enableTexture2D(); GlStateManager.disableBlend(); - TextRenderUtils.drawStringScaledMaxWidth( - option.name, - Minecraft.getMinecraft().fontRendererObj, - x + 18, - y + 6, - false, - width - 10, - 0xc0c0c0 - ); + TextRenderUtils.drawStringScaledMaxWidth(option.name, Minecraft.getMinecraft().fontRendererObj, x + 18, y + 6, false, width - 10, 0xc0c0c0); } @Override diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorButton.java b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorButton.java index d3dc74f..1950c27 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorButton.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorButton.java @@ -37,15 +37,7 @@ public class GuiOptionEditorButton extends GuiOptionEditor { RenderUtils.drawTexturedRect(x + width / 6 - 24, y + height - 7 - 14, 48, 16); if (buttonText != null) { - TextRenderUtils.drawStringCenteredScaledMaxWidth( - buttonText, - Minecraft.getMinecraft().fontRendererObj, - x + width / 6, - y + height - 7 - 6, - false, - 44, - 0xFF303030 - ); + TextRenderUtils.drawStringCenteredScaledMaxWidth(buttonText, Minecraft.getMinecraft().fontRendererObj, x + width / 6, y + height - 7 - 6, false, 44, 0xFF303030); } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorColour.java b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorColour.java index e64d14c..95bc868 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorColour.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorColour.java @@ -50,14 +50,7 @@ public class GuiOptionEditorColour extends GuiOptionEditor { public boolean mouseInput(int x, int y, int width, int mouseX, int mouseY) { int height = getHeight(); - if ( - Mouse.getEventButtonState() && - Mouse.getEventButton() == 0 && - mouseX > x + width / 6 - 24 && - mouseX < x + width / 6 + 24 && - mouseY > y + height - 7 - 14 && - mouseY < y + height - 7 + 2 - ) { + if (Mouse.getEventButtonState() && Mouse.getEventButton() == 0 && mouseX > x + width / 6 - 24 && mouseX < x + width / 6 + 24 && mouseY > y + height - 7 - 14 && mouseY < y + height - 7 + 2) { colourElement = new GuiElementColour( mouseX, diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorDraggableList.java b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorDraggableList.java index 6de0223..e0a9064 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorDraggableList.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorDraggableList.java @@ -63,15 +63,7 @@ public class GuiOptionEditorDraggableList extends GuiOptionEditor { Minecraft.getMinecraft().getTextureManager().bindTexture(button_tex); RenderUtils.drawTexturedRect(x + width / 6f - 24, y + 45 - 7 - 14, 48, 16); - TextRenderUtils.drawStringCenteredScaledMaxWidth( - "Add", - Minecraft.getMinecraft().fontRendererObj, - x + width / 6f, - y + 45 - 7 - 6, - false, - 44, - 0xFF303030 - ); + TextRenderUtils.drawStringCenteredScaledMaxWidth("Add", Minecraft.getMinecraft().fontRendererObj, x + width / 6f, y + 45 - 7 - 6, false, 44, 0xFF303030); long currentTime = System.currentTimeMillis(); float greenBlue = LerpUtils.clampZeroOne(((trashHoverTime < 0 ? 250 : 0) + trashHoverTime - currentTime) / 250f); @@ -94,15 +86,7 @@ public class GuiOptionEditorDraggableList extends GuiOptionEditor { if (i++ != dragStartIndex) { for (int multilineIndex = 0; multilineIndex < multilines.length; multilineIndex++) { String line = multilines[multilineIndex]; - Utils.drawStringScaledMaxWidth( - line + EnumChatFormatting.RESET, - Minecraft.getMinecraft().fontRendererObj, - x + 20, - y + 50 + yOff + multilineIndex * 10, - true, - width - 20, - 0xffffffff - ); + Utils.drawStringScaledMaxWidth(line + EnumChatFormatting.RESET, Minecraft.getMinecraft().fontRendererObj, x + 20, y + 50 + yOff + multilineIndex * 10, true, width - 20, 0xffffffff); } Minecraft.getMinecraft().fontRendererObj.drawString("\u2261", x + 10, y + 50 + yOff + ySize / 2f - 4, 0xffffff, true); } @@ -143,15 +127,7 @@ public class GuiOptionEditorDraggableList extends GuiOptionEditor { if (str.isEmpty()) { str = ""; } - TextRenderUtils.drawStringScaledMaxWidth( - str.replaceAll("(\n.*)+", " ..."), - fr, - left + 3, - top + 3 + dropdownY, - false, - dropdownWidth - 6, - 0xffa0a0a0 - ); + TextRenderUtils.drawStringScaledMaxWidth(str.replaceAll("(\n.*)+", " ..."), fr, left + 3, top + 3 + dropdownY, false, dropdownWidth - 6, 0xffa0a0a0); dropdownY += 12; } } else if (currentDragging >= 0) { @@ -169,12 +145,7 @@ public class GuiOptionEditorDraggableList extends GuiOptionEditor { ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); int mouseX = Mouse.getX() * scaledResolution.getScaledWidth() / Minecraft.getMinecraft().displayWidth; - int mouseY = - scaledResolution.getScaledHeight() - - Mouse.getY() * - scaledResolution.getScaledHeight() / - Minecraft.getMinecraft().displayHeight - - 1; + int mouseY = scaledResolution.getScaledHeight() - Mouse.getY() * scaledResolution.getScaledHeight() / Minecraft.getMinecraft().displayHeight - 1; String str = exampleText[currentDragging]; @@ -183,37 +154,18 @@ public class GuiOptionEditorDraggableList extends GuiOptionEditor { GlStateManager.enableBlend(); for (int multilineIndex = 0; multilineIndex < multilines.length; multilineIndex++) { String line = multilines[multilineIndex]; - Utils.drawStringScaledMaxWidth( - line + EnumChatFormatting.RESET, - Minecraft.getMinecraft().fontRendererObj, - dragOffsetX + mouseX + 10, - dragOffsetY + mouseY + multilineIndex * 10, - true, - width - 20, - 0xffffff | (opacity << 24) - ); + Utils.drawStringScaledMaxWidth(line + EnumChatFormatting.RESET, Minecraft.getMinecraft().fontRendererObj, dragOffsetX + mouseX + 10, dragOffsetY + mouseY + multilineIndex * 10, true, width - 20, 0xffffff | (opacity << 24)); } int ySize = multilines.length * 10; - Minecraft - .getMinecraft() - .fontRendererObj.drawString("\u2261", dragOffsetX + mouseX, dragOffsetY + mouseY + ySize / 2f - 4, 0xffffff, true); + Minecraft.getMinecraft().fontRendererObj.drawString("\u2261", dragOffsetX + mouseX, dragOffsetY + mouseY + ySize / 2f - 4, 0xffffff, true); } } @Override public boolean mouseInput(int x, int y, int width, int mouseX, int mouseY) { - if ( - !Mouse.getEventButtonState() && - !dropdownOpen && - dragStartIndex >= 0 && - Mouse.getEventButton() == 0 && - mouseX >= x + width / 6 + 27 - 3 && - mouseX <= x + width / 6 + 27 + 11 + 3 && - mouseY >= y + 45 - 7 - 13 - 3 && - mouseY <= y + 45 - 7 - 13 + 14 + 3 - ) { + if (!Mouse.getEventButtonState() && !dropdownOpen && dragStartIndex >= 0 && Mouse.getEventButton() == 0 && mouseX >= x + width / 6 + 27 - 3 && mouseX <= x + width / 6 + 27 + 11 + 3 && mouseY >= y + 45 - 7 - 13 - 3 && mouseY <= y + 45 - 7 - 13 + 14 + 3) { activeText.remove(dragStartIndex); currentDragging = -1; dragStartIndex = -1; @@ -224,13 +176,7 @@ public class GuiOptionEditorDraggableList extends GuiOptionEditor { currentDragging = -1; dragStartIndex = -1; if (trashHoverTime > 0) trashHoverTime = -System.currentTimeMillis(); - } else if ( - currentDragging >= 0 && - mouseX >= x + width / 6 + 27 - 3 && - mouseX <= x + width / 6 + 27 + 11 + 3 && - mouseY >= y + 45 - 7 - 13 - 3 && - mouseY <= y + 45 - 7 - 13 + 14 + 3 - ) { + } else if (currentDragging >= 0 && mouseX >= x + width / 6 + 27 - 3 && mouseX <= x + width / 6 + 27 + 11 + 3 && mouseY >= y + 45 - 7 - 13 - 3 && mouseY <= y + 45 - 7 - 13 + 14 + 3) { if (trashHoverTime < 0) trashHoverTime = System.currentTimeMillis(); } else { if (trashHoverTime > 0) trashHoverTime = -System.currentTimeMillis(); @@ -269,13 +215,7 @@ public class GuiOptionEditorDraggableList extends GuiOptionEditor { return true; } - if ( - activeText.size() < exampleText.length && - mouseX > x + width / 6 - 24 && - mouseX < x + width / 6 + 24 && - mouseY > y + 45 - 7 - 14 && - mouseY < y + 45 - 7 + 2 - ) { + if (activeText.size() < exampleText.length && mouseX > x + width / 6 - 24 && mouseX < x + width / 6 + 24 && mouseY > y + 45 - 7 - 14 && mouseY < y + 45 - 7 + 2) { dropdownOpen = !dropdownOpen; dragOffsetX = mouseX; dragOffsetY = mouseY; diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorSlider.java b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorSlider.java index 1e27684..49376e4 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorSlider.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorSlider.java @@ -25,11 +25,7 @@ public class GuiOptionEditorSlider extends GuiOptionEditor { } else { strVal = Float.toString(floatVal); } - textField = - new GuiElementTextField( - strVal, - GuiElementTextField.NO_SPACE | GuiElementTextField.NUM_ONLY | GuiElementTextField.SCALE_TEXT - ); + textField = new GuiElementTextField(strVal, GuiElementTextField.NO_SPACE | GuiElementTextField.NUM_ONLY | GuiElementTextField.SCALE_TEXT); } slider = diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiPositionEditor.java b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiPositionEditor.java index 0fae02e..1f31ec7 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiPositionEditor.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiPositionEditor.java @@ -26,14 +26,7 @@ public class GuiPositionEditor extends GuiScreen { private int guiScaleOverride = -1; - public GuiPositionEditor( - Position position, - int elementWidth, - int elementHeight, - Runnable renderCallback, - Runnable positionChangedCallback, - Runnable closedCallback - ) { + public GuiPositionEditor(Position position, int elementWidth, int elementHeight, Runnable renderCallback, Runnable positionChangedCallback, Runnable closedCallback) { this.position = position; this.originalPosition = position.clone(); this.elementWidth = elementWidth == -1 ? this.width : elementWidth; @@ -90,22 +83,8 @@ public class GuiPositionEditor extends GuiScreen { } scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); - Utils.drawStringCentered( - "Position Editor", - Minecraft.getMinecraft().fontRendererObj, - scaledResolution.getScaledWidth() / 2f, - 8, - true, - 0xffffff - ); - Utils.drawStringCentered( - "R to Reset - Arrow keys/mouse to move", - Minecraft.getMinecraft().fontRendererObj, - scaledResolution.getScaledWidth() / 2f, - 18, - true, - 0xffffff - ); + Utils.drawStringCentered("Position Editor", Minecraft.getMinecraft().fontRendererObj, scaledResolution.getScaledWidth() / 2f, 8, true, 0xffffff); + Utils.drawStringCentered("R to Reset - Arrow keys/mouse to move", Minecraft.getMinecraft().fontRendererObj, scaledResolution.getScaledWidth() / 2f, 18, true, 0xffffff); } @Override diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/config/struct/ConfigProcessor.java b/src/main/java/com/thatgravyboat/skyblockhud/core/config/struct/ConfigProcessor.java index 5b51f34..f1f8733 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/config/struct/ConfigProcessor.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/config/struct/ConfigProcessor.java @@ -91,13 +91,7 @@ public class ConfigProcessor { if (optionPresent) { ConfigOption optionAnnotation = optionField.getAnnotation(ConfigOption.class); - ProcessedOption option = new ProcessedOption( - optionAnnotation.name(), - optionAnnotation.desc(), - optionAnnotation.subcategoryId(), - optionField, - categoryObj - ); + ProcessedOption option = new ProcessedOption(optionAnnotation.name(), optionAnnotation.desc(), optionAnnotation.subcategoryId(), optionField, categoryObj); if (optionField.isAnnotationPresent(ConfigAccordionId.class)) { ConfigAccordionId annotation = optionField.getAnnotation(ConfigAccordionId.class); option.accordionId = annotation.id(); @@ -107,13 +101,7 @@ public class ConfigProcessor { Class optionType = optionField.getType(); if (optionField.isAnnotationPresent(ConfigEditorButton.class)) { ConfigEditorButton configEditorAnnotation = optionField.getAnnotation(ConfigEditorButton.class); - editor = - new GuiOptionEditorButton( - option, - configEditorAnnotation.runnableId(), - configEditorAnnotation.buttonText(), - config - ); + editor = new GuiOptionEditorButton(option, configEditorAnnotation.runnableId(), configEditorAnnotation.buttonText(), config); } if (optionType.isAssignableFrom(boolean.class) && optionField.isAnnotationPresent(ConfigEditorBoolean.class)) { editor = new GuiOptionEditorBoolean(option); @@ -130,42 +118,24 @@ public class ConfigProcessor { } if (optionType.isAssignableFrom(List.class)) { if (optionField.isAnnotationPresent(ConfigEditorDraggableList.class)) { - ConfigEditorDraggableList configEditorAnnotation = optionField.getAnnotation( - ConfigEditorDraggableList.class - ); + ConfigEditorDraggableList configEditorAnnotation = optionField.getAnnotation(ConfigEditorDraggableList.class); editor = new GuiOptionEditorDraggableList(option, configEditorAnnotation.exampleText()); } } if (optionType.isAssignableFrom(String.class)) { if (optionField.isAnnotationPresent(ConfigEditorDropdown.class)) { ConfigEditorDropdown configEditorAnnotation = optionField.getAnnotation(ConfigEditorDropdown.class); - editor = - new GuiOptionEditorDropdown( - option, - configEditorAnnotation.values(), - configEditorAnnotation.initialIndex(), - false - ); + editor = new GuiOptionEditorDropdown(option, configEditorAnnotation.values(), configEditorAnnotation.initialIndex(), false); } else if (optionField.isAnnotationPresent(ConfigEditorColour.class)) { editor = new GuiOptionEditorColour(option); } else if (optionField.isAnnotationPresent(ConfigEditorText.class)) { editor = new GuiOptionEditorText(option); } } - if ( - optionType.isAssignableFrom(int.class) || - optionType.isAssignableFrom(float.class) || - optionType.isAssignableFrom(double.class) - ) { + if (optionType.isAssignableFrom(int.class) || optionType.isAssignableFrom(float.class) || optionType.isAssignableFrom(double.class)) { if (optionField.isAnnotationPresent(ConfigEditorSlider.class)) { ConfigEditorSlider configEditorAnnotation = optionField.getAnnotation(ConfigEditorSlider.class); - editor = - new GuiOptionEditorSlider( - option, - configEditorAnnotation.minValue(), - configEditorAnnotation.maxValue(), - configEditorAnnotation.minStep() - ); + editor = new GuiOptionEditorSlider(option, configEditorAnnotation.minValue(), configEditorAnnotation.maxValue(), configEditorAnnotation.minStep()); } } if (optionType.isAssignableFrom(String.class)) { diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/util/GuiElementSlider.java b/src/main/java/com/thatgravyboat/skyblockhud/core/util/GuiElementSlider.java index bc9a694..9d9fcbd 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/util/GuiElementSlider.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/util/GuiElementSlider.java @@ -27,16 +27,7 @@ public class GuiElementSlider extends GuiElement { private boolean clicked = false; - public GuiElementSlider( - int x, - int y, - int width, - float minValue, - float maxValue, - float minStep, - float value, - Consumer setCallback - ) { + public GuiElementSlider(int x, int y, int width, float minValue, float maxValue, float minStep, float value, Consumer setCallback) { if (minStep < 0) minStep = 0.01f; this.x = x; diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/util/render/RenderUtils.java b/src/main/java/com/thatgravyboat/skyblockhud/core/util/render/RenderUtils.java index 963e1f7..bbaabb8 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/util/render/RenderUtils.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/util/render/RenderUtils.java @@ -23,16 +23,7 @@ public class RenderUtils { if (OpenGlHelper.isFramebufferEnabled()) { ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); - BackgroundBlur.renderBlurredBackground( - 15, - scaledResolution.getScaledWidth(), - scaledResolution.getScaledHeight(), - x, - y, - width, - height, - true - ); + BackgroundBlur.renderBlurredBackground(15, scaledResolution.getScaledWidth(), scaledResolution.getScaledHeight(), x, y, width, height, true); } else { alpha = 0xff000000; } @@ -95,17 +86,7 @@ public class RenderUtils { drawTexturedRect(x, y, width, height, uMin, uMax, vMin, vMax, GL11.GL_NEAREST); } - public static void drawTexturedRect( - float x, - float y, - float width, - float height, - float uMin, - float uMax, - float vMin, - float vMax, - int filter - ) { + public static void drawTexturedRect(float x, float y, float width, float height, float uMin, float uMax, float vMin, float vMax, int filter) { GlStateManager.enableBlend(); GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); @@ -114,17 +95,7 @@ public class RenderUtils { GlStateManager.disableBlend(); } - public static void drawTexturedRectNoBlend( - float x, - float y, - float width, - float height, - float uMin, - float uMax, - float vMin, - float vMax, - int filter - ) { + public static void drawTexturedRectNoBlend(float x, float y, float width, float height, float uMin, float uMax, float vMin, float vMax, int filter) { GlStateManager.enableTexture2D(); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, filter); diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/util/render/TextRenderUtils.java b/src/main/java/com/thatgravyboat/skyblockhud/core/util/render/TextRenderUtils.java index f160c04..7745562 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/util/render/TextRenderUtils.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/util/render/TextRenderUtils.java @@ -71,15 +71,7 @@ public class TextRenderUtils { GlStateManager.scale(1 / factor, 1 / factor, 1); } - public static void drawStringCenteredScaledMaxWidth( - String str, - FontRenderer fr, - float x, - float y, - boolean shadow, - int len, - int colour - ) { + public static void drawStringCenteredScaledMaxWidth(String str, FontRenderer fr, float x, float y, boolean shadow, int len, int colour) { int strLen = fr.getStringWidth(str); float factor = len / (float) strLen; factor = Math.min(1, factor); @@ -91,10 +83,7 @@ public class TextRenderUtils { } public static void renderToolTip(ItemStack stack, int mouseX, int mouseY, int screenWidth, int screenHeight, FontRenderer fontStd) { - List list = stack.getTooltip( - Minecraft.getMinecraft().thePlayer, - Minecraft.getMinecraft().gameSettings.advancedItemTooltips - ); + List list = stack.getTooltip(Minecraft.getMinecraft().thePlayer, Minecraft.getMinecraft().gameSettings.advancedItemTooltips); for (int i = 0; i < list.size(); ++i) { if (i == 0) { @@ -108,15 +97,7 @@ public class TextRenderUtils { drawHoveringText(list, mouseX, mouseY, screenWidth, screenHeight, -1, font == null ? fontStd : font); } - public static void drawHoveringText( - List textLines, - final int mouseX, - final int mouseY, - final int screenWidth, - final int screenHeight, - final int maxTextWidth, - FontRenderer font - ) { + public static void drawHoveringText(List textLines, final int mouseX, final int mouseY, final int screenWidth, final int screenHeight, final int maxTextWidth, FontRenderer font) { if (!textLines.isEmpty()) { GlStateManager.disableRescaleNormal(); RenderHelper.disableStandardItemLighting(); @@ -197,89 +178,17 @@ public class TextRenderUtils { final int zLevel = 300; final int backgroundColor = 0xF0100010; - RenderUtils.drawGradientRect( - zLevel, - tooltipX - 3, - tooltipY - 4, - tooltipX + tooltipTextWidth + 3, - tooltipY - 3, - backgroundColor, - backgroundColor - ); - RenderUtils.drawGradientRect( - zLevel, - tooltipX - 3, - tooltipY + tooltipHeight + 3, - tooltipX + tooltipTextWidth + 3, - tooltipY + tooltipHeight + 4, - backgroundColor, - backgroundColor - ); - RenderUtils.drawGradientRect( - zLevel, - tooltipX - 3, - tooltipY - 3, - tooltipX + tooltipTextWidth + 3, - tooltipY + tooltipHeight + 3, - backgroundColor, - backgroundColor - ); - RenderUtils.drawGradientRect( - zLevel, - tooltipX - 4, - tooltipY - 3, - tooltipX - 3, - tooltipY + tooltipHeight + 3, - backgroundColor, - backgroundColor - ); - RenderUtils.drawGradientRect( - zLevel, - tooltipX + tooltipTextWidth + 3, - tooltipY - 3, - tooltipX + tooltipTextWidth + 4, - tooltipY + tooltipHeight + 3, - backgroundColor, - backgroundColor - ); + RenderUtils.drawGradientRect(zLevel, tooltipX - 3, tooltipY - 4, tooltipX + tooltipTextWidth + 3, tooltipY - 3, backgroundColor, backgroundColor); + RenderUtils.drawGradientRect(zLevel, tooltipX - 3, tooltipY + tooltipHeight + 3, tooltipX + tooltipTextWidth + 3, tooltipY + tooltipHeight + 4, backgroundColor, backgroundColor); + RenderUtils.drawGradientRect(zLevel, tooltipX - 3, tooltipY - 3, tooltipX + tooltipTextWidth + 3, tooltipY + tooltipHeight + 3, backgroundColor, backgroundColor); + RenderUtils.drawGradientRect(zLevel, tooltipX - 4, tooltipY - 3, tooltipX - 3, tooltipY + tooltipHeight + 3, backgroundColor, backgroundColor); + RenderUtils.drawGradientRect(zLevel, tooltipX + tooltipTextWidth + 3, tooltipY - 3, tooltipX + tooltipTextWidth + 4, tooltipY + tooltipHeight + 3, backgroundColor, backgroundColor); final int borderColorStart = 0x505000FF; final int borderColorEnd = (borderColorStart & 0xFEFEFE) >> 1 | borderColorStart & 0xFF000000; - RenderUtils.drawGradientRect( - zLevel, - tooltipX - 3, - tooltipY - 3 + 1, - tooltipX - 3 + 1, - tooltipY + tooltipHeight + 3 - 1, - borderColorStart, - borderColorEnd - ); - RenderUtils.drawGradientRect( - zLevel, - tooltipX + tooltipTextWidth + 2, - tooltipY - 3 + 1, - tooltipX + tooltipTextWidth + 3, - tooltipY + tooltipHeight + 3 - 1, - borderColorStart, - borderColorEnd - ); - RenderUtils.drawGradientRect( - zLevel, - tooltipX - 3, - tooltipY - 3, - tooltipX + tooltipTextWidth + 3, - tooltipY - 3 + 1, - borderColorStart, - borderColorStart - ); - RenderUtils.drawGradientRect( - zLevel, - tooltipX - 3, - tooltipY + tooltipHeight + 2, - tooltipX + tooltipTextWidth + 3, - tooltipY + tooltipHeight + 3, - borderColorEnd, - borderColorEnd - ); + RenderUtils.drawGradientRect(zLevel, tooltipX - 3, tooltipY - 3 + 1, tooltipX - 3 + 1, tooltipY + tooltipHeight + 3 - 1, borderColorStart, borderColorEnd); + RenderUtils.drawGradientRect(zLevel, tooltipX + tooltipTextWidth + 2, tooltipY - 3 + 1, tooltipX + tooltipTextWidth + 3, tooltipY + tooltipHeight + 3 - 1, borderColorStart, borderColorEnd); + RenderUtils.drawGradientRect(zLevel, tooltipX - 3, tooltipY - 3, tooltipX + tooltipTextWidth + 3, tooltipY - 3 + 1, borderColorStart, borderColorStart); + RenderUtils.drawGradientRect(zLevel, tooltipX - 3, tooltipY + tooltipHeight + 2, tooltipX + tooltipTextWidth + 3, tooltipY + tooltipHeight + 3, borderColorEnd, borderColorEnd); for (int lineNumber = 0; lineNumber < textLines.size(); ++lineNumber) { String line = textLines.get(lineNumber); diff --git a/src/main/java/com/thatgravyboat/skyblockhud/dungeons/DungeonHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/dungeons/DungeonHandler.java index aff9c1e..2418b13 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/dungeons/DungeonHandler.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/dungeons/DungeonHandler.java @@ -124,11 +124,7 @@ public class DungeonHandler { public static void parseDeaths(String playerName) { if (playerName.toLowerCase().contains("deaths:")) { - String death = Utils - .removeColor(playerName.toLowerCase().replace("deaths:", "")) - .replace("(", "") - .replace(")", "") - .replace(" ", ""); + String death = Utils.removeColor(playerName.toLowerCase().replace("deaths:", "")).replace("(", "").replace(")", "").replace(" ", ""); try { deaths = Integer.parseInt(death); } catch (NumberFormatException ignored) {} diff --git a/src/main/java/com/thatgravyboat/skyblockhud/handlers/BossbarHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/handlers/BossbarHandler.java index 6f06f40..b2a148d 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/handlers/BossbarHandler.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/handlers/BossbarHandler.java @@ -22,11 +22,7 @@ public class BossbarHandler { bossBarRendered = false; } String bossName = Utils.removeColor(BossStatus.bossName); - if ( - SkyblockHud.config.renderer.hideBossBar && - DwarvenMineHandler.currentEvent == DwarvenMineHandler.Event.NONE && - !LocationHandler.getCurrentLocation().equals(Locations.CATACOMBS) - ) { + if (SkyblockHud.config.renderer.hideBossBar && DwarvenMineHandler.currentEvent == DwarvenMineHandler.Event.NONE && !LocationHandler.getCurrentLocation().equals(Locations.CATACOMBS)) { if (bossName.equalsIgnoreCase("wither")) { event.setCanceled(true); bossBarRendered = false; diff --git a/src/main/java/com/thatgravyboat/skyblockhud/handlers/CurrencyHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/handlers/CurrencyHandler.java index 847b6c7..7da9c9d 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/handlers/CurrencyHandler.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/handlers/CurrencyHandler.java @@ -34,16 +34,10 @@ public class CurrencyHandler { @SubscribeEvent public void onSidebarLineUpdate(SidebarLineUpdateEvent event) { - if ( - Utils.removeColor(event.formattedLine.toLowerCase().trim()).contains("purse:") || - Utils.removeColor(event.formattedLine.toLowerCase().trim()).contains("piggy:") - ) { + if (Utils.removeColor(event.formattedLine.toLowerCase().trim()).contains("purse:") || Utils.removeColor(event.formattedLine.toLowerCase().trim()).contains("piggy:")) { CurrencyHandler.checkCoins(event.formattedLine); } - if ( - Utils.removeColor(event.formattedLine.toLowerCase().trim()).contains("bits:") && - !event.formattedLine.toLowerCase().contains("(") - ) { + if (Utils.removeColor(event.formattedLine.toLowerCase().trim()).contains("bits:") && !event.formattedLine.toLowerCase().contains("(")) { CurrencyHandler.checkBits(event.formattedLine); } } @@ -69,12 +63,7 @@ public class CurrencyHandler { } public static void checkCoins(String formatedScoreboardLine) { - String purse = Utils - .removeWhiteSpaceAndRemoveWord( - Utils.removeColor(formatedScoreboardLine.toLowerCase().trim()), - Utils.removeColor(formatedScoreboardLine.toLowerCase().trim()).contains("purse:") ? "purse:" : "piggy:" - ) - .replace(",", ""); + String purse = Utils.removeWhiteSpaceAndRemoveWord(Utils.removeColor(formatedScoreboardLine.toLowerCase().trim()), Utils.removeColor(formatedScoreboardLine.toLowerCase().trim()).contains("purse:") ? "purse:" : "piggy:").replace(",", ""); if (!purse.contains("(") && !purse.contains("+")) { try { double coins = Double.parseDouble(Pattern.compile("[^0-9.]").matcher(purse).replaceAll("")); @@ -86,9 +75,7 @@ public class CurrencyHandler { } public static void checkBits(String formatedScoreboardLine) { - String bits = Utils - .removeWhiteSpaceAndRemoveWord(Utils.removeColor(formatedScoreboardLine.toLowerCase().trim()), "bits:") - .replace(",", ""); + String bits = Utils.removeWhiteSpaceAndRemoveWord(Utils.removeColor(formatedScoreboardLine.toLowerCase().trim()), "bits:").replace(",", ""); try { int bit = Integer.parseInt(Pattern.compile("[^0-9]").matcher(bits).replaceAll("")); CurrencyHandler.setBits(bit); diff --git a/src/main/java/com/thatgravyboat/skyblockhud/handlers/MapHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/handlers/MapHandler.java index c8ef43b..b7b232f 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/handlers/MapHandler.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/handlers/MapHandler.java @@ -58,11 +58,7 @@ public class MapHandler { public boolean canRender() { SBHConfig.Map mapConfig = SkyblockHud.config.map; - if (mapConfig.showInfoIcons && type.equals(MapIconTypes.INFO)) return true; else if ( - mapConfig.showMiscIcons && type.equals(MapIconTypes.MISC) - ) return true; else if (mapConfig.showNpcIcons && type.equals(MapIconTypes.NPC)) return true; else if ( - mapConfig.showQuestIcons && type.equals(MapIconTypes.QUEST) - ) return true; else return (mapConfig.showShopIcons && type.equals(MapIconTypes.SHOPS)); + if (mapConfig.showInfoIcons && type.equals(MapIconTypes.INFO)) return true; else if (mapConfig.showMiscIcons && type.equals(MapIconTypes.MISC)) return true; else if (mapConfig.showNpcIcons && type.equals(MapIconTypes.NPC)) return true; else if (mapConfig.showQuestIcons && type.equals(MapIconTypes.QUEST)) return true; else return (mapConfig.showShopIcons && type.equals(MapIconTypes.SHOPS)); } } @@ -85,17 +81,7 @@ public class MapHandler { public ResourceLocation mapTexture; public List icons; - Maps( - float scaleFactor, - int width, - int height, - int xMiniOffset, - int yMiniOffset, - int xOffset, - int yOffset, - ResourceLocation mapTexture, - List icons - ) { + Maps(float scaleFactor, int width, int height, int xMiniOffset, int yMiniOffset, int xOffset, int yOffset, ResourceLocation mapTexture, List icons) { this.scaleFactor = scaleFactor; this.width = width; this.height = height; @@ -119,16 +105,7 @@ public class MapHandler { mc.renderEngine.bindTexture(mapOverlay); GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f); Position pos = SkyblockHud.config.map.miniMapPosition; - Gui.drawModalRectWithCustomSizedTexture( - pos.getAbsX(event.resolution, 72), - pos.getAbsY(event.resolution, 72), - 72, - 0, - 72, - 72, - 256, - 256 - ); + Gui.drawModalRectWithCustomSizedTexture(pos.getAbsX(event.resolution, 72), pos.getAbsY(event.resolution, 72), 72, 0, 72, 72, 256, 256); mc.renderEngine.bindTexture(map.mapTexture); int x = mc.thePlayer.getPosition().getX() + map.xMiniOffset; @@ -139,60 +116,20 @@ public class MapHandler { GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_CLAMP); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_CLAMP); - Gui.drawModalRectWithCustomSizedTexture( - pos.getAbsX(event.resolution, 72) + 4, - pos.getAbsY(event.resolution, 72) + 2, - u, - v, - 64, - 64, - 256, - 256 - ); + Gui.drawModalRectWithCustomSizedTexture(pos.getAbsX(event.resolution, 72) + 4, pos.getAbsY(event.resolution, 72) + 2, u, v, 64, 64, 256, 256); if (SkyblockHud.config.map.showPlayerLocation) { - mc.fontRendererObj.drawString( - "\u2022", - pos.getAbsX(event.resolution, 72) + 36, - pos.getAbsY(event.resolution, 72) + 34, - 0xff0000, - false - ); + mc.fontRendererObj.drawString("\u2022", pos.getAbsX(event.resolution, 72) + 36, pos.getAbsY(event.resolution, 72) + 34, 0xff0000, false); } GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f); mc.renderEngine.bindTexture(mapOverlay); - Gui.drawModalRectWithCustomSizedTexture( - pos.getAbsX(event.resolution, 72), - pos.getAbsY(event.resolution, 72), - 0, - 0, - 72, - 72, - 256, - 256 - ); + Gui.drawModalRectWithCustomSizedTexture(pos.getAbsX(event.resolution, 72), pos.getAbsY(event.resolution, 72), 0, 0, 72, 72, 256, 256); String keyCode = GameSettings.getKeyDisplayString(KeyBindings.map.getKeyCode()); - Utils.drawStringCenteredScaled( - keyCode, - mc.fontRendererObj, - pos.getAbsX(event.resolution, 64) + 58, - pos.getAbsY(event.resolution, 72) + 66, - false, - 6, - 0xFFFFFF - ); + Utils.drawStringCenteredScaled(keyCode, mc.fontRendererObj, pos.getAbsX(event.resolution, 64) + 58, pos.getAbsY(event.resolution, 72) + 66, false, 6, 0xFFFFFF); BlockPos playerPos = mc.thePlayer.getPosition(); String position = String.format("%d/%d/%d", playerPos.getX(), playerPos.getY(), playerPos.getZ()); - Utils.drawStringCenteredScaled( - position, - mc.fontRendererObj, - pos.getAbsX(event.resolution, 64) + 29, - pos.getAbsY(event.resolution, 72) + 66, - false, - 36, - 0xFFFFFF - ); + Utils.drawStringCenteredScaled(position, mc.fontRendererObj, pos.getAbsX(event.resolution, 64) + 29, pos.getAbsY(event.resolution, 72) + 66, false, 36, 0xFFFFFF); GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f); } } @@ -200,11 +137,7 @@ public class MapHandler { @SubscribeEvent public void clientTick(TickEvent.ClientTickEvent event) { - if ( - KeyBindings.map.isPressed() && - LocationHandler.getCurrentLocation().getCategory().getMap() != null && - SkyblockHud.hasSkyblockScoreboard() - ) SkyblockHud.screenToOpen = new MapScreen(); + if (KeyBindings.map.isPressed() && LocationHandler.getCurrentLocation().getCategory().getMap() != null && SkyblockHud.hasSkyblockScoreboard()) SkyblockHud.screenToOpen = new MapScreen(); } public static class MapScreen extends GuiScreen { @@ -218,16 +151,7 @@ public class MapHandler { this.mc.renderEngine.bindTexture(map.mapTexture); float mapX = (width / 2f) - ((map.width / 2f) * map.scaleFactor); float mapY = (height / 2f) - ((map.height / 2f) * map.scaleFactor); - Gui.drawModalRectWithCustomSizedTexture( - (int) mapX, - (int) mapY, - 0, - 0, - (int) (map.width * map.scaleFactor), - (int) (map.height * map.scaleFactor), - (int) (map.width * map.scaleFactor), - (int) (map.height * map.scaleFactor) - ); + Gui.drawModalRectWithCustomSizedTexture((int) mapX, (int) mapY, 0, 0, (int) (map.width * map.scaleFactor), (int) (map.height * map.scaleFactor), (int) (map.width * map.scaleFactor), (int) (map.height * map.scaleFactor)); drawIcons((int) mapX, (int) mapY); if (this.mc.thePlayer != null && SkyblockHud.config.map.showPlayerLocation) { int x = this.mc.thePlayer.getPosition().getX() + map.xOffset; @@ -256,18 +180,7 @@ public class MapHandler { if (map.icons == null) return; for (MapIcon icon : map.icons) { if (!icon.canRender()) continue; - if ( - Utils.inRangeInclusive( - mouseX, - (int) ((icon.position.x + map.xOffset) * map.scaleFactor) + startX - 4, - (int) ((icon.position.x + map.xOffset) * map.scaleFactor) + startX + 4 - ) && - Utils.inRangeInclusive( - mouseY, - (int) ((icon.position.y + map.yOffset) * map.scaleFactor) + startY - 4, - (int) ((icon.position.y + map.yOffset) * map.scaleFactor) + startY + 4 - ) - ) { + if (Utils.inRangeInclusive(mouseX, (int) ((icon.position.x + map.xOffset) * map.scaleFactor) + startX - 4, (int) ((icon.position.x + map.xOffset) * map.scaleFactor) + startX + 4) && Utils.inRangeInclusive(mouseY, (int) ((icon.position.y + map.yOffset) * map.scaleFactor) + startY - 4, (int) ((icon.position.y + map.yOffset) * map.scaleFactor) + startY + 4)) { drawHoveringText(Arrays.asList(icon.tooltip.split("\n")), mouseX, mouseY); break; } @@ -280,18 +193,7 @@ public class MapHandler { int mapY = (int) ((height / 2f) - ((map.height / 2f) * map.scaleFactor)); for (MapIcon icon : map.icons) { if (!icon.canRender()) continue; - if ( - Utils.inRangeInclusive( - mouseX, - (int) ((icon.position.x + map.xOffset) * map.scaleFactor) + mapX - 4, - (int) ((icon.position.x + map.xOffset) * map.scaleFactor) + mapX + 4 - ) && - Utils.inRangeInclusive( - mouseY, - (int) ((icon.position.y + map.yOffset) * map.scaleFactor) + mapY - 4, - (int) ((icon.position.y + map.yOffset) * map.scaleFactor) + mapY + 4 - ) - ) { + if (Utils.inRangeInclusive(mouseX, (int) ((icon.position.x + map.xOffset) * map.scaleFactor) + mapX - 4, (int) ((icon.position.x + map.xOffset) * map.scaleFactor) + mapX + 4) && Utils.inRangeInclusive(mouseY, (int) ((icon.position.y + map.yOffset) * map.scaleFactor) + mapY - 4, (int) ((icon.position.y + map.yOffset) * map.scaleFactor) + mapY + 4)) { if (!icon.command.isEmpty()) { this.mc.thePlayer.sendChatMessage("/" + icon.command); } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/handlers/SlayerHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/handlers/SlayerHandler.java index b25733b..fbb95eb 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/handlers/SlayerHandler.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/handlers/SlayerHandler.java @@ -60,15 +60,7 @@ public class SlayerHandler { public void onSidebarPost(SidebarPostEvent event) { String arrayString = Arrays.toString(event.arrayScores); isDoingSlayer = Arrays.toString(event.arrayScores).contains("Slayer Quest"); - if ( - isDoingSlayer && - ( - currentSlayer.equals(slayerTypes.NONE) || - !arrayString - .replace(" ", "") - .contains(currentSlayer.getDisplayName().replace(" ", "") + Utils.intToRomanNumeral(slayerTier)) - ) - ) { + if (isDoingSlayer && (currentSlayer.equals(slayerTypes.NONE) || !arrayString.replace(" ", "").contains(currentSlayer.getDisplayName().replace(" ", "") + Utils.intToRomanNumeral(slayerTier)))) { for (int i = 0; i < event.scores.size(); i++) { String line = event.scores.get(i); if (line.contains("Slayer Quest") && event.scores.size() > 3) { @@ -81,8 +73,7 @@ public class SlayerHandler { } } SlayerHandler.currentSlayer = selectedSlayer; - SlayerHandler.slayerTier = - Utils.whatRomanNumeral(slayer.replace(selectedSlayer.getDisplayName().toLowerCase(), "").replace(" ", "")); + SlayerHandler.slayerTier = Utils.whatRomanNumeral(slayer.replace(selectedSlayer.getDisplayName().toLowerCase(), "").replace(" ", "")); break; } } @@ -118,9 +109,7 @@ public class SlayerHandler { progress = Integer.parseInt(xpMatcher.group(1)); } catch (Exception ignored) {} try { - maxKills = - Integer.parseInt(xpMatcher.group(2).replace("k", "")) * - (xpMatcher.group(2).contains("k") ? 1000 : xpMatcher.group(2).contains("m") ? 1000000 : 1); + maxKills = Integer.parseInt(xpMatcher.group(2).replace("k", "")) * (xpMatcher.group(2).contains("k") ? 1000 : xpMatcher.group(2).contains("m") ? 1000000 : 1); } catch (Exception ignored) {} } else if (line.contains("slay the boss")) { SlayerHandler.bossSlain = false; diff --git a/src/main/java/com/thatgravyboat/skyblockhud/handlers/mapicons/DwarvenIcons.java b/src/main/java/com/thatgravyboat/skyblockhud/handlers/mapicons/DwarvenIcons.java index 3ef4179..e599508 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/handlers/mapicons/DwarvenIcons.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/handlers/mapicons/DwarvenIcons.java @@ -20,79 +20,20 @@ public class DwarvenIcons { } private static void setupNpcIcons() { - dwarvenIcons.add( - new MapHandler.MapIcon( - new Vector2f(129, 187), - new ResourceLocation("skyblockhud", "maps/icons/puzzle.png"), - new ComponentBuilder() - .nl("Puzzler", new char[] { 'a', 'l' }) - .nl("Description", 'l') - .nl("The Puzzler gives you a small puzzle each day to solve and") - .nl("gives you 1000 mithril powder.") - .build(), - MapHandler.MapIconTypes.NPC - ) - ); + dwarvenIcons.add(new MapHandler.MapIcon(new Vector2f(129, 187), new ResourceLocation("skyblockhud", "maps/icons/puzzle.png"), new ComponentBuilder().nl("Puzzler", new char[] { 'a', 'l' }).nl("Description", 'l').nl("The Puzzler gives you a small puzzle each day to solve and").nl("gives you 1000 mithril powder.").build(), MapHandler.MapIconTypes.NPC)); } private static void setupMiscIcons() {} private static void setupInfoIcons() { - dwarvenIcons.add( - new MapHandler.MapIcon( - new Vector2f(129, 187), - new ResourceLocation("skyblockhud", "maps/icons/crown.png"), - new ComponentBuilder() - .nl("King", new char[] { 'a', 'l' }) - .nl("Description", 'l') - .nl("The King allows you to first start commissions and if you click") - .nl("each king which change every skyblock day you will get") - .nl("the King Talisman.") - .nl() - .apd("Click to open HOTM", new char[] { '6', 'l' }) - .build(), - MapHandler.MapIconTypes.INFO, - "hotm" - ) - ); + dwarvenIcons.add(new MapHandler.MapIcon(new Vector2f(129, 187), new ResourceLocation("skyblockhud", "maps/icons/crown.png"), new ComponentBuilder().nl("King", new char[] { 'a', 'l' }).nl("Description", 'l').nl("The King allows you to first start commissions and if you click").nl("each king which change every skyblock day you will get").nl("the King Talisman.").nl().apd("Click to open HOTM", new char[] { '6', 'l' }).build(), MapHandler.MapIconTypes.INFO, "hotm")); } private static void setupShopIcons() { - dwarvenIcons.add( - new MapHandler.MapIcon( - new Vector2f(4, 8), - new ResourceLocation("skyblockhud", "maps/icons/blacksmith.png"), - new ComponentBuilder() - .nl("Forge", new char[] { 'a', 'l' }) - .nl("Description", 'l') - .nl("The Forge is where you can go craft special items") - .nl("and fuel your drill.") - .nl("NPCS", new char[] { 'c', 'l' }) - .nl(" Forger - Allows you to forge special items") - .nl(" Jotraeline Greatforge - Allows you to refuel your drill.") - .nl() - .apd("Click to warp", new char[] { '6', 'l' }) - .build(), - MapHandler.MapIconTypes.SHOPS, - "warpforge" - ) - ); + dwarvenIcons.add(new MapHandler.MapIcon(new Vector2f(4, 8), new ResourceLocation("skyblockhud", "maps/icons/blacksmith.png"), new ComponentBuilder().nl("Forge", new char[] { 'a', 'l' }).nl("Description", 'l').nl("The Forge is where you can go craft special items").nl("and fuel your drill.").nl("NPCS", new char[] { 'c', 'l' }).nl(" Forger - Allows you to forge special items").nl(" Jotraeline Greatforge - Allows you to refuel your drill.").nl().apd("Click to warp", new char[] { '6', 'l' }).build(), MapHandler.MapIconTypes.SHOPS, "warpforge")); } private static void setupQuestIcons() { - dwarvenIcons.add( - new MapHandler.MapIcon( - new Vector2f(67, 204), - new ResourceLocation("skyblockhud", "maps/icons/special.png"), - new ComponentBuilder() - .nl("Royal Resident", new char[] { 'a', 'l' }) - .nl("The Royal Resident is a quest where you right") - .nl("click them for a bit to obtain and if you continue") - .nl("to right click them for about 7 hours it will give") - .apd("the achievement Royal Conversation.") - .build(), - MapHandler.MapIconTypes.QUEST - ) - ); + dwarvenIcons.add(new MapHandler.MapIcon(new Vector2f(67, 204), new ResourceLocation("skyblockhud", "maps/icons/special.png"), new ComponentBuilder().nl("Royal Resident", new char[] { 'a', 'l' }).nl("The Royal Resident is a quest where you right").nl("click them for a bit to obtain and if you continue").nl("to right click them for about 7 hours it will give").apd("the achievement Royal Conversation.").build(), MapHandler.MapIconTypes.QUEST)); } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/handlers/mapicons/HubIcons.java b/src/main/java/com/thatgravyboat/skyblockhud/handlers/mapicons/HubIcons.java index 4539f35..443afb7 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/handlers/mapicons/HubIcons.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/handlers/mapicons/HubIcons.java @@ -20,307 +20,36 @@ public class HubIcons { } private static void setupNpcIcons() { - hubIcons.add( - new MapHandler.MapIcon( - new Vector2f(-2, -34), - new ResourceLocation("skyblockhud", "maps/icons/special.png"), - new ComponentBuilder() - .nl("Event Hut", new char[] { 'a', 'l' }) - .nl("Description", 'l') - .nl("The Event Hut is where special event npcs") - .nl("are during some events.") - .nl("NPCS", new char[] { 'c', 'l' }) - .nl(" Baker - During New Years") - .nl(" Jerry - While Winter Island is opened") - .nl(" Fear Mongerer - During Spooky Festival") - .apd(" Oringo - During Traveling Zoo") - .build(), - MapHandler.MapIconTypes.NPC - ) - ); - hubIcons.add( - new MapHandler.MapIcon( - new Vector2f(135, 142), - new ResourceLocation("skyblockhud", "maps/icons/fairy.png"), - new ComponentBuilder() - .nl("Fairy", new char[] { 'a', 'l' }) - .nl("Description", 'l') - .nl("The Fairy is where you go when you find fairy souls") - .apd("to trade them in to get permanent stat upgrades.") - .build(), - MapHandler.MapIconTypes.NPC - ) - ); + hubIcons.add(new MapHandler.MapIcon(new Vector2f(-2, -34), new ResourceLocation("skyblockhud", "maps/icons/special.png"), new ComponentBuilder().nl("Event Hut", new char[] { 'a', 'l' }).nl("Description", 'l').nl("The Event Hut is where special event npcs").nl("are during some events.").nl("NPCS", new char[] { 'c', 'l' }).nl(" Baker - During New Years").nl(" Jerry - While Winter Island is opened").nl(" Fear Mongerer - During Spooky Festival").apd(" Oringo - During Traveling Zoo").build(), MapHandler.MapIconTypes.NPC)); + hubIcons.add(new MapHandler.MapIcon(new Vector2f(135, 142), new ResourceLocation("skyblockhud", "maps/icons/fairy.png"), new ComponentBuilder().nl("Fairy", new char[] { 'a', 'l' }).nl("Description", 'l').nl("The Fairy is where you go when you find fairy souls").apd("to trade them in to get permanent stat upgrades.").build(), MapHandler.MapIconTypes.NPC)); } private static void setupShopIcons() { - hubIcons.add( - new MapHandler.MapIcon( - new Vector2f(-50, -22), - new ResourceLocation("skyblockhud", "maps/icons/building.png"), - new ComponentBuilder() - .nl("Builder's House", new char[] { 'a', 'l' }) - .nl("NPCS", new char[] { 'c', 'l' }) - .nl(" Wool Weaver") - .nl(" Builder") - .apd(" Mad Redstone Engineer") - .build(), - MapHandler.MapIconTypes.SHOPS - ) - ); - hubIcons.add( - new MapHandler.MapIcon( - new Vector2f(-78, -46), - new ResourceLocation("skyblockhud", "maps/icons/bar.png"), - new ComponentBuilder() - .nl("Tavern", new char[] { 'a', 'l' }) - .nl("NPCS", new char[] { 'c', 'l' }) - .nl(" Bartender") - .nl(" Maddox the slayer") - .nl("Description", 'l') - .nl("The Tavern is where maddox the slayer is located you can") - .nl("start slayer quests with them to unlock") - .apd("new items the more slayer bosses you kill.") - .build(), - MapHandler.MapIconTypes.SHOPS - ) - ); - hubIcons.add( - new MapHandler.MapIcon( - new Vector2f(36, -82), - new ResourceLocation("skyblockhud", "maps/icons/vet.png"), - new ComponentBuilder() - .nl("Vet", new char[] { 'a', 'l' }) - .nl("NPCS", new char[] { 'c', 'l' }) - .nl(" Bea") - .nl(" Zog") - .nl(" Kat") - .nl(" George") - .nl("Description", 'l') - .nl("The Vet is where you go to upgrade your pet") - .nl("at Kat or to buy pet upgrade items from Zog") - .nl("or trade in your pet at George and if you're") - .apd("a new player you can buy a bee pet from Bea.") - .build(), - MapHandler.MapIconTypes.SHOPS - ) - ); - hubIcons.add( - new MapHandler.MapIcon( - new Vector2f(58, -73), - new ResourceLocation("skyblockhud", "maps/icons/fishing_merchant.png"), - new ComponentBuilder() - .nl("Fishing Merchant", new char[] { 'a', 'l' }) - .nl("Description", 'l') - .nl("The Fishing Merchant allows you to buy") - .nl("fishing related items and he has his friend") - .nl("joe whose in the house hes setup") - .apd("in front of who sells sponges.") - .build(), - MapHandler.MapIconTypes.SHOPS - ) - ); - hubIcons.add( - new MapHandler.MapIcon( - new Vector2f(46, -53), - new ResourceLocation("skyblockhud", "maps/icons/witch.png"), - new ComponentBuilder() - .nl("Alchemist", new char[] { 'a', 'l' }) - .nl("Description", 'l') - .nl("The Alchemist allows you to buy") - .apd("potion making related items") - .build(), - MapHandler.MapIconTypes.SHOPS - ) - ); - hubIcons.add( - new MapHandler.MapIcon( - new Vector2f(-4, -128), - new ResourceLocation("skyblockhud", "maps/icons/metal_merchants.png"), - new ComponentBuilder() - .nl("Blacksmith Merchants", new char[] { 'a', 'l' }) - .nl("Merchants", new char[] { 'c', 'l' }) - .nl(" Weaponsmith - Weapon Related Items") - .nl(" Armorsmith - Armor Related Items") - .apd(" Mine Merchant - Mining Related Items") - .build(), - MapHandler.MapIconTypes.SHOPS - ) - ); - hubIcons.add( - new MapHandler.MapIcon( - new Vector2f(-30, -120), - new ResourceLocation("skyblockhud", "maps/icons/blacksmith.png"), - new ComponentBuilder() - .nl("Blacksmith", new char[] { 'a', 'l' }) - .nl("NPCS", new char[] { 'c', 'l' }) - .nl(" Blacksmith") - .nl(" Dusk") - .nl(" Smithmonger") - .nl("Description", 'l') - .nl("The Blacksmith lets you reforge your items") - .nl("while the Smithmonger allows you to buy reforge stones") - .apd("and Dusk allows you to combine and apply runes.") - .build(), - MapHandler.MapIconTypes.SHOPS - ) - ); - hubIcons.add( - new MapHandler.MapIcon( - new Vector2f(124, 180), - new ResourceLocation("skyblockhud", "maps/icons/dark_bar.png"), - new ComponentBuilder() - .nl("Dark Bar", new char[] { 'a', 'l' }) - .nl("NPCS", new char[] { 'c', 'l' }) - .nl(" Shifty") - .nl(" Lucius") - .nl("Description", 'l') - .nl("The Dark Bar is where you can buy special") - .nl("brews from Shifty and you can buy special") - .nl("items from Lucius after buying a certain") - .apd("amount of items from the Dark Auction.") - .build(), - MapHandler.MapIconTypes.SHOPS - ) - ); - hubIcons.add( - new MapHandler.MapIcon( - new Vector2f(92, 185), - new ResourceLocation("skyblockhud", "maps/icons/dark_ah.png"), - new ComponentBuilder() - .nl("Dark Auction", new char[] { 'a', 'l' }) - .nl("Description", 'l') - .nl("The Dark Auction allows you to buy") - .nl("super special items from Sirius the") - .apd("auctioneer in a special auction.") - .build(), - MapHandler.MapIconTypes.SHOPS - ) - ); - hubIcons.add( - new MapHandler.MapIcon( - new Vector2f(-245, 52), - new ResourceLocation("skyblockhud", "maps/icons/scroll.png"), - new ComponentBuilder() - .nl("Lonely Philosopher", new char[] { 'a', 'l' }) - .nl("Shop", new char[] { '6', 'l' }) - .nl(" Travel Scroll to Hub Castle") - .nl() - .nl(" Cost") - .nl(" 150,000 Coins", '6') - .nl() - .apd(" Requires ") - .apd("MVP", 'b') - .apd("+", 'c') - .build(), - MapHandler.MapIconTypes.SHOPS - ) - ); - hubIcons.add( - new MapHandler.MapIcon( - new Vector2f(24, -38), - new ResourceLocation("skyblockhud", "maps/icons/tux.png"), - new ComponentBuilder() - .nl("Fashion Shop", new char[] { 'a', 'l' }) - .nl("NPCS", new char[] { 'c', 'l' }) - .nl(" Wool Weaver") - .nl(" Builder") - .apd(" Mad Redstone Engineer") - .build(), - MapHandler.MapIconTypes.SHOPS - ) - ); + hubIcons.add(new MapHandler.MapIcon(new Vector2f(-50, -22), new ResourceLocation("skyblockhud", "maps/icons/building.png"), new ComponentBuilder().nl("Builder's House", new char[] { 'a', 'l' }).nl("NPCS", new char[] { 'c', 'l' }).nl(" Wool Weaver").nl(" Builder").apd(" Mad Redstone Engineer").build(), MapHandler.MapIconTypes.SHOPS)); + hubIcons.add(new MapHandler.MapIcon(new Vector2f(-78, -46), new ResourceLocation("skyblockhud", "maps/icons/bar.png"), new ComponentBuilder().nl("Tavern", new char[] { 'a', 'l' }).nl("NPCS", new char[] { 'c', 'l' }).nl(" Bartender").nl(" Maddox the slayer").nl("Description", 'l').nl("The Tavern is where maddox the slayer is located you can").nl("start slayer quests with them to unlock").apd("new items the more slayer bosses you kill.").build(), MapHandler.MapIconTypes.SHOPS)); + hubIcons.add(new MapHandler.MapIcon(new Vector2f(36, -82), new ResourceLocation("skyblockhud", "maps/icons/vet.png"), new ComponentBuilder().nl("Vet", new char[] { 'a', 'l' }).nl("NPCS", new char[] { 'c', 'l' }).nl(" Bea").nl(" Zog").nl(" Kat").nl(" George").nl("Description", 'l').nl("The Vet is where you go to upgrade your pet").nl("at Kat or to buy pet upgrade items from Zog").nl("or trade in your pet at George and if you're").apd("a new player you can buy a bee pet from Bea.").build(), MapHandler.MapIconTypes.SHOPS)); + hubIcons.add(new MapHandler.MapIcon(new Vector2f(58, -73), new ResourceLocation("skyblockhud", "maps/icons/fishing_merchant.png"), new ComponentBuilder().nl("Fishing Merchant", new char[] { 'a', 'l' }).nl("Description", 'l').nl("The Fishing Merchant allows you to buy").nl("fishing related items and he has his friend").nl("joe whose in the house hes setup").apd("in front of who sells sponges.").build(), MapHandler.MapIconTypes.SHOPS)); + hubIcons.add(new MapHandler.MapIcon(new Vector2f(46, -53), new ResourceLocation("skyblockhud", "maps/icons/witch.png"), new ComponentBuilder().nl("Alchemist", new char[] { 'a', 'l' }).nl("Description", 'l').nl("The Alchemist allows you to buy").apd("potion making related items").build(), MapHandler.MapIconTypes.SHOPS)); + hubIcons.add(new MapHandler.MapIcon(new Vector2f(-4, -128), new ResourceLocation("skyblockhud", "maps/icons/metal_merchants.png"), new ComponentBuilder().nl("Blacksmith Merchants", new char[] { 'a', 'l' }).nl("Merchants", new char[] { 'c', 'l' }).nl(" Weaponsmith - Weapon Related Items").nl(" Armorsmith - Armor Related Items").apd(" Mine Merchant - Mining Related Items").build(), MapHandler.MapIconTypes.SHOPS)); + hubIcons.add(new MapHandler.MapIcon(new Vector2f(-30, -120), new ResourceLocation("skyblockhud", "maps/icons/blacksmith.png"), new ComponentBuilder().nl("Blacksmith", new char[] { 'a', 'l' }).nl("NPCS", new char[] { 'c', 'l' }).nl(" Blacksmith").nl(" Dusk").nl(" Smithmonger").nl("Description", 'l').nl("The Blacksmith lets you reforge your items").nl("while the Smithmonger allows you to buy reforge stones").apd("and Dusk allows you to combine and apply runes.").build(), MapHandler.MapIconTypes.SHOPS)); + hubIcons.add(new MapHandler.MapIcon(new Vector2f(124, 180), new ResourceLocation("skyblockhud", "maps/icons/dark_bar.png"), new ComponentBuilder().nl("Dark Bar", new char[] { 'a', 'l' }).nl("NPCS", new char[] { 'c', 'l' }).nl(" Shifty").nl(" Lucius").nl("Description", 'l').nl("The Dark Bar is where you can buy special").nl("brews from Shifty and you can buy special").nl("items from Lucius after buying a certain").apd("amount of items from the Dark Auction.").build(), MapHandler.MapIconTypes.SHOPS)); + hubIcons.add(new MapHandler.MapIcon(new Vector2f(92, 185), new ResourceLocation("skyblockhud", "maps/icons/dark_ah.png"), new ComponentBuilder().nl("Dark Auction", new char[] { 'a', 'l' }).nl("Description", 'l').nl("The Dark Auction allows you to buy").nl("super special items from Sirius the").apd("auctioneer in a special auction.").build(), MapHandler.MapIconTypes.SHOPS)); + hubIcons.add(new MapHandler.MapIcon(new Vector2f(-245, 52), new ResourceLocation("skyblockhud", "maps/icons/scroll.png"), new ComponentBuilder().nl("Lonely Philosopher", new char[] { 'a', 'l' }).nl("Shop", new char[] { '6', 'l' }).nl(" Travel Scroll to Hub Castle").nl().nl(" Cost").nl(" 150,000 Coins", '6').nl().apd(" Requires ").apd("MVP", 'b').apd("+", 'c').build(), MapHandler.MapIconTypes.SHOPS)); + hubIcons.add(new MapHandler.MapIcon(new Vector2f(24, -38), new ResourceLocation("skyblockhud", "maps/icons/tux.png"), new ComponentBuilder().nl("Fashion Shop", new char[] { 'a', 'l' }).nl("NPCS", new char[] { 'c', 'l' }).nl(" Wool Weaver").nl(" Builder").apd(" Mad Redstone Engineer").build(), MapHandler.MapIconTypes.SHOPS)); } private static void setupMiscIcons() { - hubIcons.add( - new MapHandler.MapIcon( - new Vector2f(-24, -53), - new ResourceLocation("skyblockhud", "maps/icons/bank.png"), - new ComponentBuilder() - .nl("Bank", new char[] { 'a', 'l' }) - .nl("Description", 'l') - .nl("The Bank is where you can store your money on skyblock") - .apd("you can also store some items in the vault.") - .build(), - MapHandler.MapIconTypes.MISC - ) - ); - hubIcons.add( - new MapHandler.MapIcon( - new Vector2f(-26, -80), - new ResourceLocation("skyblockhud", "maps/icons/ah.png"), - new ComponentBuilder() - .nl("Auction House", new char[] { 'a', 'l' }) - .nl("Description", 'l') - .nl("The Auction House is where you can auction off your") - .apd("precious items in skyblock to make a profit.") - .build(), - MapHandler.MapIconTypes.MISC - ) - ); - hubIcons.add( - new MapHandler.MapIcon( - new Vector2f(-38, -66), - new ResourceLocation("skyblockhud", "maps/icons/bazaar.png"), - new ComponentBuilder() - .nl("Bazaar", new char[] { 'a', 'l' }) - .nl("Description", 'l') - .nl("The Bazaar is where you can sell specific items") - .nl("on a sort of stock market and request and") - .apd("sell items at a specific price.") - .build(), - MapHandler.MapIconTypes.MISC - ) - ); + hubIcons.add(new MapHandler.MapIcon(new Vector2f(-24, -53), new ResourceLocation("skyblockhud", "maps/icons/bank.png"), new ComponentBuilder().nl("Bank", new char[] { 'a', 'l' }).nl("Description", 'l').nl("The Bank is where you can store your money on skyblock").apd("you can also store some items in the vault.").build(), MapHandler.MapIconTypes.MISC)); + hubIcons.add(new MapHandler.MapIcon(new Vector2f(-26, -80), new ResourceLocation("skyblockhud", "maps/icons/ah.png"), new ComponentBuilder().nl("Auction House", new char[] { 'a', 'l' }).nl("Description", 'l').nl("The Auction House is where you can auction off your").apd("precious items in skyblock to make a profit.").build(), MapHandler.MapIconTypes.MISC)); + hubIcons.add(new MapHandler.MapIcon(new Vector2f(-38, -66), new ResourceLocation("skyblockhud", "maps/icons/bazaar.png"), new ComponentBuilder().nl("Bazaar", new char[] { 'a', 'l' }).nl("Description", 'l').nl("The Bazaar is where you can sell specific items").nl("on a sort of stock market and request and").apd("sell items at a specific price.").build(), MapHandler.MapIconTypes.MISC)); } private static void setupInfoIcons() { - hubIcons.add( - new MapHandler.MapIcon( - new Vector2f(8, -95), - new ResourceLocation("skyblockhud", "maps/icons/community.png"), - new ComponentBuilder() - .nl("Community Center", new char[] { 'a', 'l' }) - .nl("Description", 'l') - .nl("The Community Center is where you can vote") - .nl("for your favorite election candidate,") - .nl("access the community shop, upgrade your") - .apd("account, and help with city projects.") - .build(), - MapHandler.MapIconTypes.INFO - ) - ); - hubIcons.add( - new MapHandler.MapIcon( - new Vector2f(150, 45), - new ResourceLocation("skyblockhud", "maps/icons/fishing.png"), - new ComponentBuilder() - .nl("Fisherman's Hut", new char[] { 'a', 'l' }) - .nl("Description", 'l') - .nl("This is a spot where people regularly") - .nl("do their fishing, this is one") - .apd("of many spots.") - .build(), - MapHandler.MapIconTypes.INFO - ) - ); + hubIcons.add(new MapHandler.MapIcon(new Vector2f(8, -95), new ResourceLocation("skyblockhud", "maps/icons/community.png"), new ComponentBuilder().nl("Community Center", new char[] { 'a', 'l' }).nl("Description", 'l').nl("The Community Center is where you can vote").nl("for your favorite election candidate,").nl("access the community shop, upgrade your").apd("account, and help with city projects.").build(), MapHandler.MapIconTypes.INFO)); + hubIcons.add(new MapHandler.MapIcon(new Vector2f(150, 45), new ResourceLocation("skyblockhud", "maps/icons/fishing.png"), new ComponentBuilder().nl("Fisherman's Hut", new char[] { 'a', 'l' }).nl("Description", 'l').nl("This is a spot where people regularly").nl("do their fishing, this is one").apd("of many spots.").build(), MapHandler.MapIconTypes.INFO)); } private static void setupQuestIcons() { - hubIcons.add( - new MapHandler.MapIcon( - new Vector2f(-8, -10), - new ResourceLocation("skyblockhud", "maps/icons/painter.png"), - new ComponentBuilder() - .nl("Marco", new char[] { 'a', 'l' }) - .nl("Description", 'l') - .nl("Marco is an NPC that has no other uses") - .nl("besides giving you a spray can for") - .apd("completing a quest.") - .build(), - MapHandler.MapIconTypes.QUEST - ) - ); + hubIcons.add(new MapHandler.MapIcon(new Vector2f(-8, -10), new ResourceLocation("skyblockhud", "maps/icons/painter.png"), new ComponentBuilder().nl("Marco", new char[] { 'a', 'l' }).nl("Description", 'l').nl("Marco is an NPC that has no other uses").nl("besides giving you a spray can for").apd("completing a quest.").build(), MapHandler.MapIconTypes.QUEST)); } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/handlers/sbentities/EntityTypeHelper.java b/src/main/java/com/thatgravyboat/skyblockhud/handlers/sbentities/EntityTypeHelper.java index a59b0db..afff109 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/handlers/sbentities/EntityTypeHelper.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/handlers/sbentities/EntityTypeHelper.java @@ -12,10 +12,7 @@ public class EntityTypeHelper { if (entity instanceof EntityEnderman) { EntityEnderman enderman = ((EntityEnderman) entity); double maxHealthBase = enderman.getAttributeMap().getAttributeInstanceByName("generic.maxHealth").getBaseValue(); - if ( - maxHealthBase == 13000d || - (maxHealthBase == 2000d && enderman.getHeldBlockState().getBlock().equals(Blocks.end_portal_frame)) - ) { + if (maxHealthBase == 13000d || (maxHealthBase == 2000d && enderman.getHeldBlockState().getBlock().equals(Blocks.end_portal_frame))) { return LocationHandler.getCurrentLocation().equals(Locations.DRAGONSNEST); } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/handlers/sbentities/EntityTypeRegistry.java b/src/main/java/com/thatgravyboat/skyblockhud/handlers/sbentities/EntityTypeRegistry.java index 83c6a70..40076d9 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/handlers/sbentities/EntityTypeRegistry.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/handlers/sbentities/EntityTypeRegistry.java @@ -17,9 +17,7 @@ public class EntityTypeRegistry { public static String getEntityId(Entity entity) { if (!entities.containsKey(entity.getClass())) return null; - for (SkyBlockEntity skyBlockEntity : entities.get(entity.getClass())) if ( - skyBlockEntity.isEntity(entity) - ) return skyBlockEntity.getName(); + for (SkyBlockEntity skyBlockEntity : entities.get(entity.getClass())) if (skyBlockEntity.isEntity(entity)) return skyBlockEntity.getName(); return null; } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/location/DwarvenMineHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/location/DwarvenMineHandler.java index faec015..3b17899 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/location/DwarvenMineHandler.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/location/DwarvenMineHandler.java @@ -72,8 +72,7 @@ public class DwarvenMineHandler { } else if (DwarvenMineHandler.currentEvent == Event.GOBLIN) { if (event.formattedLine.toLowerCase().contains("remaining:")) { try { - eventMax = - Integer.parseInt(event.formattedLine.toLowerCase().replace("goblins", "").replace("remaining:", "").trim()); + eventMax = Integer.parseInt(event.formattedLine.toLowerCase().replace("goblins", "").replace("remaining:", "").trim()); } catch (Exception ignored) {} } else if (event.formattedLine.toLowerCase().contains("your kills:") && !event.formattedLine.toLowerCase().contains("(")) { try { diff --git a/src/main/java/com/thatgravyboat/skyblockhud/location/IslandHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/location/IslandHandler.java index d16a3ac..2e2fae1 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/location/IslandHandler.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/location/IslandHandler.java @@ -28,10 +28,7 @@ public class IslandHandler { } public static boolean checkFlightDuration(String formatedScoreboardLine) { - if ( - LocationHandler.getCurrentLocation() == Locations.YOURISLAND && - Utils.removeColor(formatedScoreboardLine.toLowerCase().trim()).contains("flight duration:") - ) { + if (LocationHandler.getCurrentLocation() == Locations.YOURISLAND && Utils.removeColor(formatedScoreboardLine.toLowerCase().trim()).contains("flight duration:")) { String timeString = formatedScoreboardLine.toLowerCase().replace("flight duration:", "").replace(" ", ""); String[] times = timeString.split(":"); if (times.length == 2) { @@ -65,10 +62,7 @@ public class IslandHandler { if (LocationHandler.getCurrentLocation() == Locations.YOURISLAND) { if (formatedScoreboardLine.toLowerCase().contains("redstone:")) return true; try { - redstone = - formatedScoreboardLine.toLowerCase().contains("redstone:") - ? Integer.parseInt(Utils.removeWhiteSpaceAndRemoveWord(formatedScoreboardLine, "redstone:")) - : 0; + redstone = formatedScoreboardLine.toLowerCase().contains("redstone:") ? Integer.parseInt(Utils.removeWhiteSpaceAndRemoveWord(formatedScoreboardLine, "redstone:")) : 0; } catch (Exception ignored) {} } return false; diff --git a/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinEntityArrow.java b/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinEntityArrow.java index 2204995..cc1edaf 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinEntityArrow.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinEntityArrow.java @@ -19,12 +19,7 @@ public class MixinEntityArrow { @ModifyVariable(method = "onUpdate", at = @At(value = "STORE", ordinal = 1)) public MovingObjectPosition onUpdate(MovingObjectPosition position) { - if ( - position != null && - position.entityHit != null && - this.shootingEntity != null && - this.shootingEntity.getUniqueID().equals(Minecraft.getMinecraft().thePlayer.getUniqueID()) - ) { + if (position != null && position.entityHit != null && this.shootingEntity != null && this.shootingEntity.getUniqueID().equals(Minecraft.getMinecraft().thePlayer.getUniqueID())) { KillTrackerHandler.attackedEntities.add(position.entityHit.getUniqueID()); } return position; diff --git a/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinNetHandlerPlayClient.java b/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinNetHandlerPlayClient.java index c97a1f9..df36b8f 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinNetHandlerPlayClient.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinNetHandlerPlayClient.java @@ -44,17 +44,7 @@ public class MixinNetHandlerPlayClient { } */ - @Inject( - method = "handleTeams", - locals = LocalCapture.CAPTURE_FAILHARD, - at = @At( - value = "INVOKE", - target = "Lnet/minecraft/network/play/server/S3EPacketTeams;getAction()I", - ordinal = 0, - shift = At.Shift.BEFORE - ), - cancellable = true - ) + @Inject(method = "handleTeams", locals = LocalCapture.CAPTURE_FAILHARD, at = @At(value = "INVOKE", target = "Lnet/minecraft/network/play/server/S3EPacketTeams;getAction()I", ordinal = 0, shift = At.Shift.BEFORE), cancellable = true) public void handleTeams(S3EPacketTeams packetIn, CallbackInfo ci, Scoreboard scoreboard) { //This stops Hypixel from being stupid and spamming our logs because they dont have different ids for things. if (scoreboard.getTeam(packetIn.getName()) != null && packetIn.getAction() == 0) ci.cancel(); diff --git a/src/main/java/com/thatgravyboat/skyblockhud/overlay/DungeonOverlay.java b/src/main/java/com/thatgravyboat/skyblockhud/overlay/DungeonOverlay.java index 462896d..f8a2e0d 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/overlay/DungeonOverlay.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/overlay/DungeonOverlay.java @@ -54,38 +54,18 @@ public class DungeonOverlay extends Gui { 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); + 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.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 + - "%"; + 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 - ); + 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 @@ -105,14 +85,7 @@ public class DungeonOverlay extends Gui { 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 - ); + 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 @@ -121,14 +94,7 @@ public class DungeonOverlay extends Gui { 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 - ); + 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); } @@ -141,29 +107,14 @@ public class DungeonOverlay extends Gui { 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) - ) - ) { + 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); @@ -171,12 +122,7 @@ public class DungeonOverlay extends Gui { 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 - }; + 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; diff --git a/src/main/java/com/thatgravyboat/skyblockhud/overlay/GenericOverlays.java b/src/main/java/com/thatgravyboat/skyblockhud/overlay/GenericOverlays.java index 439d857..eeb48e1 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/overlay/GenericOverlays.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/overlay/GenericOverlays.java @@ -10,16 +10,7 @@ import net.minecraft.client.renderer.GlStateManager; 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 - ) { + 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); @@ -34,16 +25,7 @@ public class GenericOverlays extends Gui { } } - public static void drawSmallBar( - Minecraft mc, - int x, - int y, - double percentage, - double max, - int fullColor, - int loadingColor, - int barStyle - ) { + 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); diff --git a/src/main/java/com/thatgravyboat/skyblockhud/overlay/OverlayHud.java b/src/main/java/com/thatgravyboat/skyblockhud/overlay/OverlayHud.java index 530a890..23b9df0 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/overlay/OverlayHud.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/overlay/OverlayHud.java @@ -42,24 +42,11 @@ public class OverlayHud extends Gui { 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"); + String normalTime = (time12Hour == 0 ? "00" : String.valueOf(time12Hour)) + ":" + (timeMin == 0 ? "00" : timeMin) + (timeHour >= 12 ? "pm" : "am"); 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 - ); + 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); //PURSE drawPurseAndBits(width, offset, mc); @@ -100,26 +87,10 @@ public class OverlayHud extends Gui { 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(); + 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 - ); + 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); } } @@ -127,55 +98,20 @@ public class OverlayHud extends Gui { 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((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); } 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; + 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 - ); + drawCenteredString(mc.fontRendererObj, IslandHandler.redstone + "%", (width / 2), offset + (bossBarVisible ? 58 : 41), redstoneColor); } } @@ -185,14 +121,7 @@ public class OverlayHud extends Gui { int xPos = (width / 2) + 17; //COINS - drawTexturedModalRect( - xPos, - offset + (bossBarVisible ? 35 : 18), - 2, - 34, - font.getStringWidth(CurrencyHandler.getCoinsFormatted()) + 11, - 14 - ); + 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); @@ -201,14 +130,7 @@ public class OverlayHud extends Gui { //BITS if (CurrencyHandler.getBits() > 0) { - drawTexturedModalRect( - xPos, - offset + (bossBarVisible ? 35 : 18), - 2, - 34, - font.getStringWidth(CurrencyHandler.getBitsFormatted()) + 11, - 14 - ); + 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); @@ -224,32 +146,11 @@ public class OverlayHud extends Gui { 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"; + 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 - ); + 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); } } @@ -260,22 +161,8 @@ public class OverlayHud extends Gui { 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 - ); + 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); } } @@ -312,22 +199,8 @@ public class OverlayHud extends Gui { } 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 - ); + 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); } } @@ -339,22 +212,8 @@ public class OverlayHud extends Gui { 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 - ); + 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); } } @@ -363,26 +222,10 @@ public class OverlayHud extends Gui { 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; + 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 - ); + 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); } } @@ -393,56 +236,15 @@ public class OverlayHud extends Gui { 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 - ); + 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 - ); + 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); } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/overlay/RPGHud.java b/src/main/java/com/thatgravyboat/skyblockhud/overlay/RPGHud.java index 7c622e4..d6a9709 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/overlay/RPGHud.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/overlay/RPGHud.java @@ -52,14 +52,7 @@ public class RPGHud extends Gui { @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.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(); @@ -101,22 +94,10 @@ public class RPGHud extends Gui { 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 - ); + 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 - ); + 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(); diff --git a/src/main/java/com/thatgravyboat/skyblockhud/playerstats/ActionBarParsing.java b/src/main/java/com/thatgravyboat/skyblockhud/playerstats/ActionBarParsing.java index 1fc9a77..4e895f9 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/playerstats/ActionBarParsing.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/playerstats/ActionBarParsing.java @@ -24,9 +24,7 @@ public class ActionBarParsing { private static final Pattern ManaRegex = Pattern.compile("([0-9]+)/([0-9]+)\u270E Mana"); private static final Pattern ManaOverflowRegex = Pattern.compile("([0-9]+)/([0-9]+)\u270E ([0-9]+)\u02AC"); private static final Pattern ManaDecreaseRegex = Pattern.compile("-([0-9]+) Mana \\("); - private static final Pattern XpGainRegex = Pattern.compile( - "\\+(\\d*\\.?\\d*) (Farming|Mining|Combat|Foraging|Fishing|Enchanting|Alchemy|Carpentry|Runecrafting) \\((\\d*\\.?\\d*)%\\)" - ); + private static final Pattern XpGainRegex = Pattern.compile("\\+(\\d*\\.?\\d*) (Farming|Mining|Combat|Foraging|Fishing|Enchanting|Alchemy|Carpentry|Runecrafting) \\((\\d*\\.?\\d*)%\\)"); private static final Pattern HealthReplaceRegex = Pattern.compile("\u00A7c([0-9]+)/([0-9]+)\u2764"); private static final Pattern HealingReplaceRegex = Pattern.compile("\\+\u00A7c([0-9]+)[\u2586\u2585\u2584\u2583\u2582\u2581]"); diff --git a/src/main/java/com/thatgravyboat/skyblockhud/seasons/SeasonDateHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/seasons/SeasonDateHandler.java index b794eda..bc36b70 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/seasons/SeasonDateHandler.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/seasons/SeasonDateHandler.java @@ -15,10 +15,7 @@ public class SeasonDateHandler { @SubscribeEvent public void onSidebarLineUpdate(SidebarLineUpdateEvent event) { if (Season.get(SeasonDateHandler.removeDate(event.formattedLine.toLowerCase()).toUpperCase()) != Season.ERROR) { - SeasonDateHandler.setCurrentDateAndSeason( - SeasonDateHandler.removeSeason(Utils.removeColor(event.formattedLine.toLowerCase().trim())), - SeasonDateHandler.removeDate(Utils.removeColor(event.formattedLine.toLowerCase().trim())).toUpperCase() - ); + SeasonDateHandler.setCurrentDateAndSeason(SeasonDateHandler.removeSeason(Utils.removeColor(event.formattedLine.toLowerCase().trim())), SeasonDateHandler.removeDate(Utils.removeColor(event.formattedLine.toLowerCase().trim())).toUpperCase()); } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/tracker/KillTrackerHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/tracker/KillTrackerHandler.java index 8f0608d..5d5615f 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/tracker/KillTrackerHandler.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/tracker/KillTrackerHandler.java @@ -26,47 +26,21 @@ public class KillTrackerHandler { public void onDeath(LivingDeathEvent event) { if (false) { //Used for testing - System.out.println( - "----------------------------------------------------------------------------------------------------------------" - ); + System.out.println("----------------------------------------------------------------------------------------------------------------"); System.out.println("Name : " + event.entity.getName()); System.out.println("UUID : " + event.entity.getUniqueID()); NBTTagCompound tag = new NBTTagCompound(); event.entity.writeToNBT(tag); System.out.println("Tag : " + tag); System.out.println("Damage : " + getDamageSourceString(event.source)); - System.out.println( - "----------------------------------------------------------------------------------------------------------------" - ); + System.out.println("----------------------------------------------------------------------------------------------------------------"); } attackedEntities.remove(event.entity.getUniqueID()); } public static String getDamageSourceString(DamageSource source) { - return ( - "{ " + - source.getDamageType() + - ", " + - source.isDamageAbsolute() + - ", " + - source.isDifficultyScaled() + - ", " + - source.isFireDamage() + - ", " + - source.isProjectile() + - ", " + - source.isUnblockable() + - ", " + - source.isExplosion() + - ", " + - source.isMagicDamage() + - ", " + - source.isCreativePlayer() + - ", " + - source.getSourceOfDamage() + - " }" - ); + return ("{ " + source.getDamageType() + ", " + source.isDamageAbsolute() + ", " + source.isDifficultyScaled() + ", " + source.isFireDamage() + ", " + source.isProjectile() + ", " + source.isUnblockable() + ", " + source.isExplosion() + ", " + source.isMagicDamage() + ", " + source.isCreativePlayer() + ", " + source.getSourceOfDamage() + " }"); } @SubscribeEvent diff --git a/src/main/java/com/thatgravyboat/skyblockhud/tracker/TrackerFileLoader.java b/src/main/java/com/thatgravyboat/skyblockhud/tracker/TrackerFileLoader.java index 858770a..624ca60 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/tracker/TrackerFileLoader.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/tracker/TrackerFileLoader.java @@ -78,10 +78,7 @@ public class TrackerFileLoader { TrackerHandler.trackers.putIfAbsent(location, new TrackerHandler.TrackerData(events)); } - tracker - .get("location") - .getAsJsonArray() - .forEach(loc -> TrackerHandler.trackerIds.put(Locations.get(loc.getAsString()), location)); + tracker.get("location").getAsJsonArray().forEach(loc -> TrackerHandler.trackerIds.put(Locations.get(loc.getAsString()), location)); } } @@ -127,9 +124,7 @@ public class TrackerFileLoader { return true; } - try ( - BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(configFile), StandardCharsets.UTF_8)) - ) { + try (BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(configFile), StandardCharsets.UTF_8))) { JsonObject json = gson.fromJson(reader, JsonObject.class); if (json.has("trackerStats")) { json @@ -169,9 +164,7 @@ public class TrackerFileLoader { try { configFile.createNewFile(); - try ( - BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(configFile), StandardCharsets.UTF_8)) - ) { + try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(configFile), StandardCharsets.UTF_8))) { JsonObject json = new JsonObject(); json.add("trackerStats", getTrackerFile()); writer.write(gson.toJson(json)); diff --git a/src/main/java/com/thatgravyboat/skyblockhud/tracker/TrackerHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/tracker/TrackerHandler.java index f0a5b90..fa2bacf 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/tracker/TrackerHandler.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/tracker/TrackerHandler.java @@ -82,14 +82,7 @@ public class TrackerHandler { @SubscribeEvent public void renderOverlay(RenderGameOverlayEvent.Post event) { - if ( - Utils.overlayShouldRender( - event.type, - SkyblockHud.hasSkyblockScoreboard(), - trackerIds.containsKey(LocationHandler.getCurrentLocation()), - !SkyblockHud.config.trackers.hideTracker - ) - ) { + if (Utils.overlayShouldRender(event.type, SkyblockHud.hasSkyblockScoreboard(), trackerIds.containsKey(LocationHandler.getCurrentLocation()), !SkyblockHud.config.trackers.hideTracker)) { String trackerId = trackerIds.get(LocationHandler.getCurrentLocation()); Minecraft mc = Minecraft.getMinecraft(); TrackerData tracked = trackers.get(trackerId); @@ -103,13 +96,7 @@ public class TrackerHandler { Gui.drawRect(startPos, y, startPos + 120, y + 10, -1072689136); mc.fontRendererObj.drawString("Tracker", startPos + 4, y + 1, 0xffffff, false); y += 10; - Gui.drawRect( - startPos, - y, - startPos + (tracker.size() >= 6 ? 120 : tracker.size() * 20), - (int) (y + (Math.ceil(tracker.size() / 5d) * 20)), - 1610612736 - ); + Gui.drawRect(startPos, y, startPos + (tracker.size() >= 6 ? 120 : tracker.size() * 20), (int) (y + (Math.ceil(tracker.size() / 5d) * 20)), 1610612736); int x = startPos; for (ItemStack stack : tracker.values()) { String s = String.valueOf(stack.stackSize); @@ -118,12 +105,7 @@ public class TrackerHandler { drawItemStack(stack, x, y); GlStateManager.disableDepth(); GlStateManager.disableBlend(); - mc.fontRendererObj.drawStringWithShadow( - s, - (float) (x + 19 - 2 - mc.fontRendererObj.getStringWidth(s)), - (float) (y + 9), - stack.stackSize < 1 ? 16733525 : 16777215 - ); + mc.fontRendererObj.drawStringWithShadow(s, (float) (x + 19 - 2 - mc.fontRendererObj.getStringWidth(s)), (float) (y + 9), stack.stackSize < 1 ? 16733525 : 16777215); GlStateManager.enableBlend(); GlStateManager.enableDepth(); -- cgit