From 197b5f80c2538b253a0ae4384feec6f4e2a545ca Mon Sep 17 00:00:00 2001 From: viciscat <51047087+viciscat@users.noreply.github.com> Date: Thu, 5 Jun 2025 21:20:46 +0200 Subject: un-hardcode slot ids in SkillLevelAdder (#1305) * un-hardcode slot ids in SkillLevelAdder * Exclude dungeoneering --------- Co-authored-by: Aaron <51387595+AzureAaron@users.noreply.github.com> --- .../item/slottext/adders/SkillLevelAdder.java | 29 ++++++++++------------ 1 file changed, 13 insertions(+), 16 deletions(-) (limited to 'src/main/java/de') diff --git a/src/main/java/de/hysky/skyblocker/skyblock/item/slottext/adders/SkillLevelAdder.java b/src/main/java/de/hysky/skyblocker/skyblock/item/slottext/adders/SkillLevelAdder.java index 2640fb73..54a80cca 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/item/slottext/adders/SkillLevelAdder.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/item/slottext/adders/SkillLevelAdder.java @@ -6,6 +6,7 @@ import de.hysky.skyblocker.utils.ItemUtils; import de.hysky.skyblocker.utils.RomanNumerals; import de.hysky.skyblocker.utils.Utils; import net.minecraft.item.ItemStack; +import net.minecraft.item.Items; import net.minecraft.screen.slot.Slot; import net.minecraft.text.Text; import net.minecraft.util.Formatting; @@ -24,22 +25,18 @@ public class SkillLevelAdder extends SimpleSlotTextAdder { @Override public @NotNull List getText(@Nullable Slot slot, @NotNull ItemStack stack, int slotId) { - switch (slotId) { - case 19, 20, 21, 22, 23, 24, 25, 29, 30, 31, 32 -> { //These are the slots that contain the skill items. Note that they aren't continuous, as there are 2 rows. - String name = stack.getName().getString(); - int lastIndex = name.lastIndexOf(' '); - if (lastIndex == -1) return SlotText.bottomLeftList(Text.literal("0").formatted(Formatting.LIGHT_PURPLE)); //Skills without any levels don't display any roman numerals. Probably because 0 doesn't exist. - String romanNumeral = name.substring(lastIndex + 1); //+1 because we don't need the space itself - //The "romanNumeral" might be a latin numeral, too. There's a skyblock setting for this, so we have to do it this way V - if (ItemUtils.getLoreLineIf(stack, s -> s.contains("Max Skill level reached!")) != null) { - return SlotText.bottomLeftList(Text.literal(String.valueOf(RomanNumerals.isValidRomanNumeral(romanNumeral) ? RomanNumerals.romanToDecimal(romanNumeral) : Utils.parseInt(romanNumeral).orElse(0))).withColor(SlotText.GOLD)); - } else { - return SlotText.bottomLeftList(Text.literal(String.valueOf(RomanNumerals.isValidRomanNumeral(romanNumeral) ? RomanNumerals.romanToDecimal(romanNumeral) : Utils.parseInt(romanNumeral).orElse(0))).withColor(SlotText.CREAM)); - } - } - default -> { - return List.of(); - } + if (slotId / 9 < 1 || slotId / 9 > 4) return List.of(); + if (stack.getItem() == Items.BLACK_STAINED_GLASS_PANE) return List.of(); + String name = stack.getName().getString(); + if (name.equals("Dungeoneering")) return List.of(); //This is a button to open the dungeon skill menu + int lastIndex = name.lastIndexOf(' '); + if (lastIndex == -1) return SlotText.bottomLeftList(Text.literal("0").formatted(Formatting.LIGHT_PURPLE)); + String romanNumeral = name.substring(lastIndex + 1); //+1 because we don't need the space itself + //The "romanNumeral" might be a latin numeral, too. There's a skyblock setting for this, so we have to do it this way V + if (ItemUtils.getLoreLineIf(stack, s -> s.contains("Max Skill level reached!")) != null) { + return SlotText.bottomLeftList(Text.literal(String.valueOf(RomanNumerals.isValidRomanNumeral(romanNumeral) ? RomanNumerals.romanToDecimal(romanNumeral) : Utils.parseInt(romanNumeral).orElse(0))).withColor(SlotText.GOLD)); + } else { + return SlotText.bottomLeftList(Text.literal(String.valueOf(RomanNumerals.isValidRomanNumeral(romanNumeral) ? RomanNumerals.romanToDecimal(romanNumeral) : Utils.parseInt(romanNumeral).orElse(0))).withColor(SlotText.CREAM)); } } } -- cgit