From fa35f69386a0184e637ab2c8588d448065219b15 Mon Sep 17 00:00:00 2001 From: MisterCheezeCake <75341435+MisterCheezeCake@users.noreply.github.com> Date: Mon, 29 Jul 2024 17:55:18 -0400 Subject: [PATCH 1/2] Added option to display numbers in the dwarven overlay --- .../config/categories/MiningCategory.java | 8 ++ .../config/configs/MiningConfig.java | 3 + .../skyblock/dwarven/DwarvenHud.java | 11 ++- .../widget/component/ProgressComponent.java | 3 + .../tabhud/widget/hud/HudCommsWidget.java | 94 +++++++++++++++++-- .../assets/skyblocker/lang/en_us.json | 2 + src/main/resources/fabric.mod.json | 2 +- 7 files changed, 111 insertions(+), 12 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/config/categories/MiningCategory.java b/src/main/java/de/hysky/skyblocker/config/categories/MiningCategory.java index 796a6105eb..7d49c6752e 100644 --- a/src/main/java/de/hysky/skyblocker/config/categories/MiningCategory.java +++ b/src/main/java/de/hysky/skyblocker/config/categories/MiningCategory.java @@ -85,6 +85,14 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig newValue -> config.mining.dwarvenHud.style = newValue) .controller(ConfigUtils::createEnumCyclingListController) .build()) + .option(Option.createBuilder() + .name(Text.translatable("skyblocker.config.mining.dwarvenHud.showNumbers")) + .description(OptionDescription.of(Text.translatable("skyblocker.config.mining.dwarvenHud.showNumbers.@Tooltip"))) + .binding(defaults.mining.dwarvenHud.showNumbers, + () -> config.mining.dwarvenHud.showNumbers, + newValue -> config.mining.dwarvenHud.showNumbers = newValue) + .controller(ConfigUtils::createBooleanController) + .build()) .option(ButtonOption.createBuilder() .name(Text.translatable("skyblocker.config.mining.dwarvenHud.screen")) .text(Text.translatable("text.skyblocker.open")) diff --git a/src/main/java/de/hysky/skyblocker/config/configs/MiningConfig.java b/src/main/java/de/hysky/skyblocker/config/configs/MiningConfig.java index dcf70f247f..cd988b165d 100644 --- a/src/main/java/de/hysky/skyblocker/config/configs/MiningConfig.java +++ b/src/main/java/de/hysky/skyblocker/config/configs/MiningConfig.java @@ -48,6 +48,9 @@ public static class DwarvenHud { @SerialEntry public DwarvenHudStyle style = DwarvenHudStyle.SIMPLE; + @SerialEntry + public boolean showNumbers = false; + @SerialEntry public int commissionsX = 10; diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/DwarvenHud.java b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/DwarvenHud.java index 16c36dde35..f6d6ed6db4 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/DwarvenHud.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/DwarvenHud.java @@ -89,11 +89,12 @@ protected static void render(HudCommsWidget hcw, HudPowderWidget hpw, DrawContex /** * Renders hud to window without using the widget rendering - * @param context DrawContext to draw the hud to - * @param comHudX X coordinate of the commissions hud - * @param comHudY Y coordinate of the commissions hud - * @param powderHudX X coordinate of the powder hud - * @param powderHudY Y coordinate of the powder hud + * + * @param context DrawContext to draw the hud to + * @param comHudX X coordinate of the commissions hud + * @param comHudY Y coordinate of the commissions hud + * @param powderHudX X coordinate of the powder hud + * @param powderHudY Y coordinate of the powder hud * @param commissions the commissions to render to the commissions hud */ @Deprecated(since = "1.20.3+1.20.6", forRemoval = true) diff --git a/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/component/ProgressComponent.java b/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/component/ProgressComponent.java index 9522be43b5..93c33b090c 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/component/ProgressComponent.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/component/ProgressComponent.java @@ -48,6 +48,9 @@ public ProgressComponent(ItemStack ico, Text d, Text b, float pcnt, int color) { public ProgressComponent(ItemStack ico, Text text, float pcnt, int color) { this(ico, text, Text.of(pcnt + "%"), pcnt, color); } + public ProgressComponent(ItemStack ico, Text text, float pcnt, int max, int color) { + this(ico, text, Text.of(Math.round(max * (pcnt/100)) + "/" + max), pcnt, color); + } public ProgressComponent() { this(null, null, null, 100, 0); diff --git a/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/hud/HudCommsWidget.java b/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/hud/HudCommsWidget.java index 44a06c99e0..8efc08401d 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/hud/HudCommsWidget.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/hud/HudCommsWidget.java @@ -1,5 +1,6 @@ package de.hysky.skyblocker.skyblock.tabhud.widget.hud; +import de.hysky.skyblocker.config.SkyblockerConfigManager; import de.hysky.skyblocker.skyblock.dwarven.DwarvenHud.Commission; import de.hysky.skyblocker.skyblock.tabhud.util.Colors; import de.hysky.skyblocker.skyblock.tabhud.util.Ico; @@ -7,6 +8,7 @@ import de.hysky.skyblocker.skyblock.tabhud.widget.component.Component; import de.hysky.skyblocker.skyblock.tabhud.widget.component.PlainTextComponent; import de.hysky.skyblocker.skyblock.tabhud.widget.component.ProgressComponent; +import de.hysky.skyblocker.utils.Utils; import net.minecraft.text.MutableText; import net.minecraft.text.Text; import net.minecraft.util.Formatting; @@ -54,17 +56,97 @@ public void updateContent() { } Component comp; + var max = getCommissionMax(comm.commission()); if (isFancy) { - comp = new ProgressComponent(Ico.BOOK, c, p, Colors.pcntToCol(p)); + if (SkyblockerConfigManager.get().mining.dwarvenHud.showNumbers && max != null) { + comp = new ProgressComponent(Ico.BOOK, c, p, max, Colors.pcntToCol(p)); + } else { + comp = new ProgressComponent(Ico.BOOK, c, p, Colors.pcntToCol(p)); + } } else { - comp = new PlainTextComponent( - Text.literal(comm.commission() + ": ").append( - Text.literal(comm.progression()).withColor(Colors.pcntToCol(p)) - ) - ); + if (SkyblockerConfigManager.get().mining.dwarvenHud.showNumbers && max != null) { + comp = new PlainTextComponent( + Text.literal(comm.commission() + ": ").append( + Text.literal(p == 100f ? "DONE" : Math.round(max * (p / 100)) + "/" + max).withColor(Colors.pcntToCol(p)) + ) + ); + } else { + comp = new PlainTextComponent( + Text.literal(comm.commission() + ": ").append( + Text.literal(comm.progression()).withColor(Colors.pcntToCol(p)) + ) + ); + } } this.addComponent(comp); } } + /** + * Gets the actions needed to complete a commission + * + * @param commission the string name of the commission + * @return the actions needed to complete the commission + */ + private static Integer getCommissionMax(String commission) { + switch (commission) { + case "Mithril Miner" -> { + return 350; + } + case "Lava Springs Mithril", "Royal Mines Mithril", "Cliffside Veins Mithril", "Rampart's Quarry Mithril", + "Upper Mines Mithril" -> { + return 250; + } + case "Titanium Miner" -> { + return 15; + } + case "Lava Springs Titanium", "Royal Mines Titanium", "Cliffside Veins Titanium", + "Rampart's Quarry Titanium", "Upper Mines Titanium", "Treasure Hoarder Puncher", "Star Sentry Puncher", + "Maniac Slayer" -> { + return 10; + } + case "Goblin Slayer" -> { + return Utils.isInCrystalHollows() ? 13 : 100; + } + case "Glacite Walker Slayer", "Mines Slayer" -> { + return 50; + } + case "Goblin Raid Slayer", "Lucky Raffle" -> { + return 20; + } + case "Golden Goblin Slayer", "Boss Corleone Slayer", "Mineshaft Explorer", "Scrap Collector", "Goblin Raid", + "Raffle", "Jade Crystal Hunter", "Amber Crystal Hunter", "Topaz Crystal Hunter", + "Sapphire Crystal Hunter", "Amethyst Crystal Hunter" -> { + return 1; + } + case "2x Mithril Powder Collector" -> { + return 500; + } + case "Hard Stone Miner", "Jade Gemstone Collector", "Amber Gemstone Collector", "Topaz Gemstone Collector", + "Sapphire Gemstone Collector", "Amethyst Gemstone Collector", "Ruby Gemstone Collector" -> { + return 1000; + } + case "Chest Looter", "Corpse Looter" -> { + return 3; + } + case "Team Treasurite Member Slayer", "Yog Slayer", "Automaton Slayer" -> { + return 13; + } + case "Sludge Slayer" -> { + return 25; + } + case "Thyst Slayer" -> { + return 5; + } + case "Glacite Collector", "Umber Collector", "Tungsten Collector", "Citrine Gemstone Collector", + "Peridot Gemstone Collector", "Onyx Gemstone Collector", "Aquamarine Gemstone Collector" -> { + return 1500; + } + default -> { + return null; + } + + } + } + } diff --git a/src/main/resources/assets/skyblocker/lang/en_us.json b/src/main/resources/assets/skyblocker/lang/en_us.json index 129381a27d..ff9815cdd8 100644 --- a/src/main/resources/assets/skyblocker/lang/en_us.json +++ b/src/main/resources/assets/skyblocker/lang/en_us.json @@ -525,6 +525,8 @@ "skyblocker.config.mining.dwarvenHud.enabledCommissions": "Enable Commissions", "skyblocker.config.mining.dwarvenHud.enabledPowder": "Enable Powder", "skyblocker.config.mining.dwarvenHud.screen": "Dwarven HUD Config...", + "skyblocker.config.mining.dwarvenHud.showNumbers": "Show Commission Numbers", + "skyblocker.config.mining.dwarvenHud.showNumbers.@Tooltip": "Show the number of actions for each commission instead of a percentage.", "skyblocker.config.mining.dwarvenHud.style": "Style for HUD", "skyblocker.config.mining.dwarvenHud.style.@Tooltip[0]": "Simple: Shows name and percentage.", "skyblocker.config.mining.dwarvenHud.style.@Tooltip[1]": "\nFancy: Shows name, percentage, progress bar and an icon.", diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 1361c00af0..28e5696a27 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -5,7 +5,7 @@ "name": "Skyblocker", "description": "Hypixel Skyblock Mod", "authors": ["LifeIsAParadox/wohlhabend", "kevinthegreat1", "AzureAaron"], - "contributors": ["xMrVizzy", "d3dx9", "ExternalTime", "Zailer43", "TacoMonkey", "KonaeAkira", "Fix3dll", "null2264", "HyperSoop", "edgarogh", "TheColdPot", "Julienraptor01", "ADON15c", "catandA", "msg-programs", "lantice3720", "Futuremappermydud", "koloiyolo", "viciscat", "Grayray75", "alexiayaa", "KhafraDev", "btwonion", "Kaluub", "Emirlol", "LegendaryLilac", "olim88", "Ghost-3", "esteban4567890", "Fluboxer", "VeritasDL", "TheDearbear", "BigloBot", "f3shqt", "UpFault"], + "contributors": ["xMrVizzy", "d3dx9", "ExternalTime", "Zailer43", "TacoMonkey", "KonaeAkira", "Fix3dll", "null2264", "HyperSoop", "edgarogh", "TheColdPot", "Julienraptor01", "ADON15c", "catandA", "msg-programs", "lantice3720", "Futuremappermydud", "koloiyolo", "viciscat", "Grayray75", "alexiayaa", "KhafraDev", "btwonion", "Kaluub", "Emirlol", "LegendaryLilac", "olim88", "Ghost-3", "esteban4567890", "Fluboxer", "VeritasDL", "TheDearbear", "BigloBot", "f3shqt", "UpFault", "MisterCheezeCake"], "contact": { "homepage": "https://hysky.de", "sources": "https://github.com/SkyblockerMod/Skyblocker", From 98090c23f6686eafc0610aa6c58493d4fc80cde2 Mon Sep 17 00:00:00 2001 From: MisterCheezeCake <75341435+MisterCheezeCake@users.noreply.github.com> Date: Tue, 30 Jul 2024 20:02:14 -0400 Subject: [PATCH 2/2] requested changes --- .../tabhud/widget/component/ProgressComponent.java | 1 + .../skyblock/tabhud/widget/hud/HudCommsWidget.java | 8 ++++---- src/main/resources/fabric.mod.json | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/component/ProgressComponent.java b/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/component/ProgressComponent.java index 93c33b090c..50ff64622e 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/component/ProgressComponent.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/component/ProgressComponent.java @@ -48,6 +48,7 @@ public ProgressComponent(ItemStack ico, Text d, Text b, float pcnt, int color) { public ProgressComponent(ItemStack ico, Text text, float pcnt, int color) { this(ico, text, Text.of(pcnt + "%"), pcnt, color); } + public ProgressComponent(ItemStack ico, Text text, float pcnt, int max, int color) { this(ico, text, Text.of(Math.round(max * (pcnt/100)) + "/" + max), pcnt, color); } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/hud/HudCommsWidget.java b/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/hud/HudCommsWidget.java index 8efc08401d..c7ebead5e1 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/hud/HudCommsWidget.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/hud/HudCommsWidget.java @@ -58,13 +58,13 @@ public void updateContent() { Component comp; var max = getCommissionMax(comm.commission()); if (isFancy) { - if (SkyblockerConfigManager.get().mining.dwarvenHud.showNumbers && max != null) { + if (SkyblockerConfigManager.get().mining.dwarvenHud.showNumbers && max != 0) { comp = new ProgressComponent(Ico.BOOK, c, p, max, Colors.pcntToCol(p)); } else { comp = new ProgressComponent(Ico.BOOK, c, p, Colors.pcntToCol(p)); } } else { - if (SkyblockerConfigManager.get().mining.dwarvenHud.showNumbers && max != null) { + if (SkyblockerConfigManager.get().mining.dwarvenHud.showNumbers && max != 0) { comp = new PlainTextComponent( Text.literal(comm.commission() + ": ").append( Text.literal(p == 100f ? "DONE" : Math.round(max * (p / 100)) + "/" + max).withColor(Colors.pcntToCol(p)) @@ -88,7 +88,7 @@ public void updateContent() { * @param commission the string name of the commission * @return the actions needed to complete the commission */ - private static Integer getCommissionMax(String commission) { + private static int getCommissionMax(String commission) { switch (commission) { case "Mithril Miner" -> { return 350; @@ -143,7 +143,7 @@ private static Integer getCommissionMax(String commission) { return 1500; } default -> { - return null; + return 0; } } diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 28e5696a27..1361c00af0 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -5,7 +5,7 @@ "name": "Skyblocker", "description": "Hypixel Skyblock Mod", "authors": ["LifeIsAParadox/wohlhabend", "kevinthegreat1", "AzureAaron"], - "contributors": ["xMrVizzy", "d3dx9", "ExternalTime", "Zailer43", "TacoMonkey", "KonaeAkira", "Fix3dll", "null2264", "HyperSoop", "edgarogh", "TheColdPot", "Julienraptor01", "ADON15c", "catandA", "msg-programs", "lantice3720", "Futuremappermydud", "koloiyolo", "viciscat", "Grayray75", "alexiayaa", "KhafraDev", "btwonion", "Kaluub", "Emirlol", "LegendaryLilac", "olim88", "Ghost-3", "esteban4567890", "Fluboxer", "VeritasDL", "TheDearbear", "BigloBot", "f3shqt", "UpFault", "MisterCheezeCake"], + "contributors": ["xMrVizzy", "d3dx9", "ExternalTime", "Zailer43", "TacoMonkey", "KonaeAkira", "Fix3dll", "null2264", "HyperSoop", "edgarogh", "TheColdPot", "Julienraptor01", "ADON15c", "catandA", "msg-programs", "lantice3720", "Futuremappermydud", "koloiyolo", "viciscat", "Grayray75", "alexiayaa", "KhafraDev", "btwonion", "Kaluub", "Emirlol", "LegendaryLilac", "olim88", "Ghost-3", "esteban4567890", "Fluboxer", "VeritasDL", "TheDearbear", "BigloBot", "f3shqt", "UpFault"], "contact": { "homepage": "https://hysky.de", "sources": "https://github.com/SkyblockerMod/Skyblocker",