Skip to content

Commit

Permalink
Armor stack HUD
Browse files Browse the repository at this point in the history
  • Loading branch information
MisterCheezeCake committed Nov 17, 2024
1 parent c7e7885 commit 1701ecd
Show file tree
Hide file tree
Showing 7 changed files with 199 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/main/java/wtf/cheeze/sbt/SkyblockTweaks.java
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
4 changes: 4 additions & 0 deletions src/main/java/wtf/cheeze/sbt/config/categories/Huds.java
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand All @@ -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();
}
}
169 changes: 169 additions & 0 deletions src/main/java/wtf/cheeze/sbt/features/huds/ArmorStackHUD.java
Original file line number Diff line number Diff line change
@@ -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 <https://www.gnu.org/licenses/>.
*/
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.<Boolean>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.<Color>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.<Color>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.<DrawMode>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.<Float>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();
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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.<Boolean>createBuilder()
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/wtf/cheeze/sbt/utils/skyblock/SkyblockData.java
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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) {
Expand Down
12 changes: 12 additions & 0 deletions src/main/resources/assets/skyblocktweaks/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 1701ecd

Please sign in to comment.