diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/items/HideNotClickableItems.kt | 11 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt | 20 |
2 files changed, 30 insertions, 1 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/items/HideNotClickableItems.kt b/src/main/java/at/hannibal2/skyhanni/items/HideNotClickableItems.kt index 28fcc065d..500133a53 100644 --- a/src/main/java/at/hannibal2/skyhanni/items/HideNotClickableItems.kt +++ b/src/main/java/at/hannibal2/skyhanni/items/HideNotClickableItems.kt @@ -179,11 +179,20 @@ class HideNotClickableItems { hideFishingBag(chestName, stack) -> true hidePotionBag(chestName, stack) -> true hidePrivateIslandChest(chestName, stack) -> true - + hideAttributeFusion(chestName, stack) -> true else -> false } } + private fun hideAttributeFusion(chestName: String, stack: ItemStack): Boolean { + if (!chestName.startsWith("Attribute Fusion")) return false + + if (ItemUtils.hasAttributes(stack)) return false + + hideReason = "This item has no attributes!" + return true + } + private fun hidePrivateIslandChest(chestName: String, stack: ItemStack): Boolean { if (chestName != "Chest" && chestName != "Large Chest") return false //TODO make check if player is on private island diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt index 83b4ae3da..6d84c7285 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt @@ -2,6 +2,8 @@ package at.hannibal2.skyhanni.utils import at.hannibal2.skyhanni.utils.LorenzUtils.matchRegex import at.hannibal2.skyhanni.utils.LorenzUtils.removeColorCodes +import com.google.gson.GsonBuilder +import com.google.gson.JsonObject import net.minecraft.client.Minecraft import net.minecraft.client.gui.inventory.GuiChest import net.minecraft.item.ItemStack @@ -75,4 +77,22 @@ object ItemUtils { return map } + + fun hasAttributes(stack: ItemStack): Boolean { + if (stack.hasTagCompound()) { + val tagCompound = stack.tagCompound + if (tagCompound.hasKey("ExtraAttributes")) { + val extraAttributes = tagCompound.getCompoundTag("ExtraAttributes") + try { + val json = GsonBuilder().create().fromJson(extraAttributes.toString(), JsonObject::class.java) + if (json.has("attributes")) { + return true + } + } catch (e: Exception) { + e.printStackTrace() + } + } + } + return false + } }
\ No newline at end of file |