diff options
Diffstat (limited to 'src/main/kotlin/moe/nea/notenoughupdates/repo')
-rw-r--r-- | src/main/kotlin/moe/nea/notenoughupdates/repo/ItemCache.kt | 27 |
1 files changed, 18 insertions, 9 deletions
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 { |