diff --git a/src/main/java/de/hysky/skyblocker/SkyblockerMod.java b/src/main/java/de/hysky/skyblocker/SkyblockerMod.java index f9bcbe0d5c..41ee483f92 100644 --- a/src/main/java/de/hysky/skyblocker/SkyblockerMod.java +++ b/src/main/java/de/hysky/skyblocker/SkyblockerMod.java @@ -99,6 +99,7 @@ public void onInitializeClient() { DungeonSecrets.init(); DungeonBlaze.init(); ChestValue.init(); + FireFreezeStaffTimer.init(); TheRift.init(); TitleContainer.init(); ScreenMaster.init(); diff --git a/src/main/java/de/hysky/skyblocker/config/SkyblockerConfig.java b/src/main/java/de/hysky/skyblocker/config/SkyblockerConfig.java index 633ea670e8..4daa96c04e 100644 --- a/src/main/java/de/hysky/skyblocker/config/SkyblockerConfig.java +++ b/src/main/java/de/hysky/skyblocker/config/SkyblockerConfig.java @@ -629,6 +629,9 @@ public static class Dungeons { @SerialEntry public boolean solveTicTacToe = true; + @SerialEntry + public boolean fireFreezeStaffTimer = true; + @SerialEntry public LividColor lividColor = new LividColor(); diff --git a/src/main/java/de/hysky/skyblocker/config/categories/DungeonsCategory.java b/src/main/java/de/hysky/skyblocker/config/categories/DungeonsCategory.java index 2f738ff220..0a68ef5e71 100644 --- a/src/main/java/de/hysky/skyblocker/config/categories/DungeonsCategory.java +++ b/src/main/java/de/hysky/skyblocker/config/categories/DungeonsCategory.java @@ -317,6 +317,14 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig newValue -> config.locations.dungeons.solveTicTacToe = newValue) .controller(ConfigUtils::createBooleanController) .build()) + .option(Option.createBuilder() + .name(Text.translatable("text.autoconfig.skyblocker.option.locations.dungeons.fireFreezeStaffTimer")) + .description(OptionDescription.of(Text.translatable("text.autoconfig.skyblocker.option.locations.dungeons.fireFreezeStaffTimer.@Tooltip"))) + .binding(defaults.locations.dungeons.fireFreezeStaffTimer, + () -> config.locations.dungeons.fireFreezeStaffTimer, + newValue -> config.locations.dungeons.fireFreezeStaffTimer = newValue) + .controller(ConfigUtils::createBooleanController) + .build()) //Livid Color .group(OptionGroup.createBuilder() diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/FireFreezeStaffTimer.java b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/FireFreezeStaffTimer.java new file mode 100644 index 0000000000..e5d4f078e2 --- /dev/null +++ b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/FireFreezeStaffTimer.java @@ -0,0 +1,59 @@ +package de.hysky.skyblocker.skyblock.dungeon; + +import de.hysky.skyblocker.config.SkyblockerConfigManager; +import net.fabricmc.fabric.api.client.message.v1.ClientReceiveMessageEvents; +import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents; +import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.font.TextRenderer; +import net.minecraft.client.gui.DrawContext; +import net.minecraft.text.Text; +import net.minecraft.util.Formatting; + +public class FireFreezeStaffTimer { + private static long fireFreezeTimer; + + public static void init() { + HudRenderCallback.EVENT.register(FireFreezeStaffTimer::onDraw); + ClientReceiveMessageEvents.GAME.register(FireFreezeStaffTimer::onChatMessage); + ClientPlayConnectionEvents.JOIN.register((handler, sender, client) -> FireFreezeStaffTimer.reset()); + } + + private static void onDraw(DrawContext context, float v) { + MinecraftClient client = MinecraftClient.getInstance(); + + if (client.currentScreen != null) return; + + if (SkyblockerConfigManager.get().locations.dungeons.fireFreezeStaffTimer && fireFreezeTimer != 0) { + long now = System.currentTimeMillis(); + + if (now >= fireFreezeTimer + 5000) { + reset(); + return; + } + + String message = + fireFreezeTimer > now + ? String.format("%.2f", (float) (fireFreezeTimer - now) / 1000) + "s" + : "NOW"; + + TextRenderer renderer = client.textRenderer; + int width = client.getWindow().getScaledWidth() / 2; + int height = client.getWindow().getScaledHeight() / 2; + + context.drawCenteredTextWithShadow( + renderer, "Fire freeze in: " + message, width, height, 0xffffff); + } + } + + private static void reset() { + fireFreezeTimer = 0; + } + + private static void onChatMessage(Text text, boolean overlay) { + if (!overlay && SkyblockerConfigManager.get().locations.dungeons.fireFreezeStaffTimer && Formatting.strip(text.getString()) + .equals("[BOSS] The Professor: Oh? You found my Guardians' one weakness?")) { + fireFreezeTimer = System.currentTimeMillis() + 5000L; + } + } +} diff --git a/src/main/resources/assets/skyblocker/lang/en_us.json b/src/main/resources/assets/skyblocker/lang/en_us.json index 1a52732658..47b7d1f007 100644 --- a/src/main/resources/assets/skyblocker/lang/en_us.json +++ b/src/main/resources/assets/skyblocker/lang/en_us.json @@ -229,6 +229,8 @@ "text.autoconfig.skyblocker.option.locations.dungeons.terminals.solveColor": "Solve Select Colored", "text.autoconfig.skyblocker.option.locations.dungeons.terminals.solveOrder": "Solve Click In Order", "text.autoconfig.skyblocker.option.locations.dungeons.terminals.solveStartsWith": "Solve Starts With", + "text.autoconfig.skyblocker.option.locations.dungeons.fireFreezeStaffTimer": "Fire Freeze Staff Timer (F3/M3)", + "text.autoconfig.skyblocker.option.locations.dungeons.fireFreezeStaffTimer.@Tooltip": "Display a timer when to use a Fire Freeze Staff in the F3/M3 boss fight.", "text.autoconfig.skyblocker.option.locations.dwarvenMines": "Dwarven Mines", "text.autoconfig.skyblocker.option.locations.dwarvenMines.enableDrillFuel": "Enable Drill Fuel", "text.autoconfig.skyblocker.option.locations.dwarvenMines.solveFetchur": "Solve Fetchur",