diff options
author | ThatGravyBoat <thatgravyboat@gmail.com> | 2021-07-11 18:57:24 -0230 |
---|---|---|
committer | ThatGravyBoat <thatgravyboat@gmail.com> | 2021-07-11 18:57:24 -0230 |
commit | 3a1917c8a0af4157cc1e6d5f3986e89377f245d8 (patch) | |
tree | 0a25fdc3ad1fc48da3f0d06c501f772ac9cfc353 /src/main/java/com/thatgravyboat/skyblockhud/overlay | |
parent | 5a98a98dfc0009599b90280ae3a1f166de21e6e8 (diff) | |
download | skyblockhud-3a1917c8a0af4157cc1e6d5f3986e89377f245d8.tar.gz skyblockhud-3a1917c8a0af4157cc1e6d5f3986e89377f245d8.tar.bz2 skyblockhud-3a1917c8a0af4157cc1e6d5f3986e89377f245d8.zip |
Added Mining Overlay including drill bar and heat bar
Added mana cost display
Update Location Stuff
Added new mining events
stopped scoreboard logging spam
removed missing location logging as hypixel dumb and sends the wrong thing once and a while causing it to log useless stuff.
Added DEV Commands
Diffstat (limited to 'src/main/java/com/thatgravyboat/skyblockhud/overlay')
3 files changed, 117 insertions, 23 deletions
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/overlay/MiningHud.java b/src/main/java/com/thatgravyboat/skyblockhud/overlay/MiningHud.java new file mode 100644 index 0000000..57044df --- /dev/null +++ b/src/main/java/com/thatgravyboat/skyblockhud/overlay/MiningHud.java @@ -0,0 +1,60 @@ +package com.thatgravyboat.skyblockhud.overlay; + +import com.thatgravyboat.skyblockhud.GuiTextures; +import com.thatgravyboat.skyblockhud.SkyblockHud; +import com.thatgravyboat.skyblockhud.Utils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraftforge.client.event.RenderGameOverlayEvent; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; + +public class MiningHud extends Gui { + + private static int fuel, maxFuel; + private static int heat; + + public static void setFuel(int fuel, int maxFuel){ + MiningHud.fuel = fuel; + MiningHud.maxFuel = maxFuel; + } + + public static void setHeat(int heat){ + MiningHud.heat = heat; + } + + @SubscribeEvent + public void renderOverlay(RenderGameOverlayEvent.Post event) { + if (Utils.overlayShouldRender(event.type, SkyblockHud.hasSkyblockScoreboard(), SkyblockHud.config.miningHud.showDrillBar || SkyblockHud.config.miningHud.showHeatBar)) { + Minecraft mc = Minecraft.getMinecraft(); + + if (heat > 0 && Utils.isDrill(mc.thePlayer.getHeldItem()) && SkyblockHud.config.miningHud.showDrillBar && SkyblockHud.config.miningHud.showHeatBar) { + renderFuelBar(mc, (event.resolution.getScaledWidth() / 2) - 91, event.resolution.getScaledHeight() - 31); + renderHeatBar(mc, (event.resolution.getScaledWidth() / 2) + 46, event.resolution.getScaledHeight() - 31); + }else if(Utils.isDrill(mc.thePlayer.getHeldItem()) && SkyblockHud.config.miningHud.showDrillBar) { + renderFuelBar(mc, (event.resolution.getScaledWidth() / 2) - 68, event.resolution.getScaledHeight() - 31); + }else if (heat > 0 && SkyblockHud.config.miningHud.showHeatBar){ + renderHeatBar(mc, (event.resolution.getScaledWidth() / 2) - 22, event.resolution.getScaledHeight() - 31); + } + } + } + + private void renderFuelBar(Minecraft mc, int x, int y){ + if (maxFuel == 0)return; + GlStateManager.enableBlend(); + GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f); + mc.renderEngine.bindTexture(GuiTextures.mining); + drawTexturedModalRect(x, y, 0, 0, 136, 7); + drawTexturedModalRect(x, y, 0, 7, Utils.lerp((float)fuel/(float)maxFuel,0,136), 7); + String percentageText = Math.round(((float)fuel/(float)maxFuel)*100) +"%"; + this.drawCenteredString(mc.fontRendererObj, percentageText, x + 68, y-2, 0xffffff); + } + + private void renderHeatBar(Minecraft mc, int x, int y){ + GlStateManager.enableBlend(); + GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f); + mc.renderEngine.bindTexture(GuiTextures.mining); + drawTexturedModalRect(x, y, 137, 0, 45, 7); + drawTexturedModalRect(x, y, 137, 7, Utils.lerp(heat/100f,0,45), 7); + } +} diff --git a/src/main/java/com/thatgravyboat/skyblockhud/overlay/OverlayHud.java b/src/main/java/com/thatgravyboat/skyblockhud/overlay/OverlayHud.java index 23b9df0..a7a8b4e 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/overlay/OverlayHud.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/overlay/OverlayHud.java @@ -10,9 +10,6 @@ import com.thatgravyboat.skyblockhud.handlers.TimeHandler; import com.thatgravyboat.skyblockhud.location.*; import com.thatgravyboat.skyblockhud.seasons.Season; import com.thatgravyboat.skyblockhud.seasons.SeasonDateHandler; -import java.text.DecimalFormat; -import java.text.DecimalFormatSymbols; -import java.util.Locale; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.Gui; @@ -23,6 +20,10 @@ import net.minecraftforge.client.GuiIngameForge; import net.minecraftforge.client.event.RenderGameOverlayEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import java.text.DecimalFormat; +import java.text.DecimalFormatSymbols; +import java.util.Locale; + public class OverlayHud extends Gui { private static final FontRenderer font = Minecraft.getMinecraft().fontRendererObj; @@ -65,11 +66,11 @@ public class OverlayHud extends Gui { 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().isMiningCategory()) { + if (MinesHandler.currentEvent.display && LocationHandler.getCurrentLocation().getCategory() == LocationCategory.DWARVENMINES) { drawDwarvenEvent(width, offset, mc); } else { - drawMithril(width, offset, mc); + drawMiningPowders(width, offset, mc); } } else if (LocationHandler.getCurrentLocation().getCategory().equals(LocationCategory.PARK) && ParkIslandHandler.isRaining()) { if (LocationHandler.getCurrentLocation().equals(Locations.HOWLINGCAVE)) { @@ -206,15 +207,38 @@ public class OverlayHud extends Gui { } } - public void drawMithril(int width, int offset, Minecraft mc) { - if (LocationHandler.getCurrentLocation().getCategory().equals(LocationCategory.DWARVENMINES)) { + public void drawMiningPowders(int width, int offset, Minecraft mc) { + if (MinesHandler.gemstone == 0) { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); mc.renderEngine.bindTexture(GuiTextures.overlay); - String mithril = DwarvenMineHandler.getMithrilFormatted(); + String mithril = MinesHandler.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); + }else { + LocationCategory locationCategory = LocationHandler.getCurrentLocation().getCategory(); + String mithril = locationCategory == LocationCategory.DWARVENMINES ? MinesHandler.getMithrilFormatted() : MinesHandler.getMithrilShortFormatted(); + String gemstone = locationCategory == LocationCategory.CRYSTALHOLLOWS ? MinesHandler.getGemstoneFormatted() : MinesHandler.getGemstoneShortFormatted(); + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + mc.renderEngine.bindTexture(GuiTextures.overlay); + + int edge = (width / 2) - 33; + + int barWidth = font.getStringWidth(mithril) + 12 + font.getStringWidth(gemstone); + + int firstText = locationCategory == LocationCategory.DWARVENMINES ? font.getStringWidth(mithril) : font.getStringWidth(gemstone); + + //Bar + drawTexturedModalRect(edge - barWidth, offset + (bossBarVisible ? 35 : 18), 0, 34, 2, 14); + drawTexturedModalRect(edge - barWidth + 2, offset + (bossBarVisible ? 35 : 18), 2, 34, barWidth + 14, 14); + + //Icons + drawTexturedModalRect(edge - barWidth + 4, offset + (bossBarVisible ? 38 : 21), locationCategory == LocationCategory.DWARVENMINES ? 91 : 131, 0, 8, 8); + drawTexturedModalRect(edge - barWidth + 16 + firstText, offset + (bossBarVisible ? 38 : 21), locationCategory == LocationCategory.DWARVENMINES ? 131 : 91, 0, 8, 8); + + drawString(font, locationCategory == LocationCategory.DWARVENMINES ? mithril : gemstone, edge - barWidth + 14, offset + (bossBarVisible ? 38 : 21), locationCategory == LocationCategory.DWARVENMINES ? 0x00C896 : 0xFF55FF); + drawString(font, locationCategory == LocationCategory.DWARVENMINES ? gemstone : mithril, edge - barWidth + 26 + firstText, offset + (bossBarVisible ? 38 : 21), locationCategory == LocationCategory.DWARVENMINES ? 0xFF55FF : 0x00C896); } } @@ -234,17 +258,17 @@ public class OverlayHud extends Gui { 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; + if (MinesHandler.eventMax > 0 || !MinesHandler.currentEvent.needsMax) { + String duration = MinesHandler.currentEvent.needsMax ? MinesHandler.eventProgress + "/" + MinesHandler.eventMax : String.valueOf(MinesHandler.eventProgress); 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); + drawTexturedModalRect(((width / 2) - 33 - (font.getStringWidth(duration))) + 4, offset + (bossBarVisible ? 38 : 21), MinesHandler.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; + String text = MinesHandler.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))) + 4, offset + (bossBarVisible ? 38 : 21), MinesHandler.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 47e69b9..3914392 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/overlay/RPGHud.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/overlay/RPGHud.java @@ -5,16 +5,17 @@ import com.thatgravyboat.skyblockhud.GuiTextures; import com.thatgravyboat.skyblockhud.SkyblockHud; import com.thatgravyboat.skyblockhud.Utils; import com.thatgravyboat.skyblockhud.core.config.Position; -import java.text.DecimalFormat; -import java.text.NumberFormat; +import com.thatgravyboat.skyblockhud.handlers.HeldItemHandler; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.Gui; import net.minecraft.client.renderer.GlStateManager; import net.minecraftforge.client.event.RenderGameOverlayEvent; -import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import java.text.DecimalFormat; +import java.text.NumberFormat; + public class RPGHud extends Gui { private static int mana, maxMana, overflow = 0; @@ -52,7 +53,6 @@ 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.rpg.showRpgHud)) { Minecraft mc = Minecraft.getMinecraft(); GlStateManager.enableBlend(); @@ -73,14 +73,24 @@ 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); + int manaX = rightAligned ? x + 16 : 47 + x; + if (HeldItemHandler.hasManaCost(mc.thePlayer.getHeldItem())){ + int manaCost = HeldItemHandler.getManaCost(mc.thePlayer.getHeldItem()); + drawTexturedModalRect(manaX, 17 + y, rightAligned ? 199 : 0, manaCost > mana ? 96 : 64, (int) manaWidth, 4); + if (manaCost <= mana) { + drawTexturedModalRect(manaX, 17 + y, rightAligned ? 199 : 0, 92, Utils.lerp((float) manaCost / (float) maxMana,0, 57), 4); + } + }else { + drawTexturedModalRect(manaX, 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); + int healthX = rightAligned ? x + 3 : 47 + x; + drawTexturedModalRect(healthX, 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(healthX, 22 + y, rightAligned ? 186 : 0, 77, (int) absorptionWidth, 5); } drawTexturedModalRect(rightAligned ? x + 7 : 45 + x, 28 + y, rightAligned ? 189 : 0, 73, Utils.lerp(mc.thePlayer.experience, 0, 67), 4); @@ -92,9 +102,9 @@ public class RPGHud extends Gui { drawTexturedModalRect(rightAligned ? x + 19 : 41 + x, 33 + y, rightAligned ? 196 : 0, 88, Utils.lerp(mc.thePlayer.getAir() / 300f, 0, 60), 4); } - Utils.drawStringScaled("" + mc.thePlayer.experienceLevel, mc.fontRendererObj, (rightAligned ? 130 : 14) + x - (mc.fontRendererObj.getStringWidth("" + mc.thePlayer.experienceLevel) / 2f), 34 + y, false, 8453920, 0.75f); + Utils.drawStringScaled("" + mc.thePlayer.experienceLevel, font, (rightAligned ? 112 : 14) + x - (font.getStringWidth("" + mc.thePlayer.experienceLevel) / 2f), 34 + y, false, 8453920, 0.75f); - Utils.drawStringScaled(ChatFormatting.RED + " \u2764 " + health + "/" + maxHealth, mc.fontRendererObj, (rightAligned ? 10 : 42) + x, 8 + y, true, 0xffffff, 0.75f); + Utils.drawStringScaled(ChatFormatting.RED + " \u2764 " + health + "/" + maxHealth, font, (rightAligned ? 10 : 42) + x, 8 + y, true, 0xffffff, 0.75f); GlStateManager.color(255, 255, 255); GlStateManager.disableBlend(); |