diff options
author | Lorenz <lo.scherf@gmail.com> | 2022-08-17 03:05:34 +0200 |
---|---|---|
committer | Lorenz <lo.scherf@gmail.com> | 2022-08-17 03:05:34 +0200 |
commit | ef58a94bf31868c4b53218474f0be04c1cd93d97 (patch) | |
tree | cb56d5969f8bebf586298475a61c521229663fda /src/main/java/at/hannibal2/skyhanni/features/nether | |
parent | 5669dbf6f68e7cacb2df6a4e37d703df8635353e (diff) | |
download | skyhanni-ef58a94bf31868c4b53218474f0be04c1cd93d97.tar.gz skyhanni-ef58a94bf31868c4b53218474f0be04c1cd93d97.tar.bz2 skyhanni-ef58a94bf31868c4b53218474f0be04c1cd93d97.zip |
moving packets around
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/nether')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangFreezeCooldown.kt | 43 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangNextResetCooldown.kt | 53 |
2 files changed, 96 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangFreezeCooldown.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangFreezeCooldown.kt new file mode 100644 index 000000000..7cc7b54a3 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangFreezeCooldown.kt @@ -0,0 +1,43 @@ +package at.hannibal2.skyhanni.features.nether.ashfang + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.utils.GuiRender.renderString +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.LorenzUtils.matchRegex +import net.minecraftforge.client.event.RenderGameOverlayEvent +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import java.text.DecimalFormat + +class AshfangFreezeCooldown { + + var lastHit = 0L + + @SubscribeEvent + fun onChatMessage(event: LorenzChatEvent) { + if (!isEnabled()) return + + val message = event.message + if (message.matchRegex("§cAshfang Follower's Cryogenic Blast hit you for (.*) damage!")) { + lastHit = System.currentTimeMillis() + } + } + + @SubscribeEvent + fun renderOverlay(event: RenderGameOverlayEvent.Post) { + if (!isEnabled()) return + val duration = System.currentTimeMillis() - lastHit + val maxDuration = 3_000 + + val remainingLong = maxDuration - duration + if (remainingLong > 0) { + val remaining = (remainingLong.toFloat() / 1000) + val format = DecimalFormat("0.0").format(remaining + 0.1) + SkyHanniMod.feature.abilities.ashfangFreezeCooldownPos.renderString("§cAshfang Freeze: §a${format}s") + } + } + + private fun isEnabled(): Boolean { + return LorenzUtils.inSkyblock && SkyHanniMod.feature.abilities.ashfangFreezeCooldown + } +}
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangNextResetCooldown.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangNextResetCooldown.kt new file mode 100644 index 000000000..59a98552a --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangNextResetCooldown.kt @@ -0,0 +1,53 @@ +package at.hannibal2.skyhanni.features.nether.ashfang + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.utils.GuiRender.renderString +import at.hannibal2.skyhanni.utils.LorenzUtils +import net.minecraft.client.Minecraft +import net.minecraft.entity.item.EntityArmorStand +import net.minecraftforge.client.event.RenderGameOverlayEvent +import net.minecraftforge.event.world.WorldEvent +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent +import java.text.DecimalFormat + +class AshfangNextResetCooldown { + + private var spawnTime = 1L + + @SubscribeEvent + fun renderOverlay(event: ClientTickEvent) { + if (!isEnabled()) return + + if (Minecraft.getMinecraft().theWorld.loadedEntityList.any { + it is EntityArmorStand && it.posY > 145 && + (it.name.contains("§c§9Ashfang Acolyte§r") || it.name.contains("§c§cAshfang Underling§r")) + }) { + spawnTime = System.currentTimeMillis() + } + } + + @SubscribeEvent + fun renderOverlay(event: RenderGameOverlayEvent.Post) { + if (!isEnabled()) return + if (spawnTime == -1L) return + + val remainingTime = spawnTime + 46_100 - System.currentTimeMillis() + if (remainingTime > 0) { + val remaining = (remainingTime.toFloat() / 1000) + val format = DecimalFormat("0.0").format(remaining + 0.1) + SkyHanniMod.feature.abilities.ashfangNextResetCooldownPos.renderString("§cAshfang next reset in: §a${format}s") + } else { + spawnTime = -1 + } + } + + @SubscribeEvent + fun renderOverlay(event: WorldEvent.Load) { + spawnTime = -1 + } + + private fun isEnabled(): Boolean { + return LorenzUtils.inSkyblock && SkyHanniMod.feature.abilities.ashfangNextResetCooldown + } +}
\ No newline at end of file |