diff options
| author | viciscat <51047087+viciscat@users.noreply.github.com> | 2025-06-05 21:20:46 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-06-05 15:20:46 -0400 |
| commit | 197b5f80c2538b253a0ae4384feec6f4e2a545ca (patch) | |
| tree | 2244380c687313505d6f326046b7cf06bd737321 /src/main/java | |
| parent | b3634c3326fff2488d27b5306e46c69937d23e85 (diff) | |
| download | Skyblocker-197b5f80c2538b253a0ae4384feec6f4e2a545ca.tar.gz Skyblocker-197b5f80c2538b253a0ae4384feec6f4e2a545ca.tar.bz2 Skyblocker-197b5f80c2538b253a0ae4384feec6f4e2a545ca.zip | |
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>
Diffstat (limited to 'src/main/java')
| -rw-r--r-- | src/main/java/de/hysky/skyblocker/skyblock/item/slottext/adders/SkillLevelAdder.java | 29 |
1 files changed, 13 insertions, 16 deletions
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<SlotText> 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)); } } } |
