aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/util/mc/ItemUtil.kt
blob: 13519cf448e33b9ebafd91cf6261fafceb609e09 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
package moe.nea.firmament.util.mc

import net.minecraft.item.ItemStack
import net.minecraft.text.Text

fun ItemStack.appendLore(args: List<Text>) {
    if (args.isEmpty()) return
    modifyLore {
        val loreList = loreAccordingToNbt.toMutableList()
        for (arg in args) {
            loreList.add(arg)
        }
        loreList
    }
}

fun ItemStack.modifyLore(update: (List<Text>) -> List<Text>) {
    val loreList = loreAccordingToNbt
    loreAccordingToNbt = update(loreList)
}