diff --git a/src/main/java/de/hysky/skyblocker/config/configs/UIAndVisualsConfig.java b/src/main/java/de/hysky/skyblocker/config/configs/UIAndVisualsConfig.java
index 7333b1adf2..598cbf5498 100644
--- a/src/main/java/de/hysky/skyblocker/config/configs/UIAndVisualsConfig.java
+++ b/src/main/java/de/hysky/skyblocker/config/configs/UIAndVisualsConfig.java
@@ -160,32 +160,38 @@ public static class Bars {
public boolean enableBars = true;
// Kept in for backwards compatibility, remove if needed
+ @SuppressWarnings("DeprecatedIsStillUsed")
+ @Deprecated
@SerialEntry
- public OldBarPositions barPositions = new OldBarPositions();
+ public LegacyBarPositions barPositions = new LegacyBarPositions();
}
/**
- * Backwards compat
+ * Backwards compat.
+ *
+ * Used to load the legacy bar positions, which will not have an effect once the bars are saved in the new format at {@code /skyblocker/status_bars.json}.
+ * New bars do not need to be added here.
*/
- public static class OldBarPositions {
+ @SuppressWarnings("DeprecatedIsStillUsed")
+ @Deprecated
+ public static class LegacyBarPositions {
@SerialEntry
- public OldBarPosition healthBarPosition = OldBarPosition.LAYER1;
+ public LegacyBarPosition healthBarPosition = LegacyBarPosition.LAYER1;
@SerialEntry
- public OldBarPosition manaBarPosition = OldBarPosition.LAYER1;
+ public LegacyBarPosition manaBarPosition = LegacyBarPosition.LAYER1;
@SerialEntry
- public OldBarPosition defenceBarPosition = OldBarPosition.LAYER1;
+ public LegacyBarPosition defenceBarPosition = LegacyBarPosition.RIGHT;
@SerialEntry
- public OldBarPosition experienceBarPosition = OldBarPosition.LAYER1;
-
+ public LegacyBarPosition experienceBarPosition = LegacyBarPosition.LAYER2;
}
/**
* Backwards compat
*/
- public enum OldBarPosition {
+ public enum LegacyBarPosition {
LAYER1, LAYER2, RIGHT, NONE
}
diff --git a/src/main/java/de/hysky/skyblocker/skyblock/StatusBarTracker.java b/src/main/java/de/hysky/skyblocker/skyblock/StatusBarTracker.java
index 717bd8d6e0..5938f76e1b 100644
--- a/src/main/java/de/hysky/skyblocker/skyblock/StatusBarTracker.java
+++ b/src/main/java/de/hysky/skyblocker/skyblock/StatusBarTracker.java
@@ -1,10 +1,12 @@
package de.hysky.skyblocker.skyblock;
import de.hysky.skyblocker.config.SkyblockerConfigManager;
+import de.hysky.skyblocker.utils.Location;
import de.hysky.skyblocker.utils.Utils;
import net.fabricmc.fabric.api.client.message.v1.ClientReceiveMessageEvents;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.ClientPlayerEntity;
+import net.minecraft.item.ItemStack;
import net.minecraft.text.Text;
import java.util.regex.Matcher;
@@ -18,6 +20,7 @@ public class StatusBarTracker {
private Resource health = new Resource(100, 100, 0);
private Resource mana = new Resource(100, 100, 0);
+ private Resource speed = new Resource(100, 400, 0);
private int defense = 0;
public void init() {
@@ -37,6 +40,11 @@ public int getDefense() {
return this.defense;
}
+ public Resource getSpeed() {
+ updateSpeed();
+ return this.speed;
+ }
+
private int parseInt(Matcher m, int group) {
return Integer.parseInt(m.group(group).replace(",", ""));
}
@@ -48,6 +56,38 @@ private void updateMana(Matcher m) {
this.mana = new Resource(value, max, overflow);
}
+ private void updateSpeed() {
+ // Black cat and racing helm are untested - I don't have the money to test atm, but no reason why they shouldn't work
+ var player = MinecraftClient.getInstance().player;
+ int value = (int) (player.isSprinting() ? (player.getMovementSpeed() / 1.3f) * 1000 : player.getMovementSpeed() * 1000);
+ int max = 400; // hardcoded limit (except for with cactus knife, black cat, snail, racing helm, young drag)
+ if (player.getMainHandStack().getName().getString().contains("Cactus Knife") && Utils.getLocation() == Location.GARDEN) {
+ max = 500;
+ }
+ Iterable armor = player.getArmorItems();
+ int youngDragCount = 0;
+ for (ItemStack armorPiece : armor) {
+ if (armorPiece.getName().getString().contains("Racing Helmet")) {
+ max = 500;
+ } else if (armorPiece.getName().getString().contains("Young Dragon")) {
+ youngDragCount++;
+ }
+ }
+ if (youngDragCount == 4) {
+ max = 500;
+ }
+
+ PetCache.PetInfo pet = PetCache.getCurrentPet();
+ if (pet != null) {
+ if (pet.type().contains("BLACK_CAT")) {
+ max = 500;
+ } else if (pet.type().contains("SNAIL")) {
+ max = 100;
+ }
+ }
+ this.speed = new Resource(value, max, 0);
+ }
+
private void updateHealth(Matcher m) {
int value = parseInt(m, 1);
int max = parseInt(m, 3);
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 f881f19d77..28ae37fb31 100644
--- a/src/main/java/de/hysky/skyblocker/skyblock/fancybars/FancyStatusBars.java
+++ b/src/main/java/de/hysky/skyblocker/skyblock/fancybars/FancyStatusBars.java
@@ -28,8 +28,8 @@
import java.nio.file.Files;
import java.nio.file.NoSuchFileException;
import java.nio.file.Path;
-import java.util.*;
import java.util.List;
+import java.util.*;
import java.util.concurrent.CompletableFuture;
public class FancyStatusBars {
@@ -66,18 +66,24 @@ public static void init() {
statusBars.put("experience", new StatusBar(Identifier.of(SkyblockerMod.NAMESPACE, "bars/icons/experience"),
new Color[]{new Color(100, 230, 70)},
false, new Color(128, 255, 32), Text.translatable("skyblocker.bars.config.experience")));
+ statusBars.put("speed", new StatusBar(Identifier.of(SkyblockerMod.NAMESPACE, "bars/icons/speed"),
+ new Color[]{new Color(255, 255, 255)},
+ false, new Color(185, 185, 185), Text.translatable("skyblocker.bars.config.speed")));
// Fetch from old status bar config
int[] counts = new int[3]; // counts for RIGHT, LAYER1, LAYER2
StatusBar health = statusBars.get("health");
- UIAndVisualsConfig.OldBarPositions barPositions = SkyblockerConfigManager.get().uiAndVisuals.bars.barPositions;
- loadOldBarPosition(health, counts, barPositions.healthBarPosition);
+ @SuppressWarnings("deprecation")
+ UIAndVisualsConfig.LegacyBarPositions barPositions = SkyblockerConfigManager.get().uiAndVisuals.bars.barPositions;
+ initBarPosition(health, counts, barPositions.healthBarPosition);
StatusBar intelligence = statusBars.get("intelligence");
- loadOldBarPosition(intelligence, counts, barPositions.manaBarPosition);
+ initBarPosition(intelligence, counts, barPositions.manaBarPosition);
StatusBar defense = statusBars.get("defense");
- loadOldBarPosition(defense, counts, barPositions.defenceBarPosition);
+ initBarPosition(defense, counts, barPositions.defenceBarPosition);
StatusBar experience = statusBars.get("experience");
- loadOldBarPosition(experience, counts, barPositions.experienceBarPosition);
+ initBarPosition(experience, counts, barPositions.experienceBarPosition);
+ StatusBar speed = statusBars.get("speed");
+ initBarPosition(speed, counts, UIAndVisualsConfig.LegacyBarPosition.RIGHT);
CompletableFuture.supplyAsync(FancyStatusBars::loadBarConfig).thenAccept(object -> {
if (object != null) {
@@ -110,12 +116,12 @@ public static void init() {
}
/**
- * Loads the bar position from the old config
+ * Loads the bar position from the old config. Should be used to initialize new bars too.
* @param bar the bar to load the position for
* @param counts the counts for each bar position (LAYER1, LAYER2, RIGHT)
* @param position the position to load
*/
- private static void loadOldBarPosition(StatusBar bar, int[] counts, UIAndVisualsConfig.OldBarPosition position) {
+ private static void initBarPosition(StatusBar bar, int[] counts, UIAndVisualsConfig.LegacyBarPosition position) {
switch (position) {
case RIGHT:
bar.anchor = BarPositioner.BarAnchor.HOTBAR_RIGHT;
@@ -306,6 +312,8 @@ public boolean render(DrawContext context, int scaledWidth, int scaledHeight) {
statusBars.get("intelligence").updateValues(intelligence.value() / (float) intelligence.max(), intelligence.overflow() / (float) intelligence.max(), intelligence.value());
int defense = statusBarTracker.getDefense();
statusBars.get("defense").updateValues(defense / (defense + 100.f), 0, defense);
+ StatusBarTracker.Resource speed = statusBarTracker.getSpeed();
+ statusBars.get("speed").updateValues(speed.value() / (float) speed.max(), 0, speed.value());
statusBars.get("experience").updateValues(player.experienceProgress, 0, player.experienceLevel);
return true;
}
diff --git a/src/main/resources/assets/skyblocker/lang/en_us.json b/src/main/resources/assets/skyblocker/lang/en_us.json
index c622366378..6e59ee2cdb 100644
--- a/src/main/resources/assets/skyblocker/lang/en_us.json
+++ b/src/main/resources/assets/skyblocker/lang/en_us.json
@@ -696,7 +696,7 @@
"skyblocker.config.uiAndVisuals.hideStatusEffectOverlay": "Hide Status Effect Overlay",
- "skyblocker.config.uiAndVisuals.bars": "Health, Mana, Defence & XP Bars",
+ "skyblocker.config.uiAndVisuals.bars": "Health, Mana, Defence, Speed & XP Bars",
"skyblocker.config.uiAndVisuals.bars.enableBars": "Enable Bars",
"skyblocker.config.uiAndVisuals.chestValue": "Chest Value",
@@ -815,6 +815,7 @@
"skyblocker.bars.config.defense": "Defense",
"skyblocker.bars.config.intelligence": "Intelligence",
"skyblocker.bars.config.experience": "Experience",
+ "skyblocker.bars.config.speed": "Speed",
"skyblocker.bars.config.mainColor": "Main Color",
"skyblocker.bars.config.overflowColor": "Overflow Color",
"skyblocker.bars.config.textColor": "Text Color",
@@ -1024,7 +1025,7 @@
"skyblocker.tips.eventNotifications": "Check out the customizable event notifications in the config.",
"skyblocker.tips.signCalculator": "Type an math expression in a sign to have the mod calculate it for you.",
"skyblocker.tips.calculateCommand": "Enter an expression after /skyblocker calculate to have the mod calculate it for you.",
- "skyblocker.tips.fancierBars": "Customize the look of your health, mana, defense, and experience bars with /skyblocker bars. You can snap and resize bars too!",
+ "skyblocker.tips.fancierBars": "Customize the look of your health, mana, defense, speed, and experience bars with /skyblocker bars. You can snap and resize bars too!",
"skyblocker.tips.crystalWaypointsShare": "Share Crystal Hollows Waypoints with /skyblocker crystalWaypoints share.",
"skyblocker.tips.gardenMouseLock": "Lock your mouse while farming in the Skyblocker Garden config.",
"skyblocker.tips.newYearCakesHelper": "Open your New Year Cake Bag and Skyblocker will remember them and highlight duplicate cakes red and missing cakes green.",
diff --git a/src/main/resources/assets/skyblocker/textures/gui/sprites/bars/icons/speed.png b/src/main/resources/assets/skyblocker/textures/gui/sprites/bars/icons/speed.png
new file mode 100644
index 0000000000..0a110a12bb
Binary files /dev/null and b/src/main/resources/assets/skyblocker/textures/gui/sprites/bars/icons/speed.png differ