diff options
author | Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> | 2023-07-10 16:36:00 +0800 |
---|---|---|
committer | Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> | 2023-07-17 12:55:25 +0800 |
commit | c2e3c7fe5eeea767d2ce517a7ef9e4c67a7968e5 (patch) | |
tree | aecab8631680b8b8039641a2c8f382c820fd5a98 /src/main/java/me/xmrvizzy/skyblocker/skyblock/dwarven/DwarvenHud.java | |
parent | 2129c4d2284a4f78d94e74b3e328b8e056607fe9 (diff) | |
download | Skyblocker-c2e3c7fe5eeea767d2ce517a7ef9e4c67a7968e5.tar.gz Skyblocker-c2e3c7fe5eeea767d2ce517a7ef9e4c67a7968e5.tar.bz2 Skyblocker-c2e3c7fe5eeea767d2ce517a7ef9e4c67a7968e5.zip |
Refactor queueOpenScreen
Diffstat (limited to 'src/main/java/me/xmrvizzy/skyblocker/skyblock/dwarven/DwarvenHud.java')
-rw-r--r-- | src/main/java/me/xmrvizzy/skyblocker/skyblock/dwarven/DwarvenHud.java | 56 |
1 files changed, 27 insertions, 29 deletions
diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/dwarven/DwarvenHud.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/dwarven/DwarvenHud.java index 122f6c6c..7316577e 100644 --- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/dwarven/DwarvenHud.java +++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/dwarven/DwarvenHud.java @@ -1,5 +1,6 @@ package me.xmrvizzy.skyblocker.skyblock.dwarven; +import me.xmrvizzy.skyblocker.SkyblockerMod; import me.xmrvizzy.skyblocker.config.SkyblockerConfig; import me.xmrvizzy.skyblocker.skyblock.tabhud.widget.CommsWidget; import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager; @@ -7,7 +8,6 @@ import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallba import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.DrawContext; -import net.minecraft.client.util.math.MatrixStack; import net.minecraft.text.Text; import net.minecraft.util.Formatting; @@ -26,34 +26,32 @@ public class DwarvenHud { public static final List<Pattern> COMMISSIONS = Stream.of( - "(?:Titanium|Mithril|Hard Stone) Miner", - "(?:Ice Walker|Goblin|Goblin Raid|Automaton|Sludge|Team Treasurite Member|Yog|Boss Corleone|Thyst) Slayer", - "(?:Lava Springs|Cliffside Veins|Rampart's Quarry|Upper Mines|Royal Mines) Mithril", - "(?:Lava Springs|Cliffside Veins|Rampart's Quarry|Upper Mines|Royal Mines) Titanium", - "Goblin Raid", - "(?:Powder Ghast|Star Sentry) Puncher", - "(?<!Lucky )Raffle", - "Lucky Raffle", - "2x Mithril Powder Collector", - "(?:Ruby|Amber|Sapphire|Jade|Amethyst|Topaz) Gemstone Collector", - "(?:Amber|Sapphire|Jade|Amethyst|Topaz) Crystal Hunter", - "Chest Looter" + "(?:Titanium|Mithril|Hard Stone) Miner", + "(?:Ice Walker|Goblin|Goblin Raid|Automaton|Sludge|Team Treasurite Member|Yog|Boss Corleone|Thyst) Slayer", + "(?:Lava Springs|Cliffside Veins|Rampart's Quarry|Upper Mines|Royal Mines) Mithril", + "(?:Lava Springs|Cliffside Veins|Rampart's Quarry|Upper Mines|Royal Mines) Titanium", + "Goblin Raid", + "(?:Powder Ghast|Star Sentry) Puncher", + "(?<!Lucky )Raffle", + "Lucky Raffle", + "2x Mithril Powder Collector", + "(?:Ruby|Amber|Sapphire|Jade|Amethyst|Topaz) Gemstone Collector", + "(?:Amber|Sapphire|Jade|Amethyst|Topaz) Crystal Hunter", + "Chest Looter" ).map(s -> Pattern.compile("^.*(" + s + "): (\\d+\\.?\\d*%|DONE)")) .collect(Collectors.toList()); + public static void init() { ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) -> dispatcher.register(ClientCommandManager.literal("skyblocker") .then(ClientCommandManager.literal("hud") .then(ClientCommandManager.literal("dwarven") - .executes(context -> { - client.send(() -> client.setScreen(new DwarvenHudConfigScreen(Text.of("Dwarven HUD Config")))); - return 1; - }))))); + .executes(context -> SkyblockerMod.getInstance().scheduler.queueOpenScreen(DwarvenHudConfigScreen::new)))))); HudRenderCallback.EVENT.register((context, tickDelta) -> { if (!SkyblockerConfig.get().locations.dwarvenMines.dwarvenHud.enabled - || client.options.playerListKey.isPressed() - || client.player == null - || commissionList.isEmpty()) { + || client.options.playerListKey.isPressed() + || client.player == null + || commissionList.isEmpty()) { return; } render(context, SkyblockerConfig.get().locations.dwarvenMines.dwarvenHud.x, SkyblockerConfig.get().locations.dwarvenMines.dwarvenHud.y, commissionList); @@ -62,7 +60,7 @@ public class DwarvenHud { public static void render(DrawContext context, int hudX, int hudY, List<Commission> commissions) { - switch(SkyblockerConfig.get().locations.dwarvenMines.dwarvenHud.style) { + switch (SkyblockerConfig.get().locations.dwarvenMines.dwarvenHud.style) { case SIMPLE -> renderSimple(context, hudX, hudY, commissions); case FANCY -> renderFancy(context, hudX, hudY, commissions); case CLASSIC -> renderClassic(context, hudX, hudY, commissions); @@ -77,12 +75,12 @@ public class DwarvenHud { int y = 0; for (Commission commission : commissions) { context - .drawTextWithShadow(client.textRenderer, - Text.literal(commission.commission + ": ") - .styled(style -> style.withColor(Formatting.AQUA)) - .append(Text.literal(commission.progression) - .styled(style -> style.withColor(Formatting.GREEN))), - hudX + 5, hudY + y + 5, 0xFFFFFFFF); + .drawTextWithShadow(client.textRenderer, + Text.literal(commission.commission + ": ") + .styled(style -> style.withColor(Formatting.AQUA)) + .append(Text.literal(commission.progression) + .styled(style -> style.withColor(Formatting.GREEN))), + hudX + 5, hudY + y + 5, 0xFFFFFFFF); y += 20; } } @@ -119,6 +117,6 @@ public class DwarvenHud { } // steamroller tactics to get visibility from outside classes (CommsWidget) - public static record Commission(String commission, String progression){} - + public record Commission(String commission, String progression) { + } }
\ No newline at end of file |