Add collection info to skill page
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import net.minecraft.client.gui.screen.ingame.HandledScreen
|
||||
import net.minecraft.util.math.BlockPos
|
||||
|
||||
object MC {
|
||||
inline val font get() = MinecraftClient.getInstance().textRenderer
|
||||
inline val soundManager get() = MinecraftClient.getInstance().soundManager
|
||||
inline val player get() = MinecraftClient.getInstance().player
|
||||
inline val world get() = MinecraftClient.getInstance().world
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
package moe.nea.firmament.util
|
||||
|
||||
import net.minecraft.text.TextColor
|
||||
import net.minecraft.util.DyeColor
|
||||
|
||||
fun DyeColor.toShedaniel(): me.shedaniel.math.Color =
|
||||
me.shedaniel.math.Color.ofOpaque(this.signColor)
|
||||
|
||||
fun DyeColor.toTextColor(): TextColor =
|
||||
TextColor.fromRgb(this.signColor)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user