blob: 892127dadbddba1e944e1dd9c72a40657f48f813 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
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) }
}
fun ItemStack.getDisplayNameU(): String {
val nbt = this.tagCompound ?: NBTTagCompound()
val extraAttributes = nbt.getCompoundTag("display")
return extraAttributes.getString("Name")
}
|