aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/utils
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt
index 8b6203aaa..612f048de 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt
@@ -55,7 +55,17 @@ object ItemUtils {
return list
}
- val ItemStack.extraAttributes: NBTTagCompound get() = this.tagCompound.getCompoundTag("ExtraAttributes")
+ var ItemStack.extraAttributes: NBTTagCompound
+ get() = this.tagCompound?.getCompoundTag("ExtraAttributes") ?: NBTTagCompound()
+ set(value) {
+ val tag = this.tagCompound ?: NBTTagCompound().also { tagCompound = it }
+ tag.setTag("ExtraAttributes", value)
+ }
+
+ fun ItemStack.overrideId(id: String): ItemStack {
+ extraAttributes = extraAttributes.apply { setString("id", id) }
+ return this
+ }
// TODO change else janni is sad
fun ItemStack.isCoopSoulBound(): Boolean =