diff options
Diffstat (limited to 'src/main/java/de/hysky/skyblocker/skyblock/item/ItemRarityBackgrounds.java')
-rw-r--r-- | src/main/java/de/hysky/skyblocker/skyblock/item/ItemRarityBackgrounds.java | 29 |
1 files changed, 11 insertions, 18 deletions
diff --git a/src/main/java/de/hysky/skyblocker/skyblock/item/ItemRarityBackgrounds.java b/src/main/java/de/hysky/skyblocker/skyblock/item/ItemRarityBackgrounds.java index 0af64bd9..9e1df2bb 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/item/ItemRarityBackgrounds.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/item/ItemRarityBackgrounds.java @@ -1,15 +1,10 @@ package de.hysky.skyblocker.skyblock.item; -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.function.Supplier; - import com.google.common.collect.ImmutableMap; import com.mojang.blaze3d.systems.RenderSystem; - import de.hysky.skyblocker.SkyblockerMod; import de.hysky.skyblocker.config.SkyblockerConfigManager; +import de.hysky.skyblocker.utils.ItemUtils; import de.hysky.skyblocker.utils.Utils; import de.hysky.skyblocker.utils.scheduler.Scheduler; import it.unimi.dsi.fastutil.ints.Int2ReferenceOpenHashMap; @@ -20,10 +15,14 @@ import net.minecraft.client.item.TooltipContext; import net.minecraft.client.network.ClientPlayerEntity; import net.minecraft.client.texture.Sprite; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NbtCompound; import net.minecraft.text.Text; import net.minecraft.util.Identifier; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.function.Supplier; + public class ItemRarityBackgrounds { private static final Identifier RARITY_BG_TEX = new Identifier(SkyblockerMod.NAMESPACE, "item_rarity_background"); private static final Supplier<Sprite> SPRITE = () -> MinecraftClient.getInstance().getGuiAtlasManager().getSprite(RARITY_BG_TEX); @@ -67,17 +66,11 @@ public class ItemRarityBackgrounds { private static SkyblockItemRarity getItemRarity(ItemStack stack, ClientPlayerEntity player) { if (stack == null || stack.isEmpty()) return null; - - int hashCode = 0; - NbtCompound nbt = stack.getNbt(); - - if (nbt != null && nbt.contains("ExtraAttributes")) { - NbtCompound extraAttributes = nbt.getCompound("ExtraAttributes"); - String itemUuid = extraAttributes.getString("uuid"); - - //If the item has an uuid, then use the hash code of the uuid otherwise use the identity hash code of the stack - hashCode = itemUuid.isEmpty() ? System.identityHashCode(stack) : itemUuid.hashCode(); - } + + String itemUuid = ItemUtils.getItemUuid(stack); + + //If the item has an uuid, then use the hash code of the uuid otherwise use the identity hash code of the stack + int hashCode = itemUuid.isEmpty() ? System.identityHashCode(stack) : itemUuid.hashCode(); if (CACHE.containsKey(hashCode)) return CACHE.get(hashCode); |