Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slot Text Stuff #1134

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ private static boolean allowInput(MinecraftClient client, HandledScreen<?> handl
public @NotNull List<SlotText> getText(@Nullable Slot slot, @NotNull ItemStack stack, int slotId) {
if (!stack.isOf(Items.PINK_DYE) && !stack.isOf(Items.LIME_DYE)) return List.of();
if (!(slotId >= 36 && slotId <= 44)) return List.of();
return SlotText.bottomLeftList(Text.literal(String.valueOf(slotId - 35)).withColor(0x74c7ec));
return SlotText.bottomLeftList(Text.literal(String.valueOf(slotId - 35)).withColor(SlotText.MID_BLUE));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,20 @@
import java.util.List;

public record SlotText(@NotNull Text text, @NotNull TextPosition position) {
/**
* The "default" slot text color.
*/
public static final int CREAM = 0xFFDDC1;
public static final int GOLD = 0xE5B80B;
public static final int LIGHT_BLUE = 0xCFF8F8;
public static final int LIGHT_ORANGE = 0xfab387;
public static final int LIGHT_YELLOW = 0xf9e2af;
public static final int LIGHT_PURPLE = 0xcba6f7;
public static final int LIGHT_RED = 0xFF7276;
public static final int LIGHT_GREEN = 0x90ee90;
public static final int MID_BLUE = 0x74c7ec;
public static final int WHITE = 0xFFFFFF;
AzureAaron marked this conversation as resolved.
Show resolved Hide resolved

public static SlotText bottomLeft(@NotNull Text text) {
return new SlotText(text, TextPosition.BOTTOM_LEFT);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public class SlotTextManager {
new MinionLevelAdder(),
new PetLevelAdder(),
new SkyblockLevelAdder(),
new HotmPerkLevelAdder(),
new SkillLevelAdder(),
new CatacombsLevelAdder.Dungeoneering(),
new CatacombsLevelAdder.DungeonClasses(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ public AttributeShardAdder() {
String attributeInitials = ID_2_SHORT_NAME.getOrDefault(attributeId, "");

return List.of(
SlotText.bottomRight(Text.literal(String.valueOf(attributeLevel)).withColor(0xFFDDC1)),
SlotText.topLeft(Text.literal(attributeInitials).withColor(0xCFF8F8))
SlotText.bottomRight(Text.literal(String.valueOf(attributeLevel)).withColor(SlotText.CREAM)),
SlotText.topLeft(Text.literal(attributeInitials).withColor(SlotText.LIGHT_BLUE))
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public Dungeoneering() {
level = String.valueOf(RomanNumerals.romanToDecimal(roman));
}

return SlotText.bottomLeftList(Text.literal(level).withColor(0xFFDDC1));
return SlotText.bottomLeftList(Text.literal(level).withColor(SlotText.CREAM));
}
default -> {
return List.of();
Expand All @@ -72,7 +72,7 @@ public DungeonClasses() {
case 11, 12, 13, 14, 15 -> {
String level = getBracketedLevelFromName(stack);
if (!NumberUtils.isDigits(level)) return List.of();
return SlotText.bottomLeftList(Text.literal(level).withColor(0xFFDDC1));
return SlotText.bottomLeftList(Text.literal(level).withColor(SlotText.CREAM));
}
default -> {
return List.of();
Expand All @@ -93,7 +93,7 @@ public ReadyUp() {
case 29, 30, 31, 32, 33 -> {
String level = getBracketedLevelFromName(stack);
if (!NumberUtils.isDigits(level)) return List.of();
return SlotText.bottomLeftList(Text.literal(level).withColor(0xFFDDC1));
return SlotText.bottomLeftList(Text.literal(level).withColor(SlotText.CREAM));
}
default -> {
return List.of();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ public CollectionAdder() {
if (matcher.matches()) {
int level = RomanNumerals.romanToDecimal(matcher.group("level"));
if (ItemUtils.getLoreLineIf(stack, s -> s.contains("Progress to ")) != null) {
return SlotText.bottomRightList(Text.literal(String.valueOf(level)).withColor(0xFFDDC1));
return SlotText.bottomRightList(Text.literal(String.valueOf(level)).withColor(SlotText.CREAM));
} else {
return SlotText.bottomRightList(Text.literal(String.valueOf(level)).withColor(0xE5B80B));
return SlotText.bottomRightList(Text.literal(String.valueOf(level)).withColor(SlotText.GOLD));
}
}
return List.of();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ private static List<SlotText> getTextForUpgradesScreen(ItemStack stack, int slot
if (lore.isEmpty()) yield List.of();
String lastLine = lore.getLast().getString();
yield SlotText.bottomLeftList(switch (lastLine) {
case "Maxed out!" -> Text.literal("Max").withColor(0xfab387);
case "Currently upgrading!", "Click to instantly upgrade!" -> Text.literal("⏰").withColor(0xf9e2af).formatted(Formatting.BOLD);
case "Maxed out!" -> Text.literal("Max").withColor(SlotText.LIGHT_ORANGE);
case "Currently upgrading!", "Click to instantly upgrade!" -> Text.literal("⏰").withColor(SlotText.LIGHT_YELLOW).formatted(Formatting.BOLD);
case "Click to claim!" -> Text.literal("✅").withColor(0xa6e3a1).formatted(Formatting.BOLD);
default -> Text.literal(String.valueOf(RomanNumerals.romanToDecimal(roman))).withColor(0xcba6f7);
default -> Text.literal(String.valueOf(RomanNumerals.romanToDecimal(roman))).withColor(SlotText.LIGHT_PURPLE);
});
}
default -> List.of();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ public EnchantmentLevelAdder() {
NbtCompound enchantments = nbt.getCompound("enchantments");
if (enchantments.getSize() != 1) return List.of(); //Only makes sense to display the level when there's one enchant.
int level = enchantments.getInt(enchantments.getKeys().iterator().next());
return SlotText.bottomLeftList(Text.literal(String.valueOf(level)).withColor(0xFFDDC1));
return SlotText.bottomLeftList(Text.literal(String.valueOf(level)).withColor(SlotText.CREAM));
} else { //In bazaar, the books have the enchantment level in the name
int level = getEnchantLevelFromString(name);
if (level == 0) return List.of();
return SlotText.bottomLeftList(Text.literal(String.valueOf(level)).withColor(0xFFDDC1));
return SlotText.bottomLeftList(Text.literal(String.valueOf(level)).withColor(SlotText.CREAM));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ public EssenceShopAdder() {
if (unlockedMatcher == null) {
level -= 1;
}
return SlotText.bottomRightList(Text.literal(String.valueOf(level)).withColor(0xFFDDC1));
return SlotText.bottomRightList(Text.literal(String.valueOf(level)).withColor(SlotText.CREAM));
}
if (essenceAmountMatcher == null) return List.of();
String essenceAmount = essenceAmountMatcher.group("essence").replace(",", "");
if (!essenceAmount.matches("-?\\d+")) return List.of();

return SlotText.bottomRightList(Text.literal(YourEssenceAdder.COMPACT_NUMBER_FORMATTER.format(Integer.parseInt(essenceAmount))).withColor(0xFFDDC1));
return SlotText.bottomRightList(Text.literal(YourEssenceAdder.COMPACT_NUMBER_FORMATTER.format(Integer.parseInt(essenceAmount))).withColor(SlotText.CREAM));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public EvolvingItemAdder() {
@Override
public @NotNull List<SlotText> getText(@Nullable Slot slot, @NotNull ItemStack stack, int slotId) {
switch (stack.getSkyblockId()) {
case "NEW_BOTTLE_OF_JYRRE", "DARK_CACAO_TRUFFLE" -> {
case "NEW_BOTTLE_OF_JYRRE", "DARK_CACAO_TRUFFLE", "DISCRITE" -> {
return actualLogic(stack, "Current Bonus: ");
}
case "TRAINING_WEIGHTS" -> {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package de.hysky.skyblocker.skyblock.item.slottext.adders;

import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import de.hysky.skyblocker.skyblock.item.slottext.SimpleSlotTextAdder;
import de.hysky.skyblocker.skyblock.item.slottext.SlotText;
import de.hysky.skyblocker.utils.ItemUtils;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.screen.slot.Slot;
import net.minecraft.text.Text;

public class HotmPerkLevelAdder extends SimpleSlotTextAdder {
private static final ConfigInformation CONFIG_INFORMATION = new ConfigInformation(
"hotm_perk_level",
"skyblocker.config.uiAndVisuals.slotText.hotmPerkLevel");
private static final Pattern LEVEL = Pattern.compile("Level (?<level>\\d+)\\/(?<max>\\d+)");
Copy link
Collaborator

@Emirlol Emirlol Jan 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/ doesn't need to be escaped

Suggested change
private static final Pattern LEVEL = Pattern.compile("Level (?<level>\\d+)\\/(?<max>\\d+)");
private static final Pattern LEVEL = Pattern.compile("Level (?<level>\\d+)/(?<max>\\d+)");

Also, this doesn't match maxed hotm perks. This doesn't seem intentional given that you handled the case where level == max for a different color.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no idea what the text shows for that, it was a best effort guess


public HotmPerkLevelAdder() {
super("^Heart of the Mountain$", CONFIG_INFORMATION);
}

@Override
@NotNull
public List<SlotText> getText(@Nullable Slot slot, @NotNull ItemStack stack, int slotId) {
if (slotId >= 0 && slotId <= 53 && !stack.isOf(Items.COAL)) {
AzureAaron marked this conversation as resolved.
Show resolved Hide resolved
List<Text> lore = ItemUtils.getLore(stack);

if (!lore.isEmpty()) {
String levelLine = lore.getFirst().getString();
Matcher matcher = LEVEL.matcher(levelLine);

if (matcher.matches()) {
int level = Integer.parseInt(matcher.group("level"));
int max = Integer.parseInt(matcher.group("max"));

return SlotText.bottomRightList(Text.literal(String.valueOf(level)).withColor(level == max ? SlotText.GOLD : SlotText.CREAM));
}
}
}

return List.of();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ public MinionLevelAdder() {
String romanNumeral = matcher.group(1);
if (!RomanNumerals.isValidRomanNumeral(romanNumeral)) return List.of();
int level = RomanNumerals.romanToDecimal(romanNumeral);
return SlotText.topRightList(Text.literal(String.valueOf(level)).withColor(0xFFDDC1));
return SlotText.topRightList(Text.literal(String.valueOf(level)).withColor(SlotText.CREAM));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ public class NewYearCakeAdder extends SimpleSlotTextAdder {
if (!stack.isOf(Items.CAKE)) return List.of();
int year = ItemUtils.getCustomData(stack).getInt("new_years_cake");
if (year <= 0) return List.of();
return SlotText.bottomLeftList(Text.literal(String.valueOf(year)).withColor(0x74c7ec));
return SlotText.bottomLeftList(Text.literal(String.valueOf(year)).withColor(SlotText.MID_BLUE));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ public PetLevelAdder() {
if (!matcher.matches()) return List.of();
String level = matcher.group(1);
if (!NumberUtils.isDigits(level) || "100".equals(level) || "200".equals(level)) return List.of();
return SlotText.topLeftList(Text.literal(level).withColor(0xFFDDC1));
return SlotText.topLeftList(Text.literal(level).withColor(SlotText.CREAM));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ public PotionLevelAdder() {
if (customData.contains("potion_level", NbtElement.INT_TYPE) && !title.contains("Healer Class") && !title.contains("Class Passives")) {
if (title.contains("Healer Level ")){
String level = title.replaceAll("\\D", "");
return SlotText.bottomRightList(Text.literal(level).withColor(0xFFFFFF));
return SlotText.bottomRightList(Text.literal(level).withColor(SlotText.WHITE));
} else {
int level = customData.getInt("potion_level");
return SlotText.bottomRightList(Text.literal(String.valueOf(level)).withColor(0xFFDDC1));
return SlotText.bottomRightList(Text.literal(String.valueOf(level)).withColor(SlotText.CREAM));
}
}
return List.of();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public PowerStonesGuideAdder() {
if (match == null) return List.of();
String symbol = match.group("symbol");
Text text = symbol.equals("✖")
? Text.literal("✖").withColor(0xFF7276)
: Text.literal("✔").withColor(0x90ee90);
? Text.literal("✖").withColor(SlotText.LIGHT_RED)
: Text.literal("✔").withColor(SlotText.LIGHT_GREEN);

return SlotText.bottomRightList(text);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ public PrehistoricEggAdder() {
else if (walked < 10000) walkedStr = String.format("%.1fk", walked/1000.0f);
else walkedStr = walked / 1000 + "k";

return SlotText.bottomLeftList(Text.literal(walkedStr).withColor(0xFFDDC1));
return SlotText.bottomLeftList(Text.literal(walkedStr).withColor(SlotText.CREAM));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ public RancherBootsSpeedAdder() {
if (matcher == null) return List.of();
String speed = matcher.group(2);
if (speed == null) speed = matcher.group(1); //2nd group only matches when the speed cap is set to a number beyond the player's actual speed cap.
return SlotText.bottomLeftList(Text.literal(speed).withColor(0xFFDDC1));
return SlotText.bottomLeftList(Text.literal(speed).withColor(SlotText.CREAM));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ public SkillLevelAdder() {
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) : Integer.parseInt(romanNumeral))).withColor(0xE5B80B));
return SlotText.bottomLeftList(Text.literal(String.valueOf(RomanNumerals.isValidRomanNumeral(romanNumeral) ? RomanNumerals.romanToDecimal(romanNumeral) : Integer.parseInt(romanNumeral))).withColor(SlotText.GOLD));
} else {
return SlotText.bottomLeftList(Text.literal(String.valueOf(RomanNumerals.isValidRomanNumeral(romanNumeral) ? RomanNumerals.romanToDecimal(romanNumeral) : Integer.parseInt(romanNumeral))).withColor(0xFFDDC1));
return SlotText.bottomLeftList(Text.literal(String.valueOf(RomanNumerals.isValidRomanNumeral(romanNumeral) ? RomanNumerals.romanToDecimal(romanNumeral) : Integer.parseInt(romanNumeral))).withColor(SlotText.CREAM));
}
}
default -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ public SkyblockLevelAdder() {
if (siblings.size() < 3) return List.of();
String levelText = siblings.get(2).getString(); //The 3rd child is the level text itself
if (!NumberUtils.isDigits(levelText)) return List.of();
return SlotText.bottomLeftList(Text.literal(levelText).withColor(0xFFDDC1));
return SlotText.bottomLeftList(Text.literal(levelText).withColor(SlotText.CREAM));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ public StatsTuningAdder() {
if (stack.getName().getString().equals("Stats Tuning")) {
if (unassignedMatcher == null) return List.of();
String unassignedPoints = unassignedMatcher.group("points");
return SlotText.bottomRightList(Text.literal(unassignedPoints).withColor(0xFFDDC1));
return SlotText.bottomRightList(Text.literal(unassignedPoints).withColor(SlotText.CREAM));
}

if (statMatcher == null) return List.of();
String assignedPoints = statMatcher.group("points");
if (assignedPoints.equals("0")) return List.of();
return SlotText.bottomRightList(Text.literal(assignedPoints).withColor(0xFFDDC1));
return SlotText.bottomRightList(Text.literal(assignedPoints).withColor(SlotText.CREAM));

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public YourEssenceAdder() {
return essenceAmountMatcher(ItemUtils.getLore(stack)).<List<SlotText>>map(essenceAmountMatcher -> {
String essenceAmount = essenceAmountMatcher.group("essence").replace(",", "");
if (!essenceAmount.matches("-?\\d+")) return List.of();
return SlotText.bottomRightList(Text.literal(COMPACT_NUMBER_FORMATTER.format(Integer.parseInt(essenceAmount))).withColor(0xFFDDC1));
return SlotText.bottomRightList(Text.literal(COMPACT_NUMBER_FORMATTER.format(Integer.parseInt(essenceAmount))).withColor(SlotText.CREAM));
}).orElse(List.of());
}
return List.of();
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/assets/skyblocker/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -857,6 +857,7 @@
"skyblocker.config.uiAndVisuals.slotText.enchantmentLevel": "Enchantment Book Level",
"skyblocker.config.uiAndVisuals.slotText.essenceShop": "Essence Shop",
"skyblocker.config.uiAndVisuals.slotText.essenceShop.@Tooltip": "Displays the levels and your current amount of essence while in essence shops.",
"skyblocker.config.uiAndVisuals.slotText.hotmPerkLevel": "HOTM Perk Level",
"skyblocker.config.uiAndVisuals.slotText.minionLevel": "Minion Level",
"skyblocker.config.uiAndVisuals.slotText.petLevel": "Pet Level",
"skyblocker.config.uiAndVisuals.slotText.potionLevel": "Potion Level",
Expand Down
Loading