aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com')
-rw-r--r--src/main/java/com/anthonyhilyard/iceberg/util/ItemColor.java17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/main/java/com/anthonyhilyard/iceberg/util/ItemColor.java b/src/main/java/com/anthonyhilyard/iceberg/util/ItemColor.java
index 6b614c5..d5bcbfa 100644
--- a/src/main/java/com/anthonyhilyard/iceberg/util/ItemColor.java
+++ b/src/main/java/com/anthonyhilyard/iceberg/util/ItemColor.java
@@ -1,11 +1,16 @@
package com.anthonyhilyard.iceberg.util;
import net.minecraft.world.item.ItemStack;
+import net.minecraft.world.item.TooltipFlag;
import net.minecraft.util.FormattedCharSink;
import net.minecraft.network.chat.TextColor;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.Style;
+
+import java.util.List;
+
import net.minecraft.ChatFormatting;
+import net.minecraft.client.Minecraft;
public class ItemColor
{
@@ -97,6 +102,18 @@ public class ItemColor
result = colorCollector.getColor();
}
+ // If we haven't found a color or we're still using the rarity color, check the actual tooltip.
+ // This is slow, so it better get cached externally!
+ if (result == null || result.equals(item.getDisplayName().getStyle().getColor()))
+ {
+ Minecraft mc = Minecraft.getInstance();
+ List<Component> lines = item.getTooltipLines(mc.player, TooltipFlag.Default.ADVANCED);
+ if (!lines.isEmpty())
+ {
+ result = lines.get(0).getStyle().getColor();
+ }
+ }
+
// Fallback to the default TextColor if we somehow haven't found a single valid TextColor.
if (result == null)
{