diff options
author | Luna <luna@alexia.lol> | 2024-08-10 00:54:51 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-10 00:54:51 +0200 |
commit | a2466409114bc570e8e8ab92e30be8c24794441f (patch) | |
tree | 6162aac5fd7a4363cf00f538b15d02cd908818ff | |
parent | 894334db3abe18bb7260fcaac53f7ae548cd7c42 (diff) | |
download | skyhanni-a2466409114bc570e8e8ab92e30be8c24794441f.tar.gz skyhanni-a2466409114bc570e8e8ab92e30be8c24794441f.tar.bz2 skyhanni-a2466409114bc570e8e8ab92e30be8c24794441f.zip |
Fix: Incorrect "This item has no attributes" message (#2304)
3 files changed, 4 insertions, 16 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt index b71633122..2e549313c 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt @@ -39,6 +39,7 @@ import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher import at.hannibal2.skyhanni.utils.RenderUtils.drawBorder import at.hannibal2.skyhanni.utils.RenderUtils.highlight import at.hannibal2.skyhanni.utils.SimpleTimeMark +import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.hasAttributes import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.isMuseumDonated import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.isRiftExportable import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.isRiftTransferable @@ -330,7 +331,7 @@ object HideNotClickableItems { showGreenLine = true - if (ItemUtils.hasAttributes(stack)) return false + if (stack.hasAttributes()) return false hideReason = "This item has no attributes!" return true diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt index 580ee2a95..95dad660c 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt @@ -14,8 +14,6 @@ import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getEnchantments import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.isRecombobulated import at.hannibal2.skyhanni.utils.StringUtils.removeColor import at.hannibal2.skyhanni.utils.StringUtils.removeResets -import com.google.gson.GsonBuilder -import com.google.gson.JsonObject import io.github.moulberry.notenoughupdates.recipes.NeuRecipe import net.minecraft.client.Minecraft import net.minecraft.init.Items @@ -78,19 +76,6 @@ object ItemUtils { return list } - fun hasAttributes(stack: ItemStack): Boolean { - if (!stack.hasTagCompound()) return false - val tagCompound = stack.tagCompound - if (!tagCompound.hasKey("ExtraAttributes")) return false - val extraAttributes = tagCompound.getCompoundTag("ExtraAttributes") - try { - val json = GsonBuilder().create().fromJson(extraAttributes.toString(), JsonObject::class.java) - return json.has("attributes") - } catch (_: Exception) { - return false - } - } - fun ItemStack.getInternalName() = getInternalNameOrNull() ?: NEUInternalName.NONE fun ItemStack.getInternalNameOrNull(): NEUInternalName? { diff --git a/src/main/java/at/hannibal2/skyhanni/utils/SkyBlockItemModifierUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/SkyBlockItemModifierUtils.kt index 2b3ece2c7..7d38fa58b 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/SkyBlockItemModifierUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/SkyBlockItemModifierUtils.kt @@ -151,6 +151,8 @@ object SkyBlockItemModifierUtils { }.sortedBy { it.first } } + fun ItemStack.hasAttributes() = getAttributes() != null + fun ItemStack.getReforgeName() = getAttributeString("modifier")?.let { when { it == "pitchin" -> "pitchin_koi" |