aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/kotlin/features/debug/itemeditor/LegacyItemExporter.kt7
-rw-r--r--src/main/kotlin/util/MC.kt1
2 files changed, 6 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]!!
}
}
diff --git a/src/main/kotlin/util/MC.kt b/src/main/kotlin/util/MC.kt
index a6e3205..33b0bb3 100644
--- a/src/main/kotlin/util/MC.kt
+++ b/src/main/kotlin/util/MC.kt
@@ -121,6 +121,7 @@ object MC {
val defaultRegistries: RegistryWrapper.WrapperLookup by lazy { BuiltinRegistries.createWrapperLookup() }
val defaultRegistryNbtOps by lazy { RegistryOps.of(NbtOps.INSTANCE, defaultRegistries) }
inline val currentOrDefaultRegistries get() = currentRegistries ?: defaultRegistries
+ val currentOrDefaultRegistryNbtOps get() = RegistryOps.of(NbtOps.INSTANCE, currentOrDefaultRegistries)
val defaultItems: RegistryWrapper.Impl<Item> by lazy { defaultRegistries.getOrThrow(RegistryKeys.ITEM) }
var currentTick = 0
var lastWorld: World? = null