NPE when Apotheosis applies affixes to air items
Closed this issue · 1 comments
When opening certain Incendium barrels (e.g., loot table incendium:castle/tower_barrel), the table's conditional pools sometimes resolve to minecraft:air. Apotheosis then applies enchantments and affixes via EnchantWithLevelsFunction without validating the stack, passing a null air ItemStack into the shared EnchantmentHelper pipeline.
This triggers Spell Power Attribute’s enchantment hook (FabricItemStack.canBeEnchantedWith via Fabric Item API), where it calls itemAttributes.modifiers() on a null stack, causing the NPE. The exception is suppressed (no visible crash), but the affected barrel becomes permanently unopenable.
Empty air entries in loot tables should be ignored by Apotheosis when adding modifiers
Possibly related to: ZsoltMolnarrr/SpellPower#43
Versions
Minecraft 1.21.1 (NeoForge)
Apotheosis 8.4.0
Spell Power Attribute 1.4.1
Incendium 5.4.3
Lootr 1.10.35.91
Connector present
Log Excerpt:
[13:23:51] [Server thread/ERROR] [minecraft/ServerPacketListener]: Failed to handle packet net.minecraft.network.protocol.game.ServerboundUseItemOnPacket@5fecc6fa, suppressing error
java.lang.NullPointerException: Cannot invoke "net.minecraft.world.item.component.ItemAttributeModifiers.modifiers()" because "itemAttributes" is null
at TRANSFORMER/[email protected]+1.21.1/net.spell_power.SpellPowerMod.lambda$registerAttributes$0(SpellPowerMod.java:63) ~[spell_power-neoforge-1.4.1+1.21.1.jar%23814!/:?] {re:mixin,re:classloading}
at TRANSFORMER/[email protected]+57cdfa8219/net.fabricmc.fabric.api.item.v1.EnchantmentEvents.lambda$static$0(EnchantmentEvents.java:56) ~[fabric-item-api-v1-11.1.1+57cdfa8219.jar%231179!/:11.1.1+57cdfa8219] {re:classloading}
at TRANSFORMER/[email protected]+57cdfa8219/net.fabricmc.fabric.api.item.v1.FabricItemStack.canBeEnchantedWith(FabricItemStack.java:57) ~[fabric-item-api-v1-11.1.1+57cdfa8219.jar%231179!/:11.1.1+57cdfa8219] {re:mixin,re:classloading}
at TRANSFORMER/[email protected]/net.minecraft.world.item.enchantment.EnchantmentHelper.md45a20a$fabric_item_api_v1$lambda$useCustomEnchantingChecks$0$4(EnchantmentHelper.java:1216) ~[client-1.21.1-20240808.144430-srg.jar%23527!/:?] {re:mixin,pl:accesstransformer:B,xf:fml:apothic_enchanting:ench_info_loot_redirects,pl:connector_pre_launch:A,re:classloading,pl:accesstransformer:B,xf:fml:apothic_enchanting:ench_info_loot_redirects,pl:mixin:APP:accessories-common.mixins.json:EnchantmentHelperMixin from mod accessories,pl:mixin:APP:fabric-item-api-v1.mixins.json:EnchantmentHelperMixin from mod fabric_item_api_v1,pl:mixin:APP:apotheosis.mixins.json:EnchantmentHelperMixin from mod apotheosis,pl:mixin:APP:puzzleslib.neoforge.mixins.json:EnchantmentHelperNeoForgeMixin from mod puzzleslib,pl:mixin:A,pl:connector_pre_launch:A}
at java.base/java.util.stream.ReferencePipeline$2$1.accept(Unknown Source) ~[?:?] {}```