aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/moe/nea/notenoughupdates/repo
diff options
context:
space:
mode:
authornea <romangraef@gmail.com>2022-10-09 04:58:37 +0200
committernea <romangraef@gmail.com>2022-10-09 04:58:37 +0200
commitebffedd08c3ce32b7cd4ef6314f3f0efce7fbf51 (patch)
treea56760fa212cd20fc7719b56d10a92ac33ffc27e /src/main/kotlin/moe/nea/notenoughupdates/repo
parent4d73331a449f0b0647066f7dde0628730fe0e178 (diff)
downloadfirmament-ebffedd08c3ce32b7cd4ef6314f3f0efce7fbf51.tar.gz
firmament-ebffedd08c3ce32b7cd4ef6314f3f0efce7fbf51.tar.bz2
firmament-ebffedd08c3ce32b7cd4ef6314f3f0efce7fbf51.zip
stuff
Diffstat (limited to 'src/main/kotlin/moe/nea/notenoughupdates/repo')
-rw-r--r--src/main/kotlin/moe/nea/notenoughupdates/repo/ItemCache.kt27
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 {