aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/moe/nea/ledger/ItemUtil.kt
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/kotlin/moe/nea/ledger/ItemUtil.kt')
-rw-r--r--src/main/kotlin/moe/nea/ledger/ItemUtil.kt13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/main/kotlin/moe/nea/ledger/ItemUtil.kt b/src/main/kotlin/moe/nea/ledger/ItemUtil.kt
new file mode 100644
index 0000000..365c37e
--- /dev/null
+++ b/src/main/kotlin/moe/nea/ledger/ItemUtil.kt
@@ -0,0 +1,13 @@
+package moe.nea.ledger
+
+import net.minecraft.item.ItemStack
+import net.minecraft.nbt.NBTTagCompound
+
+
+fun ItemStack.getInternalId(): String? {
+ val nbt = this.tagCompound ?: NBTTagCompound()
+ val extraAttributes = nbt.getCompoundTag("ExtraAttributes")
+ val id = extraAttributes.getString("id")
+ return id.takeIf { it.isNotBlank() }
+}
+