From ebffedd08c3ce32b7cd4ef6314f3f0efce7fbf51 Mon Sep 17 00:00:00 2001 From: nea Date: Sun, 9 Oct 2022 04:58:37 +0200 Subject: stuff --- .../moe/nea/notenoughupdates/repo/ItemCache.kt | 27 ++++++++++++++-------- 1 file changed, 18 insertions(+), 9 deletions(-) (limited to 'src/main/kotlin/moe/nea/notenoughupdates/repo/ItemCache.kt') diff --git a/src/main/kotlin/moe/nea/notenoughupdates/repo/ItemCache.kt b/src/main/kotlin/moe/nea/notenoughupdates/repo/ItemCache.kt index 7dbfce3..5f9159e 100644 --- a/src/main/kotlin/moe/nea/notenoughupdates/repo/ItemCache.kt +++ b/src/main/kotlin/moe/nea/notenoughupdates/repo/ItemCache.kt @@ -56,18 +56,27 @@ object ItemCache : IReloadable { null } + private fun brokenItemStack(neuItem: NEUItem): ItemStack { + return ItemStack(Items.PAINTING).apply { + setCustomName(Text.literal(neuItem.displayName)) + appendLore(listOf(Text.translatable("notenoughupdates.repo.brokenitem", neuItem.skyblockItemId))) + } + } + private fun NEUItem.asItemStackNow(): ItemStack { - val oldItemTag = get10809CompoundTag() - val modernItemTag = oldItemTag.transformFrom10809ToModern() - ?: return ItemStack(Items.PAINTING).apply { - setCustomName(Text.literal(this@asItemStackNow.displayName)) - appendLore(listOf(Text.translatable("notenoughupdates.repo.brokenitem", skyblockItemId))) + try { + val oldItemTag = get10809CompoundTag() + val modernItemTag = oldItemTag.transformFrom10809ToModern() + ?: return brokenItemStack(this) + val itemInstance = ItemStack.fromNbt(modernItemTag) + if (itemInstance.nbt?.contains("Enchantments") == true) { + itemInstance.enchantments.add(NbtCompound()) } - val itemInstance = ItemStack.fromNbt(modernItemTag) - if (itemInstance.nbt?.contains("Enchantments") == true) { - itemInstance.enchantments.add(NbtCompound()) + return itemInstance + } catch (e: Exception) { + e.printStackTrace() + return brokenItemStack(this) } - return itemInstance } fun NEUItem.asItemStack(): ItemStack { -- cgit