package moe.nea.ledger import net.minecraft.item.ItemStack import net.minecraft.nbt.NBTTagCompound fun ItemStack.getInternalId(): ItemId? { val nbt = this.tagCompound ?: NBTTagCompound() val extraAttributes = nbt.getCompoundTag("ExtraAttributes") val id = extraAttributes.getString("id") return id.takeIf { it.isNotBlank() }?.let(::ItemId) } fun ItemStack.getLore(): List { val nbt = this.tagCompound ?: NBTTagCompound() val extraAttributes = nbt.getCompoundTag("display") val lore = extraAttributes.getTagList("Lore", 8) return (0 until lore.tagCount()).map { lore.getStringTagAt(it) } } fun ItemStack.getDisplayNameU(): String { val nbt = this.tagCompound ?: NBTTagCompound() val extraAttributes = nbt.getCompoundTag("display") return extraAttributes.getString("Name") }