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/main/kotlin/com/ambientaddons/features/display | |
parent | 0576a7f5304565bb58a499b8ccdcda31ed587dc4 (diff) | |
download | AmbientAddons-10d1822a2a8a93fd34f4303aa7c09b9268ba0e60.tar.gz AmbientAddons-10d1822a2a8a93fd34f4303aa7c09b9268ba0e60.tar.bz2 AmbientAddons-10d1822a2a8a93fd34f4303aa7c09b9268ba0e60.zip |
+spirit bow overlay
Diffstat (limited to 'src/main/kotlin/com/ambientaddons/features/display')
3 files changed, 99 insertions, 13 deletions
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 |