blob: 715738698818d8c2db05d83906c5cdd9b6e62f0c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
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() }
}
fun ItemStack.getLore(): List<String> {
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) }
}
|