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) --- .../java/me/xmrvizzy/skyblocker/SkyblockerMod.java | 1 + .../skyblocker/config/SkyblockerConfig.java | 10 ++++ .../skyblocker/skyblock/QuiverWarning.java | 66 ++++++++++++++++++++++ .../resources/assets/skyblocker/lang/en_us.json | 18 ++++-- 4 files changed, 89 insertions(+), 6 deletions(-) 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/SkyblockerMod.java b/src/main/java/me/xmrvizzy/skyblocker/SkyblockerMod.java index f15427c1..4ef19931 100644 --- a/src/main/java/me/xmrvizzy/skyblocker/SkyblockerMod.java +++ b/src/main/java/me/xmrvizzy/skyblocker/SkyblockerMod.java @@ -99,6 +99,7 @@ public class SkyblockerMod implements ClientModInitializer { CustomArmorDyeColors.init(); CustomArmorTrims.init(); TicTacToe.init(); + QuiverWarning.init(); containerSolverManager.init(); statusBarTracker.init(); scheduler.scheduleCyclic(Utils::update, 20); diff --git a/src/main/java/me/xmrvizzy/skyblocker/config/SkyblockerConfig.java b/src/main/java/me/xmrvizzy/skyblocker/config/SkyblockerConfig.java index 3373b71d..5d251f4f 100644 --- a/src/main/java/me/xmrvizzy/skyblocker/config/SkyblockerConfig.java +++ b/src/main/java/me/xmrvizzy/skyblocker/config/SkyblockerConfig.java @@ -174,6 +174,10 @@ public class SkyblockerConfig implements ConfigData { @ConfigEntry.Gui.CollapsibleObject() public Shortcuts shortcuts = new Shortcuts(); + @ConfigEntry.Category("quiverWarning") + @ConfigEntry.Gui.CollapsibleObject() + public QuiverWarning quiverWarning = new QuiverWarning(); + @ConfigEntry.Category("itemList") @ConfigEntry.Gui.CollapsibleObject() public ItemList itemList = new ItemList(); @@ -302,6 +306,12 @@ public class SkyblockerConfig implements ConfigData { public boolean enableCommandArgShortcuts = true; } + public static class QuiverWarning { + public boolean enableQuiverWarning = true; + public boolean enableQuiverWarningInDungeons = true; + public boolean enableQuiverWarningAfterDungeon = true; + } + public static class Hitbox { public boolean oldFarmlandHitbox = true; public boolean oldLeverHitbox = false; 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/resources/assets/skyblocker/lang/en_us.json b/src/main/resources/assets/skyblocker/lang/en_us.json index ec1b73b1..33f6ff9c 100644 --- a/src/main/resources/assets/skyblocker/lang/en_us.json +++ b/src/main/resources/assets/skyblocker/lang/en_us.json @@ -37,8 +37,10 @@ "text.autoconfig.skyblocker.option.general.shortcuts.enableCommandShortcuts.@Tooltip": "Shortcuts for commands consisting of only one word. Edit shortcuts with \"/skyblocker shortcuts\". Shortcuts must be enabled for this to take effect.", "text.autoconfig.skyblocker.option.general.shortcuts.enableCommandArgShortcuts": "Enable Command Argument Shortcuts", "text.autoconfig.skyblocker.option.general.shortcuts.enableCommandArgShortcuts.@Tooltip": "Shortcuts that replace one or more word(s)/argument(s) of a command which has multiple words/arguments. Edit shortcuts with \"/skyblocker shortcuts\". Shortcuts must be enabled for this to take effect.", - "text.autoconfig.skyblocker.option.general.quicknav": "Quicknav", - "text.autoconfig.skyblocker.option.general.quicknav.enableQuicknav": "Enable Quicknav", + "text.autoconfig.skyblocker.option.general.quiverWarning": "Quiver Warning", + "text.autoconfig.skyblocker.option.general.quiverWarning.enableQuiverWarning": "Enable Quiver Warning", + "text.autoconfig.skyblocker.option.general.quiverWarning.enableQuiverWarningInDungeons": "Enable Quiver Warning In Dungeons", + "text.autoconfig.skyblocker.option.general.quiverWarning.enableQuiverWarningAfterDungeon": "Enable Quiver Warning After a Dungeon", "text.autoconfig.skyblocker.option.general.backpackPreviewWithoutShift": "View backpack preview without holding Shift", "text.autoconfig.skyblocker.option.general.tabHud": "Fancy tab HUD", "text.autoconfig.skyblocker.option.general.tabHud.tabHudEnabled": "Enable fancy tab HUD", @@ -322,13 +324,13 @@ "skyblocker.shortcuts.deleteWarning": "Shortcut '%s' will be lost forever! (A long time!)", "skyblocker.shortcuts.new": "New Shortcut", "skyblocker.shortcuts.commandSuggestionTooltip": "Due to limitations of Minecraft, command suggestions will only work after a restart of the game.", - + "skyblocker.customItemNames.removed": "§b[§6Skyblocker§b] §fRemoved this item's custom name.", "skyblocker.customItemNames.neverHad": "§b[§6Skyblocker§b] §fThis item doesn't have a custom name set, but why not add one? ;)", "skyblocker.customItemNames.added": "§b[§6Skyblocker§b] §fSet a custom name for your currently held item!", "skyblocker.customItemNames.noItemUuid": "§b[§6Skyblocker§b] §cYou must be holding an item that has a uuid in order to set a custom name!", "skyblocker.customItemNames.unableToSetName": "§b[§6Skyblocker§b] §cUnable to set a custom item name :( (Are you in skyblock?, are you holding an item?)", - + "skyblocker.customDyeColors.invalidHex": "§b[§6Skyblocker§b] §cInvalid HEX color code!", "skyblocker.customDyeColors.notDyeable": "§b[§6Skyblocker§b] §cThis item isn't a dyeable armor piece!", "skyblocker.customDyeColors.removed": "§b[§6Skyblocker§b] §fRemoved this item's custom dye color.", @@ -336,12 +338,16 @@ "skyblocker.customDyeColors.added": "§b[§6Skyblocker§b] §fSet a custom dye color for your currently held item!", "skyblocker.customDyeColors.noItemUuid": "§b[§6Skyblocker§b] §cYou must be holding an item that has a uuid in order to set a custom dye color!", "skyblocker.customDyeColors.unableToSetColor": "§b[§6Skyblocker§b] §cUnable to set a custom dye color :( (Are you in skyblock?, are you holding an item?)", - + "skyblocker.customArmorTrims.invalidMaterialOrPattern": "§b[§6Skyblocker§b] §cYou supplied either an invalid material, or an invalid trim pattern!", "skyblocker.customArmorTrims.notAnArmorPiece": "§b[§6Skyblocker§b] §cThis item isn't an armor piece!", "skyblocker.customArmorTrims.removed": "§b[§6Skyblocker§b] §fRemoved this item's custom armor trim.", "skyblocker.customArmorTrims.neverHad": "§b[§6Skyblocker§b] §fThis item doesn't have a armor trim set, but why not add one? ;)", "skyblocker.customArmorTrims.added": "§b[§6Skyblocker§b] §fSet a custom armor trim for your currently held item!", "skyblocker.customArmorTrims.noItemUuid": "§b[§6Skyblocker§b] §cYou must be holding an item that has a uuid in order to set a custom armor trim!", - "skyblocker.customArmorTrims.unableToSetTrim": "§b[§6Skyblocker§b] §cUnable to set a custom armor trim :( (Are you in skyblock?, are you holding an item?)" + "skyblocker.customArmorTrims.unableToSetTrim": "§b[§6Skyblocker§b] §cUnable to set a custom armor trim :( (Are you in skyblock?, are you holding an item?)", + + "skyblocker.quiverWarning.50Left": "You only have 50 Arrows left in your Quiver!", + "skyblocker.quiverWarning.10Left": "You only have 10 Arrows left in your Quiver!", + "skyblocker.quiverWarning.empty": "You don't have any more Arrows left in your Quiver!" } -- cgit