diff options
author | Appability <appable@icloud.com> | 2022-10-23 13:17:54 -0700 |
---|---|---|
committer | Appability <appable@icloud.com> | 2022-10-23 13:17:54 -0700 |
commit | 10d1822a2a8a93fd34f4303aa7c09b9268ba0e60 (patch) | |
tree | 9e0906cd9e223ed5460daa4a4cb4c62e299040c4 /src | |
parent | 0576a7f5304565bb58a499b8ccdcda31ed587dc4 (diff) | |
download | AmbientAddons-10d1822a2a8a93fd34f4303aa7c09b9268ba0e60.tar.gz AmbientAddons-10d1822a2a8a93fd34f4303aa7c09b9268ba0e60.tar.bz2 AmbientAddons-10d1822a2a8a93fd34f4303aa7c09b9268ba0e60.zip |
+spirit bow overlay
Diffstat (limited to 'src')
5 files changed, 111 insertions, 15 deletions
diff --git a/src/main/kotlin/com/ambientaddons/AmbientAddons.kt b/src/main/kotlin/com/ambientaddons/AmbientAddons.kt index 9f63b13..57ded8a 100644 --- a/src/main/kotlin/com/ambientaddons/AmbientAddons.kt +++ b/src/main/kotlin/com/ambientaddons/AmbientAddons.kt @@ -4,6 +4,7 @@ import com.ambientaddons.config.Config import com.ambientaddons.config.PersistentData import com.ambientaddons.features.display.CatOverlay import com.ambientaddons.features.display.PingOverlay +import com.ambientaddons.features.display.ThornOverlay import com.ambientaddons.features.display.WitherShieldOverlay import com.ambientaddons.features.dungeon.* import com.ambientaddons.features.dungeon.terminals.MelodyHelper @@ -72,12 +73,14 @@ class AmbientAddons { Trapper, CrimsonFishing, CatOverlay, - PingOverlay + PingOverlay, + ThornOverlay ).forEach(MinecraftForge.EVENT_BUS::register) keyBinds.values.forEach(ClientRegistry::registerKeyBinding) guiElements = listOf( CatOverlay.element, - PingOverlay.element + PingOverlay.element, + ThornOverlay.element ) } diff --git a/src/main/kotlin/com/ambientaddons/config/Config.kt b/src/main/kotlin/com/ambientaddons/config/Config.kt index db2c327..753d401 100644 --- a/src/main/kotlin/com/ambientaddons/config/Config.kt +++ b/src/main/kotlin/com/ambientaddons/config/Config.kt @@ -36,6 +36,7 @@ object Config : Vigilant( var maskWarning = false var cat = true var witherShieldDisplay = 0 + var spiritBowTimer = 0 var shouldPing = 0 var pingDisplay = 0 @@ -194,6 +195,12 @@ object Config : Vigilant( description = "Displays remaining wither shield duration", options = listOf("Off", "Default", "Shadow", "Outline") ) + selector( + ::spiritBowTimer, + name = "Spirit bow break timer", + description = "Displays time until spirit bow breaks", + options = listOf("Off", "Default", "Shadow", "Outline") + ) subcategory("Ping and TPS") { selector( ::shouldPing, diff --git a/src/main/kotlin/com/ambientaddons/features/display/CatOverlay.kt b/src/main/kotlin/com/ambientaddons/features/display/CatOverlay.kt index ac35729..8f010ae 100644 --- a/src/main/kotlin/com/ambientaddons/features/display/CatOverlay.kt +++ b/src/main/kotlin/com/ambientaddons/features/display/CatOverlay.kt @@ -3,6 +3,7 @@ package com.ambientaddons.features.display import AmbientAddons.Companion.config import AmbientAddons.Companion.mc import com.ambientaddons.gui.GuiElement +import com.ambientaddons.gui.MoveGui import com.ambientaddons.utils.render.OverlayUtils import net.minecraft.client.renderer.GlStateManager import net.minecraft.util.ResourceLocation @@ -16,7 +17,9 @@ object CatOverlay { @SubscribeEvent fun onRenderOverlay(event: RenderGameOverlayEvent) { - if (!config.cat || event.type != RenderGameOverlayEvent.ElementType.TEXT) return + if ((!config.cat && mc.currentScreen !is MoveGui) || + event.type != RenderGameOverlayEvent.ElementType.TEXT + ) return GlStateManager.pushMatrix() GlStateManager.enableAlpha() GlStateManager.color(255f, 255f, 255f, 255f) diff --git a/src/main/kotlin/com/ambientaddons/features/display/PingOverlay.kt b/src/main/kotlin/com/ambientaddons/features/display/PingOverlay.kt index d8689be..409cb33 100644 --- a/src/main/kotlin/com/ambientaddons/features/display/PingOverlay.kt +++ b/src/main/kotlin/com/ambientaddons/features/display/PingOverlay.kt @@ -4,6 +4,7 @@ import AmbientAddons.Companion.config import AmbientAddons.Companion.mc import com.ambientaddons.events.ReceivePacketEvent import com.ambientaddons.gui.GuiElement +import com.ambientaddons.gui.MoveGui import com.ambientaddons.utils.Alignment import com.ambientaddons.utils.Extensions.renderWidth import com.ambientaddons.utils.Extensions.withModPrefix @@ -131,24 +132,38 @@ object PingOverlay { @SubscribeEvent fun onRenderOverlay(event: RenderGameOverlayEvent) { - if (config.pingDisplay == 0 || event.type != RenderGameOverlayEvent.ElementType.TEXT) return - val textStyle = TextStyle.fromInt(config.pingDisplay - 1) ?: return - GlStateManager.pushMatrix() - GlStateManager.translate(element.position.x, element.position.y, 500.0) - GlStateManager.scale(element.position.scale, element.position.scale, 1.0) - val tpsValue = averageTps?.let { "${colorizeTps(it) }%.1f".format(it) } ?: "§e?" - if (shouldPing()) { - val pingValue = averagePing?.let { "${colorizePing(it)}%.1f".format(it) } ?: "§e?" + if (event.type != RenderGameOverlayEvent.ElementType.TEXT) return + val textStyle = TextStyle.fromInt(config.pingDisplay - 1) ?: TextStyle.Outline + if (config.pingDisplay != 0) { + GlStateManager.pushMatrix() + GlStateManager.translate(element.position.x, element.position.y, 500.0) + GlStateManager.scale(element.position.scale, element.position.scale, 1.0) + val tpsValue = averageTps?.let { "${colorizeTps(it) }%.1f".format(it) } ?: "§e?" + if (shouldPing()) { + val pingValue = averagePing?.let { "${colorizePing(it)}%.1f".format(it) } ?: "§e?" + val valueWidth = max(pingValue.renderWidth(), tpsValue.renderWidth()) + OverlayUtils.drawString(0, 0, "§bPing:", textStyle, Alignment.Left) + OverlayUtils.drawString(0, 10, "§bTPS:", textStyle, Alignment.Left) + OverlayUtils.drawString(30 + valueWidth, 0, pingValue, textStyle, Alignment.Right) + OverlayUtils.drawString(30 + valueWidth, 10, tpsValue, textStyle, Alignment.Right) + } else { + OverlayUtils.drawString(0, 0, "§bTPS:", textStyle, Alignment.Left) + OverlayUtils.drawString(30 + tpsValue.renderWidth(), 0, tpsValue, textStyle, Alignment.Right) + } + GlStateManager.popMatrix() + } else if (mc.currentScreen is MoveGui) { + GlStateManager.pushMatrix() + GlStateManager.translate(element.position.x, element.position.y, 500.0) + GlStateManager.scale(element.position.scale, element.position.scale, 1.0) + val tpsValue = "§a19.8" + val pingValue = "§e103.1" val valueWidth = max(pingValue.renderWidth(), tpsValue.renderWidth()) OverlayUtils.drawString(0, 0, "§bPing:", textStyle, Alignment.Left) OverlayUtils.drawString(0, 10, "§bTPS:", textStyle, Alignment.Left) OverlayUtils.drawString(30 + valueWidth, 0, pingValue, textStyle, Alignment.Right) OverlayUtils.drawString(30 + valueWidth, 10, tpsValue, textStyle, Alignment.Right) - } else { - OverlayUtils.drawString(0, 0, "§bTPS:", textStyle, Alignment.Left) - OverlayUtils.drawString(30 + tpsValue.renderWidth(), 0, tpsValue, textStyle, Alignment.Right) + GlStateManager.popMatrix() } - GlStateManager.popMatrix() } diff --git a/src/main/kotlin/com/ambientaddons/features/display/ThornOverlay.kt b/src/main/kotlin/com/ambientaddons/features/display/ThornOverlay.kt new file mode 100644 index 0000000..70a5d2e --- /dev/null +++ b/src/main/kotlin/com/ambientaddons/features/display/ThornOverlay.kt @@ -0,0 +1,68 @@ +package com.ambientaddons.features.display + +import AmbientAddons.Companion.config +import AmbientAddons.Companion.mc +import com.ambientaddons.gui.GuiElement +import com.ambientaddons.gui.MoveGui +import com.ambientaddons.utils.Alignment +import com.ambientaddons.utils.Extensions.stripControlCodes +import com.ambientaddons.utils.SBLocation +import com.ambientaddons.utils.dungeon.TextStyle +import com.ambientaddons.utils.render.OverlayUtils +import net.minecraft.client.renderer.GlStateManager +import net.minecraftforge.client.event.ClientChatReceivedEvent +import net.minecraftforge.client.event.RenderGameOverlayEvent +import net.minecraftforge.event.world.WorldEvent +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import kotlin.math.roundToInt + +object ThornOverlay { + val element = GuiElement("thorn", 50, 10) + private var lastPickedUpBow: Long = -1 + private const val bowPickedUpString = "You picked up the Spirit Bow! Use it to attack Thorn!" + + @SubscribeEvent + fun onChat(event: ClientChatReceivedEvent) { + if (SBLocation.dungeonFloor?.floor != 4) return + if (event.message.unformattedText.stripControlCodes() == bowPickedUpString && lastPickedUpBow < 0) { + lastPickedUpBow = System.currentTimeMillis() + } + } + + @SubscribeEvent + fun onWorldUnload(event: WorldEvent.Unload) { + lastPickedUpBow = -1 + } + + private fun colorizeTime(time: Double) = when { + (time < 3) -> "§c" + (time < 5) -> "§e" + else -> "§a" + } + + @SubscribeEvent + fun onRenderOverlay(event: RenderGameOverlayEvent) { + if (event.type != RenderGameOverlayEvent.ElementType.TEXT) return + val textStyle = TextStyle.fromInt(config.spiritBowTimer - 1) ?: TextStyle.Outline + val timeUntilBreak = 20.0 - ((System.currentTimeMillis() - lastPickedUpBow) / 1000.0) + if (config.spiritBowTimer != 0 && SBLocation.dungeonFloor?.floor == 4) { + if (timeUntilBreak > 0) { + val timeString = "${colorizeTime(timeUntilBreak)}%.2f".format(timeUntilBreak) + GlStateManager.pushMatrix() + GlStateManager.translate(element.position.x, element.position.y, 500.0) + GlStateManager.scale(element.position.scale, element.position.scale, 1.0) + OverlayUtils.drawString(0, 0, "§bBow:", textStyle, Alignment.Left) + OverlayUtils.drawString(50, 0, timeString, textStyle, Alignment.Right) + GlStateManager.popMatrix() + } + } else if (mc.currentScreen is MoveGui) { + val timeString = "§e4.98" + GlStateManager.pushMatrix() + GlStateManager.translate(element.position.x, element.position.y, 500.0) + GlStateManager.scale(element.position.scale, element.position.scale, 1.0) + OverlayUtils.drawString(0, 0, "§bBow:", textStyle, Alignment.Left) + OverlayUtils.drawString(50, 0, timeString, textStyle, Alignment.Right) + GlStateManager.popMatrix() + } + } +}
\ No newline at end of file |