From acc866dc2a5f1f55ea8307321e31f8f3a8742e5e Mon Sep 17 00:00:00 2001 From: Lorenz Date: Tue, 16 Aug 2022 23:11:13 +0200 Subject: add ashfang reset cooldown --- .../java/at/hannibal2/skyhanni/SkyHanniMod.java | 4 +- .../at/hannibal2/skyhanni/config/Features.java | 9 +++- .../skyhanni/config/features/Abilities.java | 10 ++++ .../features/abilities/AshfangFreezeCooldown.kt | 43 ---------------- .../misc/nether/ashfang/AshfangFreezeCooldown.kt | 43 ++++++++++++++++ .../nether/ashfang/AshfangNextResetCooldown.kt | 58 ++++++++++++++++++++++ 6 files changed, 121 insertions(+), 46 deletions(-) delete mode 100644 src/main/java/at/hannibal2/skyhanni/features/abilities/AshfangFreezeCooldown.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/misc/nether/ashfang/AshfangFreezeCooldown.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/misc/nether/ashfang/AshfangNextResetCooldown.kt (limited to 'src/main') diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java index 86b7c3f5b..4ee380890 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java @@ -11,7 +11,6 @@ import at.hannibal2.skyhanni.config.Features; import at.hannibal2.skyhanni.config.gui.commands.Commands; import at.hannibal2.skyhanni.damageindicator.BossDamageIndicator; import at.hannibal2.skyhanni.dungeon.*; -import at.hannibal2.skyhanni.features.abilities.AshfangFreezeCooldown; import at.hannibal2.skyhanni.fishing.SeaCreatureManager; import at.hannibal2.skyhanni.fishing.SeaCreatureMessageShortener; import at.hannibal2.skyhanni.fishing.TrophyFishMessages; @@ -20,6 +19,8 @@ import at.hannibal2.skyhanni.items.HideNotClickableItems; import at.hannibal2.skyhanni.items.ItemDisplayOverlayFeatures; import at.hannibal2.skyhanni.items.abilitycooldown.ItemAbilityCooldown; import at.hannibal2.skyhanni.misc.*; +import at.hannibal2.skyhanni.misc.nether.ashfang.AshfangFreezeCooldown; +import at.hannibal2.skyhanni.misc.nether.ashfang.AshfangNextResetCooldown; import at.hannibal2.skyhanni.repo.RepoManager; import at.hannibal2.skyhanni.test.LorenzTest; import com.google.gson.Gson; @@ -84,6 +85,7 @@ public class SkyHanniMod { registerEvent(new SeaCreatureMessageShortener()); // registerEvent(new GriffinBurrowFinder()); registerEvent(new AshfangFreezeCooldown()); + registerEvent(new AshfangNextResetCooldown()); registerEvent(new SummoningSoulsName()); Commands.init(); diff --git a/src/main/java/at/hannibal2/skyhanni/config/Features.java b/src/main/java/at/hannibal2/skyhanni/config/Features.java index 00eaa6074..833cb8123 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/Features.java +++ b/src/main/java/at/hannibal2/skyhanni/config/Features.java @@ -1,13 +1,13 @@ package at.hannibal2.skyhanni.config; import at.hannibal2.skyhanni.SkyHanniMod; +import at.hannibal2.skyhanni.config.features.*; import at.hannibal2.skyhanni.config.gui.config.ConfigEditor; import at.hannibal2.skyhanni.config.gui.core.GuiElement; import at.hannibal2.skyhanni.config.gui.core.GuiScreenElementWrapper; import at.hannibal2.skyhanni.config.gui.core.config.Position; -import at.hannibal2.skyhanni.config.gui.core.config.annotations.*; +import at.hannibal2.skyhanni.config.gui.core.config.annotations.Category; import at.hannibal2.skyhanni.config.gui.core.config.gui.GuiPositionEditor; -import at.hannibal2.skyhanni.config.features.*; import com.google.gson.annotations.Expose; import net.minecraft.client.Minecraft; @@ -56,6 +56,11 @@ public class Features { editOverlay(activeConfigCategory, 200, 16, abilities.ashfangFreezeCooldownPos); return; } + + if (runnableId.equals("ashfangResetCooldown")) { + editOverlay(activeConfigCategory, 200, 16, abilities.ashfangNextResetCooldownPos); + return; + } } @Expose diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Abilities.java b/src/main/java/at/hannibal2/skyhanni/config/features/Abilities.java index 73fb588ef..b723272c2 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/Abilities.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/Abilities.java @@ -27,4 +27,14 @@ public class Abilities { @ConfigOption(name = "Ashfang Freeze Position", desc = "") @ConfigEditorButton(runnableId = "ashfangFreezeCooldown", buttonText = "Edit") public Position ashfangFreezeCooldownPos = new Position(10, 10, false, true); + + @Expose + @ConfigOption(name = "Ashfang Reset", desc = "Shows the cooldown until ashfang pulls his underlings back") + @ConfigEditorBoolean + public boolean ashfangNextResetCooldown = false; + + @Expose + @ConfigOption(name = "Ashfang Reset Position", desc = "") + @ConfigEditorButton(runnableId = "ashfangResetCooldown", buttonText = "Edit") + public Position ashfangNextResetCooldownPos = new Position(10, 10, false, true); } diff --git a/src/main/java/at/hannibal2/skyhanni/features/abilities/AshfangFreezeCooldown.kt b/src/main/java/at/hannibal2/skyhanni/features/abilities/AshfangFreezeCooldown.kt deleted file mode 100644 index 5a5bdac0d..000000000 --- a/src/main/java/at/hannibal2/skyhanni/features/abilities/AshfangFreezeCooldown.kt +++ /dev/null @@ -1,43 +0,0 @@ -package at.hannibal2.skyhanni.features.abilities - -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/misc/nether/ashfang/AshfangFreezeCooldown.kt b/src/main/java/at/hannibal2/skyhanni/misc/nether/ashfang/AshfangFreezeCooldown.kt new file mode 100644 index 000000000..1a413d0bf --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/misc/nether/ashfang/AshfangFreezeCooldown.kt @@ -0,0 +1,43 @@ +package at.hannibal2.skyhanni.misc.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/misc/nether/ashfang/AshfangNextResetCooldown.kt b/src/main/java/at/hannibal2/skyhanni/misc/nether/ashfang/AshfangNextResetCooldown.kt new file mode 100644 index 000000000..41ad05908 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/misc/nether/ashfang/AshfangNextResetCooldown.kt @@ -0,0 +1,58 @@ +package at.hannibal2.skyhanni.misc.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 { + + var spawnTime = 1L + + @SubscribeEvent + fun renderOverlay(event: ClientTickEvent) { + if (!isEnabled()) return + + if (spawnTime == -1L) { + val spawned = Minecraft.getMinecraft().theWorld.loadedEntityList.any { + it is EntityArmorStand && (it.name.contains("§c§8Ashfang Follower§r") || + it.name.contains("§c§9Ashfang Acolyte§r") || + it.name.contains("§c§cAshfang Underling§r")) + } + if (spawned) { + spawnTime = System.currentTimeMillis() + } + } + } + + @SubscribeEvent + fun renderOverlay(event: RenderGameOverlayEvent.Post) { + if (!isEnabled()) return + if (spawnTime == -1L) return + + val remainingTime = spawnTime + 45_000 - 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 -- cgit