Add collection info to skill page

This commit is contained in:
nea
2023-06-11 02:43:14 +02:00
parent 040f7c7275
commit a36c8f1c0e
12 changed files with 211 additions and 41 deletions

View File

@@ -33,6 +33,16 @@ fun ItemStack.appendLore(args: List<Text>) {
}
}
fun ItemStack.modifyLore(update: (List<Text>) -> List<Text>) {
val compoundTag = getOrCreateSubNbt("display")
val loreList = compoundTag.getOrCreateList("Lore", NbtString.STRING_TYPE)
val parsed = loreList.map { Text.Serializer.fromJson(it.asString())!! }
val updated = update(parsed)
loreList.clear()
loreList.addAll(updated.map { NbtString.of(Text.Serializer.toJson(it)) })
}
fun NbtCompound.getOrCreateList(label: String, tag: Byte): NbtList = getList(label, tag.toInt()).also {
put(label, it)
}