Skip to content

Commit

Permalink
Add f3/m3 fire freeze staff timer (#436)
Browse files Browse the repository at this point in the history
  • Loading branch information
KhafraDev authored Dec 5, 2023
1 parent 78dbe6c commit 75b49aa
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/main/java/de/hysky/skyblocker/SkyblockerMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ public void onInitializeClient() {
DungeonSecrets.init();
DungeonBlaze.init();
ChestValue.init();
FireFreezeStaffTimer.init();
TheRift.init();
TitleContainer.init();
ScreenMaster.init();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,9 @@ public static class Dungeons {
@SerialEntry
public boolean solveTicTacToe = true;

@SerialEntry
public boolean fireFreezeStaffTimer = true;

@SerialEntry
public LividColor lividColor = new LividColor();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,14 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig
newValue -> config.locations.dungeons.solveTicTacToe = newValue)
.controller(ConfigUtils::createBooleanController)
.build())
.option(Option.<Boolean>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()
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}
}
}
2 changes: 2 additions & 0 deletions src/main/resources/assets/skyblocker/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 75b49aa

Please sign in to comment.