From 5d34c99a38af9011559260bb1e211468c41edbc6 Mon Sep 17 00:00:00 2001 From: Aaron <51387595+AzureAaron@users.noreply.github.com> Date: Thu, 31 Aug 2023 22:53:27 -0400 Subject: Attribute Shard Info Display (#263) --- .../skyblocker/skyblock/item/AttributeShards.java | 59 ++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 src/main/java/me/xmrvizzy/skyblocker/skyblock/item/AttributeShards.java (limited to 'src/main/java/me/xmrvizzy/skyblocker/skyblock') 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 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, ""); + } +} -- cgit From 232b0b472a7e473d1fee6b8798d21fd1bb920260 Mon Sep 17 00:00:00 2001 From: msg-programs Date: Fri, 1 Sep 2023 11:06:14 +0200 Subject: Fix minion widget displaying wrong info when player has 11/12 minions --- .../skyblock/tabhud/widget/MinionWidget.java | 59 ++++++++++++++-------- 1 file changed, 37 insertions(+), 22 deletions(-) (limited to 'src/main/java/me/xmrvizzy/skyblocker/skyblock') 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; } } -- cgit From 225644de8bf2a15c7a0970d84c548189d5a15ec4 Mon Sep 17 00:00:00 2001 From: Kevin <92656833+kevinthegreat1@users.noreply.github.com> Date: Sat, 2 Sep 2023 00:30:56 -0400 Subject: Add Quiver Warning (#270) --- .../skyblocker/skyblock/QuiverWarning.java | 66 ++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 src/main/java/me/xmrvizzy/skyblocker/skyblock/QuiverWarning.java (limited to 'src/main/java/me/xmrvizzy/skyblocker/skyblock') 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; + } + } +} -- cgit