feat: Add item model to export
This commit is contained in:
@@ -106,6 +106,7 @@ class ItemExporter(var itemStack: ItemStack) {
|
|||||||
// TODO: calculate hideflags
|
// TODO: calculate hideflags
|
||||||
legacyNbt.put("HideFlags", NbtInt.of(254))
|
legacyNbt.put("HideFlags", NbtInt.of(254))
|
||||||
copyUnbreakable()
|
copyUnbreakable()
|
||||||
|
copyItemModel()
|
||||||
copyExtraAttributes()
|
copyExtraAttributes()
|
||||||
copyLegacySkullNbt()
|
copyLegacySkullNbt()
|
||||||
copyDisplay()
|
copyDisplay()
|
||||||
@@ -114,6 +115,11 @@ class ItemExporter(var itemStack: ItemStack) {
|
|||||||
// TODO: copyDisplay
|
// TODO: copyDisplay
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun copyItemModel() {
|
||||||
|
val itemModel = itemStack.get(DataComponentTypes.ITEM_MODEL) ?: return
|
||||||
|
legacyNbt.put("ItemModel", NbtString.of(itemModel.toString()))
|
||||||
|
}
|
||||||
|
|
||||||
private fun copyDisplay() {
|
private fun copyDisplay() {
|
||||||
legacyNbt.put("display", NbtCompound().apply {
|
legacyNbt.put("display", NbtCompound().apply {
|
||||||
put("Lore", lore.map { NbtString.of(it.getLegacyFormatString(trimmed = true)) }.toNbtList())
|
put("Lore", lore.map { NbtString.of(it.getLegacyFormatString(trimmed = true)) }.toNbtList())
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ import net.minecraft.nbt.NbtString
|
|||||||
import net.minecraft.text.MutableText
|
import net.minecraft.text.MutableText
|
||||||
import net.minecraft.text.Style
|
import net.minecraft.text.Style
|
||||||
import net.minecraft.text.Text
|
import net.minecraft.text.Text
|
||||||
|
import net.minecraft.util.Identifier
|
||||||
import moe.nea.firmament.Firmament
|
import moe.nea.firmament.Firmament
|
||||||
import moe.nea.firmament.repo.RepoManager.initialize
|
import moe.nea.firmament.repo.RepoManager.initialize
|
||||||
import moe.nea.firmament.util.LegacyFormattingCode
|
import moe.nea.firmament.util.LegacyFormattingCode
|
||||||
@@ -147,10 +148,14 @@ object ItemCache : IReloadable {
|
|||||||
ItemStack.fromNbt(MC.defaultRegistries, modernItemTag).getOrNull() ?: return brokenItemStack(this)
|
ItemStack.fromNbt(MC.defaultRegistries, modernItemTag).getOrNull() ?: return brokenItemStack(this)
|
||||||
itemInstance.loreAccordingToNbt = lore.map { un189Lore(it) }
|
itemInstance.loreAccordingToNbt = lore.map { un189Lore(it) }
|
||||||
itemInstance.displayNameAccordingToNbt = un189Lore(displayName)
|
itemInstance.displayNameAccordingToNbt = un189Lore(displayName)
|
||||||
val extraAttributes = oldItemTag.getCompound("tag").flatMap { it.getCompound("ExtraAttributes") }
|
val tag = oldItemTag.getCompound("tag")
|
||||||
|
val extraAttributes = tag.flatMap { it.getCompound("ExtraAttributes") }
|
||||||
.getOrNull()
|
.getOrNull()
|
||||||
if (extraAttributes != null)
|
if (extraAttributes != null)
|
||||||
itemInstance.set(DataComponentTypes.CUSTOM_DATA, NbtComponent.of(extraAttributes))
|
itemInstance.set(DataComponentTypes.CUSTOM_DATA, NbtComponent.of(extraAttributes))
|
||||||
|
val itemModel = tag.flatMap { it.getString("ItemModel") }.getOrNull()
|
||||||
|
if (itemModel != null)
|
||||||
|
itemInstance.set(DataComponentTypes.ITEM_MODEL, Identifier.of(itemModel))
|
||||||
return itemInstance
|
return itemInstance
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
|
|||||||
Reference in New Issue
Block a user