aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorRime <81419447+Emirlol@users.noreply.github.com>2024-05-29 09:11:50 +0300
committerRime <81419447+Emirlol@users.noreply.github.com>2024-06-08 04:13:47 +0300
commit6911d4f963ddd0e2f420b586ca673000c62da31e (patch)
treee2720ce4f738dc41d748b41d669fc427aa7eedc9 /src/main
parentf559aa2b0a945d27fb5e78076e55f4e3b31e016e (diff)
downloadSkyblocker-6911d4f963ddd0e2f420b586ca673000c62da31e.tar.gz
Skyblocker-6911d4f963ddd0e2f420b586ca673000c62da31e.tar.bz2
Skyblocker-6911d4f963ddd0e2f420b586ca673000c62da31e.zip
Refactor museum tooltip
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/ItemTooltip.java24
-rw-r--r--src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/MuseumTooltip.java48
-rw-r--r--src/main/java/de/hysky/skyblocker/utils/tooltip/TooltipManager.java2
3 files changed, 50 insertions, 24 deletions
diff --git a/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/ItemTooltip.java b/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/ItemTooltip.java
index 776e301d..1f1412d4 100644
--- a/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/ItemTooltip.java
+++ b/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/ItemTooltip.java
@@ -4,7 +4,6 @@ import com.google.gson.JsonObject;
import de.hysky.skyblocker.SkyblockerMod;
import de.hysky.skyblocker.config.SkyblockerConfigManager;
import de.hysky.skyblocker.config.configs.GeneralConfig;
-import de.hysky.skyblocker.skyblock.item.MuseumItemCache;
import de.hysky.skyblocker.skyblock.item.tooltip.AccessoriesHelper.AccessoryReport;
import de.hysky.skyblocker.utils.Constants;
import de.hysky.skyblocker.utils.ItemUtils;
@@ -122,30 +121,7 @@ public class ItemTooltip {
}
- if (TooltipInfoType.MUSEUM.isTooltipEnabledAndHasOrNullWarning(internalID)) {
- String itemCategory = TooltipInfoType.MUSEUM.getData().get(internalID).getAsString();
- String format = switch (itemCategory) {
- case "Weapons" -> "%-18s";
- case "Armor" -> "%-19s";
- default -> "%-20s";
- };
- //Special case the special category so that it doesn't always display not donated
- if (itemCategory.equals("Special")) {
- lines.add(Text.literal(String.format(format, "Museum: (" + itemCategory + ")"))
- .formatted(Formatting.LIGHT_PURPLE));
- } else {
- NbtCompound customData = ItemUtils.getCustomData(stack);
- boolean isInMuseum = (customData.contains("donated_museum") && customData.getBoolean("donated_museum")) || MuseumItemCache.hasItemInMuseum(internalID);
-
- Formatting donatedIndicatorFormatting = isInMuseum ? Formatting.GREEN : Formatting.RED;
-
- lines.add(Text.literal(String.format(format, "Museum (" + itemCategory + "):"))
- .formatted(Formatting.LIGHT_PURPLE)
- .append(Text.literal(isInMuseum ? "✔" : "✖").formatted(donatedIndicatorFormatting, Formatting.BOLD))
- .append(Text.literal(isInMuseum ? " Donated" : " Not Donated").formatted(donatedIndicatorFormatting)));
- }
- }
if (TooltipInfoType.COLOR.isTooltipEnabledAndHasOrNullWarning(internalID) && stack.contains(DataComponentTypes.DYED_COLOR)) {
String uuid = ItemUtils.getItemUuid(stack);
diff --git a/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/MuseumTooltip.java b/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/MuseumTooltip.java
new file mode 100644
index 00000000..727c83db
--- /dev/null
+++ b/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/MuseumTooltip.java
@@ -0,0 +1,48 @@
+package de.hysky.skyblocker.skyblock.item.tooltip;
+
+import de.hysky.skyblocker.skyblock.item.MuseumItemCache;
+import de.hysky.skyblocker.utils.ItemUtils;
+import de.hysky.skyblocker.utils.tooltip.TooltipAdder;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NbtCompound;
+import net.minecraft.screen.slot.Slot;
+import net.minecraft.text.Text;
+import net.minecraft.util.Formatting;
+
+import java.util.List;
+
+public class MuseumTooltip extends TooltipAdder {
+ public MuseumTooltip(int priority) {
+ super(priority);
+ }
+
+ @Override
+ public void addToTooltip(List<Text> lore, Slot focusedSlot) {
+ final ItemStack itemStack = focusedSlot.getStack();
+ final String internalID = ItemTooltip.getInternalNameFromNBT(itemStack, true);
+ if (TooltipInfoType.MUSEUM.isTooltipEnabledAndHasOrNullWarning(internalID)) {
+ String itemCategory = TooltipInfoType.MUSEUM.getData().get(internalID).getAsString();
+ String format = switch (itemCategory) {
+ case "Weapons" -> "%-18s";
+ case "Armor" -> "%-19s";
+ default -> "%-20s";
+ };
+
+ //Special case the special category so that it doesn't always display not donated
+ if (itemCategory.equals("Special")) {
+ lore.add(Text.literal(String.format(format, "Museum: (" + itemCategory + ")"))
+ .formatted(Formatting.LIGHT_PURPLE));
+ } else {
+ NbtCompound customData = ItemUtils.getCustomData(itemStack);
+ boolean isInMuseum = (customData.contains("donated_museum") && customData.getBoolean("donated_museum")) || MuseumItemCache.hasItemInMuseum(internalID);
+
+ Formatting donatedIndicatorFormatting = isInMuseum ? Formatting.GREEN : Formatting.RED;
+
+ lore.add(Text.literal(String.format(format, "Museum (" + itemCategory + "):"))
+ .formatted(Formatting.LIGHT_PURPLE)
+ .append(Text.literal(isInMuseum ? "✔" : "✖").formatted(donatedIndicatorFormatting, Formatting.BOLD))
+ .append(Text.literal(isInMuseum ? " Donated" : " Not Donated").formatted(donatedIndicatorFormatting)));
+ }
+ }
+ }
+}
diff --git a/src/main/java/de/hysky/skyblocker/utils/tooltip/TooltipManager.java b/src/main/java/de/hysky/skyblocker/utils/tooltip/TooltipManager.java
index 05f16487..dcad236f 100644
--- a/src/main/java/de/hysky/skyblocker/utils/tooltip/TooltipManager.java
+++ b/src/main/java/de/hysky/skyblocker/utils/tooltip/TooltipManager.java
@@ -1,5 +1,6 @@
package de.hysky.skyblocker.utils.tooltip;
+import de.hysky.skyblocker.skyblock.item.tooltip.MuseumTooltip;
import de.hysky.skyblocker.utils.Utils;
import net.fabricmc.fabric.api.client.screen.v1.ScreenEvents;
import net.minecraft.client.gui.screen.Screen;
@@ -15,6 +16,7 @@ public class TooltipManager {
new LineSmoothener(),
new DungeonQualityTooltip(0),
new ObtainedTooltip(3),
+ new MuseumTooltip(4),
new MotesTooltip(0),
new NpcPriceTooltip(1)
};