diff --git a/src/main/java/wtf/cheeze/sbt/SkyblockTweaks.java b/src/main/java/wtf/cheeze/sbt/SkyblockTweaks.java index 254becc..18306fc 100644 --- a/src/main/java/wtf/cheeze/sbt/SkyblockTweaks.java +++ b/src/main/java/wtf/cheeze/sbt/SkyblockTweaks.java @@ -91,6 +91,7 @@ public void onInitialize() { HUDS.add(new TickerHUD()); HUDS.add(new QuiverHUD()); + HUDS.add(new ArmorStackHUD()); HudRenderCallback.EVENT.register((context, tickCounter) -> { HUDS.forEach(hud -> hud.render(context, false)); diff --git a/src/main/java/wtf/cheeze/sbt/config/categories/GlobalSearchCategory.java b/src/main/java/wtf/cheeze/sbt/config/categories/GlobalSearchCategory.java index 1e1d245..abd492a 100644 --- a/src/main/java/wtf/cheeze/sbt/config/categories/GlobalSearchCategory.java +++ b/src/main/java/wtf/cheeze/sbt/config/categories/GlobalSearchCategory.java @@ -67,6 +67,7 @@ public static ConfigCategory getCategory(ConfigImpl defaults, ConfigImpl config) .group(FpsHUD.Config.getGroup(defaults, config)) .group(TickerHUD.Config.getGroup(defaults, config)) .group(QuiverHUD.Config.getGroup(defaults, config)) + .group(ArmorStackHUD.Config.getGroup(defaults, config)) .build(); } diff --git a/src/main/java/wtf/cheeze/sbt/config/categories/Huds.java b/src/main/java/wtf/cheeze/sbt/config/categories/Huds.java index 2db9633..1ea701d 100644 --- a/src/main/java/wtf/cheeze/sbt/config/categories/Huds.java +++ b/src/main/java/wtf/cheeze/sbt/config/categories/Huds.java @@ -81,6 +81,9 @@ public class Huds { @SerialEntry public QuiverHUD.Config quiver = new QuiverHUD.Config(); + @SerialEntry + public ArmorStackHUD.Config armorStack = new ArmorStackHUD.Config(); + public static ConfigCategory getCategory(ConfigImpl defaults, ConfigImpl config) { return ConfigCategory.createBuilder() .name(Text.translatable("sbt.config.huds")) @@ -103,6 +106,7 @@ public static ConfigCategory getCategory(ConfigImpl defaults, ConfigImpl config) .group(FpsHUD.Config.getGroup(defaults, config)) .group(TickerHUD.Config.getGroup(defaults, config)) .group(QuiverHUD.Config.getGroup(defaults, config)) + .group(ArmorStackHUD.Config.getGroup(defaults, config)) .build(); } } diff --git a/src/main/java/wtf/cheeze/sbt/features/huds/ArmorStackHUD.java b/src/main/java/wtf/cheeze/sbt/features/huds/ArmorStackHUD.java new file mode 100644 index 0000000..c9e8a08 --- /dev/null +++ b/src/main/java/wtf/cheeze/sbt/features/huds/ArmorStackHUD.java @@ -0,0 +1,169 @@ +/* + * Copyright (C) 2024 MisterCheezeCake + * + * This file is part of SkyblockTweaks. + * + * SkyblockTweaks is free software: you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation, either + * version 3 of the License, or (at your option) any later version. + * + * SkyblockTweaks is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with SkyblockTweaks. If not, see . + */ +package wtf.cheeze.sbt.features.huds; + +import dev.isxander.yacl3.api.Option; +import dev.isxander.yacl3.api.OptionGroup; +import dev.isxander.yacl3.api.controller.ColorControllerBuilder; +import dev.isxander.yacl3.config.v2.api.SerialEntry; +import net.minecraft.text.Text; +import wtf.cheeze.sbt.SkyblockTweaks; +import wtf.cheeze.sbt.config.ConfigImpl; +import wtf.cheeze.sbt.config.SBTConfig; +import wtf.cheeze.sbt.hud.utils.AnchorPoint; +import wtf.cheeze.sbt.hud.utils.DrawMode; +import wtf.cheeze.sbt.hud.components.SingleHudLine; +import wtf.cheeze.sbt.hud.utils.HudInformation; +import wtf.cheeze.sbt.hud.bases.TextHUD; +import wtf.cheeze.sbt.utils.render.Colors; + +import java.awt.Color; + +public class ArmorStackHUD extends TextHUD { + + public ArmorStackHUD() { + INFO = new HudInformation( + () -> SBTConfig.huds().armorStack.x, + () -> SBTConfig.huds().armorStack.y, + () -> SBTConfig.huds().armorStack.scale, + () -> SBTConfig.huds().armorStack.anchor, + x -> SBTConfig.huds().armorStack.x = (float) x, + y -> SBTConfig.huds().armorStack.y = (float) y, + scale -> SBTConfig.huds().armorStack.scale = (float) scale, + anchor -> SBTConfig.huds().armorStack.anchor = anchor + ); + line = new SingleHudLine( + () -> SBTConfig.huds().armorStack.color, + () -> SBTConfig.huds().armorStack.outlineColor, + () -> SBTConfig.huds().armorStack.mode, + () -> SkyblockTweaks.DATA.stackString != null ? Text.literal(SkyblockTweaks.DATA.armorStack + SkyblockTweaks.DATA.stackString) : Text.literal("0ᝐ") + ); + } + @Override + public boolean shouldRender(boolean fromHudScreen) { + if (!super.shouldRender(fromHudScreen)) return false; + if (SkyblockTweaks.DATA.stackString == null && !fromHudScreen) return false; + if ((SkyblockTweaks.DATA.inSB && SBTConfig.huds().armorStack.enabled) || fromHudScreen) return true; + return false; + } + + @Override + public String getName() { + return "Armor Stack HUD"; + } + + public static class Config { + @SerialEntry + public boolean enabled = false; + + @SerialEntry + public DrawMode mode = DrawMode.SHADOW; + + @SerialEntry + public int color = Colors.ORANGE; + + @SerialEntry + public int outlineColor = Colors.BLACK; + + @SerialEntry // Not handled by YACL Gui + public float x = 0; + + @SerialEntry // Not handled by YACL Gui + public float y = 0.95f; + + @SerialEntry + public float scale = 1.0f; + + @SerialEntry + public AnchorPoint anchor = AnchorPoint.LEFT; + + public static OptionGroup getGroup(ConfigImpl defaults, ConfigImpl config) { + var enabled = Option.createBuilder() + .name(key("armorStack.enabled")) + .description(keyD("armorStack.enabled")) + .controller(SBTConfig::generateBooleanController) + .binding( + defaults.huds.armorStack.enabled, + () -> config.huds.armorStack.enabled, + value -> config.huds.armorStack.enabled = (Boolean) value + ) + .build(); + + var color = Option.createBuilder() + .name(key("armorStack.color")) + .description(keyD("armorStack.color")) + .controller(ColorControllerBuilder::create) + .binding( + new Color(defaults.huds.armorStack.color), + () -> new Color(config.huds.armorStack.color), + value -> config.huds.armorStack.color = value.getRGB() + + ) + .build(); + var outline = Option.createBuilder() + .name(key("armorStack.outlineColor")) + .description(keyD("armorStack.outlineColor")) + .controller(ColorControllerBuilder::create) + .available(config.huds.armorStack.mode == DrawMode.OUTLINE) + .binding( + new Color(defaults.huds.armorStack.outlineColor), + () -> new Color(config.huds.armorStack.outlineColor), + value -> config.huds.armorStack.outlineColor = value.getRGB() + + ) + .build(); + var mode = Option.createBuilder() + .name(key("armorStack.mode")) + .description(keyD("armorStack.mode")) + .controller(SBTConfig::generateDrawModeController) + .binding( + defaults.huds.armorStack.mode, + () -> config.huds.armorStack.mode, + value -> { + config.huds.armorStack.mode = value; + if (value == DrawMode.OUTLINE) outline.setAvailable(true); + else outline.setAvailable(false); + } + ) + .build(); + var scale = Option.createBuilder() + .name(key("armorStack.scale")) + .description(keyD("armorStack.scale")) + .controller(SBTConfig::generateScaleController) + .binding( + defaults.huds.armorStack.scale, + () -> config.huds.armorStack.scale, + value -> config.huds.armorStack.scale = value + ) + .build(); + + return OptionGroup.createBuilder() + .name(key("armorStack")) + .description(keyD("armorStack")) + .option(enabled) + .option(mode) + .option(color) + .option(outline) + .option(scale) + .collapsed(true) + .build(); + } + } +} + diff --git a/src/main/java/wtf/cheeze/sbt/utils/actionbar/ActionBarTransformer.java b/src/main/java/wtf/cheeze/sbt/utils/actionbar/ActionBarTransformer.java index 1fffaf6..9fa1b83 100644 --- a/src/main/java/wtf/cheeze/sbt/utils/actionbar/ActionBarTransformer.java +++ b/src/main/java/wtf/cheeze/sbt/utils/actionbar/ActionBarTransformer.java @@ -210,7 +210,7 @@ else if (unpadded.contains("§7§l")) { public static void registerEvents() { ClientReceiveMessageEvents.MODIFY_GAME.register((message, overlay) -> { if (!overlay) return message; - SkyblockTweaks.LOGGER.info("Old: " + message.getString()); + //SkyblockTweaks.LOGGER.info("Old: " + message.getString()); var data = ActionBarTransformer.extractDataAndRunTransformation(message.getString()); //SkyblockTweaks.LOGGER.info("New: " + data.transformedText); SkyblockTweaks.DATA.update(data); @@ -245,8 +245,6 @@ public static class Config { @SerialEntry public boolean hideTickers = false; - @SerialEntry - public boolean hideArmorStacks = false; public static OptionGroup getGroup(ConfigImpl defaults, ConfigImpl config) { var health = Option.createBuilder() diff --git a/src/main/java/wtf/cheeze/sbt/utils/skyblock/SkyblockData.java b/src/main/java/wtf/cheeze/sbt/utils/skyblock/SkyblockData.java index dc31507..5b770ef 100644 --- a/src/main/java/wtf/cheeze/sbt/utils/skyblock/SkyblockData.java +++ b/src/main/java/wtf/cheeze/sbt/utils/skyblock/SkyblockData.java @@ -56,6 +56,9 @@ public class SkyblockData { public int tickers = 0; public boolean tickerActive = false; + public int armorStack = 0; + public String stackString = null; + public float getSpeed() { @@ -95,6 +98,14 @@ public void update(ActionBarData data) { } else { this.tickerActive = false; } + if (data.stackSymbol != null && data.stackAmount !=null) { + this.stackString = data.stackSymbol; + this.armorStack = data.stackAmount; + } else { + this.stackString = null; + this.armorStack = 0; + } + } public void handlePacket(HypixelS2CPacket packet) { diff --git a/src/main/resources/assets/skyblocktweaks/lang/en_us.json b/src/main/resources/assets/skyblocktweaks/lang/en_us.json index 4ed7d85..70896ee 100644 --- a/src/main/resources/assets/skyblocktweaks/lang/en_us.json +++ b/src/main/resources/assets/skyblocktweaks/lang/en_us.json @@ -321,6 +321,18 @@ "sbt.config.huds.quiver.scale.desc": "The scale of the Quiver HUD", "sbt.config.huds.quiver.icon": "Quiver HUD Icon", "sbt.config.huds.quiver.icon.desc": "Enables the icon in the Quiver HUD", + "sbt.config.huds.armorStack": "Armor Stack HUD", + "sbt.config.huds.armorStack.desc": "Settings for the Armor Stack HUD", + "sbt.config.huds.armorStack.color": "Armor Stack HUD Color", + "sbt.config.huds.armorStack.color.desc": "The color of the Armor Stack HUD", + "sbt.config.huds.armorStack.enabled": "Enable Armor Stack HUD", + "sbt.config.huds.armorStack.enabled.desc": "Enables the Armor Stack HUD", + "sbt.config.huds.armorStack.mode": "Armor Stack HUD Mode", + "sbt.config.huds.armorStack.mode.desc": "The draw mode of the Armor Stack HUD. Pure will render without shadow, Shadow will render with a shadow, and Outline will render with an outline\n§4Warning: §cOutline mode is still a work in progress and can cause annoying visual bugs in menus.", + "sbt.config.huds.armorStack.outlineColor": "Armor Stack HUD Outline Color", + "sbt.config.huds.armorStack.outlineColor.desc": "The outline color of the Armor Stack HUD", + "sbt.config.huds.armorStack.scale": "Armor Stack HUD Scale", + "sbt.config.huds.armorStack.scale.desc": "The scale of the Armor Stack HUD", "sbt.config.globalSearch": "All Options", "sbt.config.globalSearch.desc": "Contains all SBT options in a single searchable category", "sbt.config.globalSearch.open": "Open Global Search",