blob: b82c97f1aff28b72d2356ec6519c095c23cf0071 (
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(): 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<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")
}
|