blob: 2e721d87ad4f1523d1f1b664f4bbdd0654b22770 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
package moe.nea.firmament.util.item
import net.minecraft.item.ItemStack
import net.minecraft.nbt.NbtElement
import net.minecraft.nbt.NbtString
import net.minecraft.text.Text
val ItemStack.loreAccordingToNbt
get() = getOrCreateSubNbt(ItemStack.DISPLAY_KEY).getList(ItemStack.LORE_KEY, NbtElement.STRING_TYPE.toInt())
.map { Text.Serializer.fromJson((it as NbtString).asString()) }
val ItemStack.displayNameAccordingToNbt
get() = getOrCreateSubNbt(ItemStack.DISPLAY_KEY).let {
if (it.contains(ItemStack.NAME_KEY, NbtElement.STRING_TYPE.toInt()))
Text.Serializer.fromJson(it.getString(ItemStack.NAME_KEY))
else
null
}
|