-
-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add f3/m3 fire freeze staff timer (#436)
- Loading branch information
Showing
5 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
src/main/java/de/hysky/skyblocker/skyblock/dungeon/FireFreezeStaffTimer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters