diff options
Diffstat (limited to 'src/main/kotlin/moe/nea/firmament/util')
-rw-r--r-- | src/main/kotlin/moe/nea/firmament/util/item/NbtItemData.kt | 5 | ||||
-rw-r--r-- | src/main/kotlin/moe/nea/firmament/util/textutil.kt | 3 |
2 files changed, 6 insertions, 2 deletions
diff --git a/src/main/kotlin/moe/nea/firmament/util/item/NbtItemData.kt b/src/main/kotlin/moe/nea/firmament/util/item/NbtItemData.kt index ef22325..c33c47f 100644 --- a/src/main/kotlin/moe/nea/firmament/util/item/NbtItemData.kt +++ b/src/main/kotlin/moe/nea/firmament/util/item/NbtItemData.kt @@ -18,8 +18,11 @@ var ItemStack.loreAccordingToNbt set(DataComponentTypes.LORE, LoreComponent(value)) } -val ItemStack.displayNameAccordingToNbt +var ItemStack.displayNameAccordingToNbt: Text get() = get(DataComponentTypes.CUSTOM_NAME) ?: get(DataComponentTypes.ITEM_NAME) ?: item.name + set(value) { + set(DataComponentTypes.CUSTOM_NAME, value) + } fun ItemStack.setCustomName(text: Text) { set(DataComponentTypes.CUSTOM_NAME, text) diff --git a/src/main/kotlin/moe/nea/firmament/util/textutil.kt b/src/main/kotlin/moe/nea/firmament/util/textutil.kt index 5f9379a..38b7daf 100644 --- a/src/main/kotlin/moe/nea/firmament/util/textutil.kt +++ b/src/main/kotlin/moe/nea/firmament/util/textutil.kt @@ -9,6 +9,7 @@ package moe.nea.firmament.util import net.minecraft.text.MutableText import net.minecraft.text.PlainTextContent +import net.minecraft.text.Style import net.minecraft.text.Text import net.minecraft.text.TranslatableTextContent import net.minecraft.util.Formatting @@ -98,7 +99,7 @@ val Text.unformattedString: String get() = string.removeColorCodes() -fun MutableText.withColor(formatting: Formatting) = this.styled { it.withColor(formatting) } +fun MutableText.withColor(formatting: Formatting) = this.styled { it.withColor(formatting).withItalic(false) } fun Text.transformEachRecursively(function: (Text) -> Text): Text { val c = this.content |