diff options
author | J10a1n15 <45315647+j10a1n15@users.noreply.github.com> | 2024-06-12 23:55:50 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-12 23:55:50 +0200 |
commit | 7dab99f46d4caaaef0b7c29f90ad48c192800df7 (patch) | |
tree | 254080fff301aa6f6615d2f4f96ef541cf81ce9e | |
parent | e6d4aea4b0bff9438beefd78e59ff17479182404 (diff) | |
download | skyhanni-7dab99f46d4caaaef0b7c29f90ad48c192800df7.tar.gz skyhanni-7dab99f46d4caaaef0b7c29f90ad48c192800df7.tar.bz2 skyhanni-7dab99f46d4caaaef0b7c29f90ad48c192800df7.zip |
Fix: ConcurrentModificationException in EnchantParser in CustomWardrobe (#2070)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/inventory/wardrobe/CustomWardrobe.kt | 56 |
1 files changed, 31 insertions, 25 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/wardrobe/CustomWardrobe.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/wardrobe/CustomWardrobe.kt index 128fa9c69..21bf346ff 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/wardrobe/CustomWardrobe.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/wardrobe/CustomWardrobe.kt @@ -12,6 +12,7 @@ import at.hannibal2.skyhanni.features.inventory.wardrobe.WardrobeAPI.MAX_PAGES import at.hannibal2.skyhanni.features.inventory.wardrobe.WardrobeAPI.MAX_SLOT_PER_PAGE import at.hannibal2.skyhanni.mixins.transformers.gui.AccessorGuiContainer import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule +import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.ColorUtils.addAlpha import at.hannibal2.skyhanni.utils.ColorUtils.darker import at.hannibal2.skyhanni.utils.ColorUtils.toChromaColor @@ -198,20 +199,14 @@ object CustomWardrobe { for (armorIndex in 0 until 4) { val stack = slot.armor[armorIndex]?.copy() - if (stack == null) { - loreList.add(Renderable.placeholder(containerWidth, hoverableSizes[armorIndex])) - } else { - loreList.add( - Renderable.hoverable( - Renderable.hoverTips( - Renderable.placeholder(containerWidth, hoverableSizes[armorIndex]), - getToolTip(stack, slot, armorIndex) - ), - Renderable.placeholder(containerWidth, hoverableSizes[armorIndex]), - bypassChecks = true - ) - ) + var renderable = Renderable.placeholder(containerWidth, hoverableSizes[armorIndex]) + if (stack != null) { + val toolTip = getToolTip(stack, slot, armorIndex) + if (toolTip != null) { + renderable = Renderable.hoverTips(renderable, tips = toolTip) + } } + loreList.add(renderable) } return Renderable.verticalContainer(loreList, spacing = 1) } @@ -220,18 +215,29 @@ object CustomWardrobe { stack: ItemStack, slot: WardrobeSlot, armorIndex: Int, - ): List<String> { - // Get tooltip from minecraft and other mods - // TODO add support for advanced tooltip (F3+H) - val toolTips = stack.getTooltip(Minecraft.getMinecraft().thePlayer, false) - - // Modify tooltip via SkyHanni Events - val mcSlotId = slot.inventorySlots[armorIndex] - // if the slot is null, we don't fire LorenzToolTipEvent at all. - val mcSlot = InventoryUtils.getSlotAtIndex(mcSlotId) ?: return toolTips - LorenzToolTipEvent(mcSlot, stack, toolTips).postAndCatch() - - return toolTips + ): List<String>? { + try { + // Get tooltip from minecraft and other mods + // TODO add support for advanced tooltip (F3+H) + val toolTips = stack.getTooltip(Minecraft.getMinecraft().thePlayer, false) + + // Modify tooltip via SkyHanni Events + val mcSlotId = slot.inventorySlots[armorIndex] + // if the slot is null, we don't fire LorenzToolTipEvent at all. + val mcSlot = InventoryUtils.getSlotAtIndex(mcSlotId) ?: return toolTips + LorenzToolTipEvent(mcSlot, stack, toolTips).postWithoutCatch() + + return toolTips + } catch (e: Exception) { + ErrorManager.logErrorWithData( + e, + "Failed to get tooltip for armor piece in CustomWardrobe", + "Armor" to stack, + "Slot" to slot, + "Lore" to stack.getTooltip(Minecraft.getMinecraft().thePlayer, false), + ) + return null + } } private fun createFakePlayerRenderable( |