diff options
| author | Linnea Gräf <nea@nea.moe> | 2025-09-17 23:47:51 +0200 |
|---|---|---|
| committer | Linnea Gräf <nea@nea.moe> | 2025-09-17 23:47:51 +0200 |
| commit | 8ee0f8625b1cc3d7ba93400271e3851d186868b2 (patch) | |
| tree | 31151b1a857fa1ba11425fea8da44e84a8a8777e /src/main/kotlin/features/debug | |
| parent | 171fa38ddc65de7c37356c12f3cafc584bbca801 (diff) | |
| download | Firmament-8ee0f8625b1cc3d7ba93400271e3851d186868b2.tar.gz Firmament-8ee0f8625b1cc3d7ba93400271e3851d186868b2.tar.bz2 Firmament-8ee0f8625b1cc3d7ba93400271e3851d186868b2.zip | |
fix: crash on stonks / splash potions in item exporter
Diffstat (limited to 'src/main/kotlin/features/debug')
| -rw-r--r-- | src/main/kotlin/features/debug/itemeditor/LegacyItemExporter.kt | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/main/kotlin/features/debug/itemeditor/LegacyItemExporter.kt b/src/main/kotlin/features/debug/itemeditor/LegacyItemExporter.kt index 20ab2c3..f06eb43 100644 --- a/src/main/kotlin/features/debug/itemeditor/LegacyItemExporter.kt +++ b/src/main/kotlin/features/debug/itemeditor/LegacyItemExporter.kt @@ -8,6 +8,7 @@ import kotlin.concurrent.thread import kotlin.jvm.optionals.getOrNull import net.minecraft.component.DataComponentTypes import net.minecraft.item.ItemStack +import net.minecraft.item.Items import net.minecraft.nbt.NbtByte import net.minecraft.nbt.NbtCompound import net.minecraft.nbt.NbtElement @@ -25,6 +26,7 @@ import moe.nea.firmament.features.debug.ExportedTestConstantMeta import moe.nea.firmament.repo.SBItemStack import moe.nea.firmament.util.HypixelPetInfo import moe.nea.firmament.util.LegacyTagWriter.Companion.toLegacyString +import moe.nea.firmament.util.MC import moe.nea.firmament.util.StringUtil.words import moe.nea.firmament.util.directLiteralStringContent import moe.nea.firmament.util.extraAttributes @@ -197,10 +199,9 @@ class LegacyItemExporter private constructor(var itemStack: ItemStack) { } fun exportModernSnbt(): NbtElement { - val overlay = ItemStack.CODEC.encodeStart(NbtOps.INSTANCE, itemStack.copy().also { + val overlay = ItemStack.CODEC.encodeStart(MC.currentOrDefaultRegistryNbtOps, itemStack.copy().also { it.modifyExtraAttributes { attribs -> originalId.ifPresent { attribs.putString("id", it) } - attribs } }).orThrow val overlayWithVersion = @@ -312,6 +313,8 @@ class LegacyItemExporter private constructor(var itemStack: ItemStack) { fun legacyifyItemStack(): LegacyItemData.LegacyItemType { // TODO: add a default here + if (itemStack.item == Items.LINGERING_POTION || itemStack.item == Items.SPLASH_POTION) + return LegacyItemData.LegacyItemType("potion", 16384) return LegacyItemData.itemLut[itemStack.item]!! } } |
