aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/de/hysky/skyblocker/skyblock/fancybars/FancyStatusBars.java
diff options
context:
space:
mode:
authorviciscat <51047087+viciscat@users.noreply.github.com>2024-05-12 19:32:13 +0200
committerviciscat <51047087+viciscat@users.noreply.github.com>2024-05-12 19:32:13 +0200
commitc7fb5ee7f3d8baba5e510772abf95eb2c322b688 (patch)
treeb24c18d712e3ce784b9057fd022b8540e75e4514 /src/main/java/de/hysky/skyblocker/skyblock/fancybars/FancyStatusBars.java
parent9714f93a9209b4046c8e3fe7642070cae24be669 (diff)
downloadSkyblocker-c7fb5ee7f3d8baba5e510772abf95eb2c322b688.tar.gz
Skyblocker-c7fb5ee7f3d8baba5e510772abf95eb2c322b688.tar.bz2
Skyblocker-c7fb5ee7f3d8baba5e510772abf95eb2c322b688.zip
make health and exp show if their respective fancy variant are hidden
more mixins here and there :p
Diffstat (limited to 'src/main/java/de/hysky/skyblocker/skyblock/fancybars/FancyStatusBars.java')
-rw-r--r--src/main/java/de/hysky/skyblocker/skyblock/fancybars/FancyStatusBars.java36
1 files changed, 29 insertions, 7 deletions
diff --git a/src/main/java/de/hysky/skyblocker/skyblock/fancybars/FancyStatusBars.java b/src/main/java/de/hysky/skyblocker/skyblock/fancybars/FancyStatusBars.java
index 37376e76..72c1370c 100644
--- a/src/main/java/de/hysky/skyblocker/skyblock/fancybars/FancyStatusBars.java
+++ b/src/main/java/de/hysky/skyblocker/skyblock/fancybars/FancyStatusBars.java
@@ -41,6 +41,16 @@ public class FancyStatusBars {
public static BarPositioner barPositioner = new BarPositioner();
public static Map<String, StatusBar> statusBars = new HashMap<>();
+ public static boolean isHealthFancyBarVisible() {
+ StatusBar health = statusBars.get("health");
+ return health.anchor != null || health.inMouse;
+ }
+
+ public static boolean isExperienceFancyBarVisible() {
+ StatusBar experience = statusBars.get("experience");
+ return experience.anchor != null || experience.inMouse;
+ }
+
public static void init() {
statusBars.put("health", new StatusBar(new Identifier(SkyblockerMod.NAMESPACE, "bars/icons/health"),
new Color[]{new Color(255, 0, 0), new Color(255, 220, 0)},
@@ -177,6 +187,12 @@ public class FancyStatusBars {
ScreenPos anchorPosition = barAnchor.getAnchorPosition(width, height);
BarPositioner.SizeRule sizeRule = barAnchor.getSizeRule();
+ int targetSize = sizeRule.targetSize();
+ boolean visibleHealthMove = barAnchor == BarPositioner.BarAnchor.HOTBAR_TOP && !isHealthFancyBarVisible();
+ if (visibleHealthMove) {
+ targetSize /= 2;
+ }
+
if (sizeRule.isTargetSize()) {
for (int row = 0; row < barPositioner.getRowCount(barAnchor); row++) {
LinkedList<StatusBar> barRow = barPositioner.getRow(barAnchor, row);
@@ -188,13 +204,13 @@ public class FancyStatusBars {
totalSize += (statusBar.size = Math.clamp(statusBar.size, sizeRule.minSize(), sizeRule.maxSize()));
whileLoop:
- while (totalSize != sizeRule.targetSize()) {
- if (totalSize > sizeRule.targetSize()) {
+ while (totalSize != targetSize) {
+ if (totalSize > targetSize) {
for (StatusBar statusBar : barRow) {
if (statusBar.size > sizeRule.minSize()) {
statusBar.size--;
totalSize--;
- if (totalSize == sizeRule.targetSize()) break whileLoop;
+ if (totalSize == targetSize) break whileLoop;
}
}
} else {
@@ -202,7 +218,7 @@ public class FancyStatusBars {
if (statusBar.size < sizeRule.maxSize()) {
statusBar.size++;
totalSize++;
- if (totalSize == sizeRule.targetSize()) break whileLoop;
+ if (totalSize == targetSize) break whileLoop;
}
}
}
@@ -219,10 +235,12 @@ public class FancyStatusBars {
// Update the positions
float widthPerSize;
if (sizeRule.isTargetSize())
- widthPerSize = (float) sizeRule.totalWidth() / sizeRule.targetSize();
+ widthPerSize = (float) sizeRule.totalWidth() / targetSize;
else
widthPerSize = sizeRule.widthPerSize();
+ if (visibleHealthMove) widthPerSize /= 2;
+
int currSize = 0;
int rowSize = barRow.size();
for (int i = 0; i < rowSize; i++) {
@@ -243,7 +261,7 @@ public class FancyStatusBars {
statusBar.size = Math.clamp(statusBar.size, sizeRule.minSize(), sizeRule.maxSize());
float x = barAnchor.isRight() ?
- anchorPosition.x() + currSize * widthPerSize :
+ anchorPosition.x() + (visibleHealthMove ? sizeRule.totalWidth() / 2.f : 0) + currSize * widthPerSize :
anchorPosition.x() - currSize * widthPerSize - statusBar.size * widthPerSize;
statusBar.setX(MathHelper.ceil(x) + offsetX);
@@ -263,9 +281,13 @@ public class FancyStatusBars {
}
}
+ public static boolean isEnabled() {
+ return SkyblockerConfigManager.get().uiAndVisuals.bars.enableBars && !Utils.isInTheRift();
+ }
+
public boolean render(DrawContext context, int scaledWidth, int scaledHeight) {
var player = client.player;
- if (!SkyblockerConfigManager.get().uiAndVisuals.bars.enableBars || player == null || Utils.isInTheRift())
+ if (!isEnabled() || player == null)
return false;
Collection<StatusBar> barCollection = statusBars.values();