aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me/xmrvizzy/skyblocker/skyblock
diff options
context:
space:
mode:
authorKevinthegreat <92656833+kevinthegreat1@users.noreply.github.com>2023-09-03 16:21:12 -0400
committerKevinthegreat <92656833+kevinthegreat1@users.noreply.github.com>2023-09-03 16:21:12 -0400
commit210891749f4a15c948a6c9e889dae1898807e951 (patch)
tree064e8d49a0c8ed882ad7845d16fd44af60bdd0e4 /src/main/java/me/xmrvizzy/skyblocker/skyblock
parentaa2abcf644bf58adb3330e87d870ce56a09ce3f5 (diff)
parent6e5a77698ebfd189daa46f45523d8286450999ae (diff)
downloadSkyblocker-210891749f4a15c948a6c9e889dae1898807e951.tar.gz
Skyblocker-210891749f4a15c948a6c9e889dae1898807e951.tar.bz2
Skyblocker-210891749f4a15c948a6c9e889dae1898807e951.zip
Merge branch 'master' into utils-cleanup
Diffstat (limited to 'src/main/java/me/xmrvizzy/skyblocker/skyblock')
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/skyblock/QuiverWarning.java66
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/skyblock/item/AttributeShards.java59
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/MinionWidget.java59
3 files changed, 162 insertions, 22 deletions
diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/QuiverWarning.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/QuiverWarning.java
new file mode 100644
index 00000000..cf793461
--- /dev/null
+++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/QuiverWarning.java
@@ -0,0 +1,66 @@
+package me.xmrvizzy.skyblocker.skyblock;
+
+import me.xmrvizzy.skyblocker.SkyblockerMod;
+import me.xmrvizzy.skyblocker.config.SkyblockerConfig;
+import me.xmrvizzy.skyblocker.utils.Utils;
+import net.fabricmc.fabric.api.client.message.v1.ClientReceiveMessageEvents;
+import net.minecraft.client.MinecraftClient;
+import net.minecraft.client.gui.hud.InGameHud;
+import net.minecraft.text.Text;
+import net.minecraft.util.Formatting;
+import org.jetbrains.annotations.Nullable;
+
+public class QuiverWarning {
+ @Nullable
+ private static Type warning = null;
+
+ public static void init() {
+ ClientReceiveMessageEvents.ALLOW_GAME.register(QuiverWarning::onChatMessage);
+ SkyblockerMod.getInstance().scheduler.scheduleCyclic(QuiverWarning::update, 10);
+ }
+
+ public static boolean onChatMessage(Text text, boolean overlay) {
+ String message = text.getString();
+ if (SkyblockerConfig.get().general.quiverWarning.enableQuiverWarning && message.endsWith("left in your Quiver!")) {
+ MinecraftClient.getInstance().inGameHud.setDefaultTitleFade();
+ if (message.startsWith("You only have 50")) {
+ onChatMessage(Type.FIFTY_LEFT);
+ } else if (message.startsWith("You only have 10")) {
+ onChatMessage(Type.TEN_LEFT);
+ } else if (message.startsWith("You don't have any more")) {
+ onChatMessage(Type.EMPTY);
+ }
+ }
+ return true;
+ }
+
+ private static void onChatMessage(Type warning) {
+ if (!Utils.isInDungeons()) {
+ MinecraftClient.getInstance().inGameHud.setTitle(Text.translatable(warning.key).formatted(Formatting.RED));
+ } else if (SkyblockerConfig.get().general.quiverWarning.enableQuiverWarningInDungeons) {
+ MinecraftClient.getInstance().inGameHud.setTitle(Text.translatable(warning.key).formatted(Formatting.RED));
+ QuiverWarning.warning = warning;
+ }
+ }
+
+ public static void update() {
+ if (warning != null && SkyblockerConfig.get().general.quiverWarning.enableQuiverWarning && SkyblockerConfig.get().general.quiverWarning.enableQuiverWarningAfterDungeon && !Utils.isInDungeons()) {
+ InGameHud inGameHud = MinecraftClient.getInstance().inGameHud;
+ inGameHud.setDefaultTitleFade();
+ inGameHud.setTitle(Text.translatable(warning.key).formatted(Formatting.RED));
+ warning = null;
+ }
+ }
+
+ private enum Type {
+ NONE(""),
+ FIFTY_LEFT("50Left"),
+ TEN_LEFT("10Left"),
+ EMPTY("empty");
+ private final String key;
+
+ Type(String key) {
+ this.key = "skyblocker.quiverWarning." + key;
+ }
+ }
+}
diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/item/AttributeShards.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/item/AttributeShards.java
new file mode 100644
index 00000000..0f106cdf
--- /dev/null
+++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/item/AttributeShards.java
@@ -0,0 +1,59 @@
+package me.xmrvizzy.skyblocker.skyblock.item;
+
+import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
+
+public class AttributeShards {
+ private static final Object2ObjectOpenHashMap<String, String> ID_2_SHORT_NAME = new Object2ObjectOpenHashMap<>();
+
+ static {
+ //Weapons
+ ID_2_SHORT_NAME.put("arachno", "A");
+ ID_2_SHORT_NAME.put("attack_speed", "AS");
+ ID_2_SHORT_NAME.put("blazing", "BL");
+ ID_2_SHORT_NAME.put("combo", "C");
+ ID_2_SHORT_NAME.put("elite", "E");
+ ID_2_SHORT_NAME.put("ender", "EN");
+ ID_2_SHORT_NAME.put("ignition", "I");
+ ID_2_SHORT_NAME.put("life_recovery", "LR");
+ ID_2_SHORT_NAME.put("mana_steal", "MS");
+ ID_2_SHORT_NAME.put("midas_touch", "MT");
+ ID_2_SHORT_NAME.put("undead", "U");
+
+ //Swords & Bows
+ ID_2_SHORT_NAME.put("warrior", "W");
+ ID_2_SHORT_NAME.put("deadeye", "DE");
+
+ //Armor or Equipment
+ ID_2_SHORT_NAME.put("arachno_resistance", "AR");
+ ID_2_SHORT_NAME.put("blazing_resistance", "BR");
+ ID_2_SHORT_NAME.put("breeze", "B");
+ ID_2_SHORT_NAME.put("dominance", "D");
+ ID_2_SHORT_NAME.put("ender_resistance", "ER");
+ ID_2_SHORT_NAME.put("experience", "XP");
+ ID_2_SHORT_NAME.put("fortitude", "F");
+ ID_2_SHORT_NAME.put("life_regeneration", "HR"); //Health regeneration
+ ID_2_SHORT_NAME.put("lifeline", "L");
+ ID_2_SHORT_NAME.put("magic_find", "MF");
+ ID_2_SHORT_NAME.put("mana_pool", "MP");
+ ID_2_SHORT_NAME.put("mana_regeneration", "MR");
+ ID_2_SHORT_NAME.put("mending", "V"); //Vitality
+ ID_2_SHORT_NAME.put("speed", "S");
+ ID_2_SHORT_NAME.put("undead_resistance", "UR");
+ ID_2_SHORT_NAME.put("veteran", "V");
+
+ //Fishing Gear
+ ID_2_SHORT_NAME.put("blazing_fortune", "BF");
+ ID_2_SHORT_NAME.put("fishing_experience", "FE");
+ ID_2_SHORT_NAME.put("infection", "IF");
+ ID_2_SHORT_NAME.put("double_hook", "DH");
+ ID_2_SHORT_NAME.put("fisherman", "FM");
+ ID_2_SHORT_NAME.put("fishing_speed", "FS");
+ ID_2_SHORT_NAME.put("hunter", "H");
+ ID_2_SHORT_NAME.put("trophy_hunter", "TH");
+
+ }
+
+ public static String getShortName(String id) {
+ return ID_2_SHORT_NAME.getOrDefault(id, "");
+ }
+}
diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/MinionWidget.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/MinionWidget.java
index 039871b2..579828d4 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/MinionWidget.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/MinionWidget.java
@@ -97,29 +97,13 @@ public class MinionWidget extends Widget {
@Override
public void updateContent() {
- for (int i = 48; i < 59; i++) {
- Matcher m = PlayerListMgr.regexAt(i, MINION_PATTERN);
- if (m != null) {
-
- String min = m.group("name");
- String lvl = m.group("level");
- String stat = m.group("status");
-
- MutableText mt = Text.literal(min + " " + lvl).append(Text.literal(": "));
- Formatting format = Formatting.RED;
- if (stat.equals("ACTIVE")) {
- format = Formatting.GREEN;
- } else if (stat.equals("SLOW")) {
- format = Formatting.YELLOW;
- }
- // makes "BLOCKED" also red. in reality, it's some kind of crimson
- mt.append(Text.literal(stat).formatted(format));
+ // this looks a bit weird because if we used regex mismatch as a stop condition,
+ // it'd spam the chat.
+ // not sure if not having that debug output is worth the cleaner solution here...
- IcoTextComponent itc = new IcoTextComponent(MIN_ICOS.get(min), mt);
- this.addComponent(itc);
-
- } else {
+ for (int i = 48; i < 59; i++) {
+ if (!this.addMinionComponent(i)) {
break;
}
}
@@ -128,8 +112,39 @@ public class MinionWidget extends Widget {
// a "And X more..." text is shown
// look for that and add it to the widget
String more = PlayerListMgr.strAt(59);
- if (more != null) {
+ if (more == null) {
+ return;
+ } else if (more.startsWith("And ")) {
this.addComponent(new PlainTextComponent(Text.of(more)));
+ } else {
+ this.addMinionComponent(59);
+ }
+ }
+
+ public boolean addMinionComponent(int i) {
+ Matcher m = PlayerListMgr.regexAt(i, MINION_PATTERN);
+ if (m != null) {
+
+ String min = m.group("name");
+ String lvl = m.group("level");
+ String stat = m.group("status");
+
+ MutableText mt = Text.literal(min + " " + lvl).append(Text.literal(": "));
+
+ Formatting format = Formatting.RED;
+ if (stat.equals("ACTIVE")) {
+ format = Formatting.GREEN;
+ } else if (stat.equals("SLOW")) {
+ format = Formatting.YELLOW;
+ }
+ // makes "BLOCKED" also red. in reality, it's some kind of crimson
+ mt.append(Text.literal(stat).formatted(format));
+
+ IcoTextComponent itc = new IcoTextComponent(MIN_ICOS.get(min), mt);
+ this.addComponent(itc);
+ return true;
+ } else {
+ return false;
}
}