Trinkets Compat Layer for Accessories

Trinkets Compat Layer for Accessories

3M Downloads

[1.20.x Forge Curios] getCuriosInventory() throws an exception when livingEntity is null

gamrguy opened this issue ยท 1 comments

commented

In normal Curios an empty LazyOptional is returned when livingEntity is null.
In the Accessories compat layer this situation instead throws a NullPointerException.

Curios code:
https://github.com/TheIllusiveC4/Curios/blob/157f0dca5417092900b3adc60bcd6312101db912/src/main/java/top/theillusivec4/curios/mixin/CuriosImplMixinHooks.java#L105

Accessories compat layer code:

public static LazyOptional<ICuriosItemHandler> getCuriosInventory(LivingEntity livingEntity) {

This means mods that don't crash with Curios can crash when the Accessories Curios Compat Layer is in use.

I've identified a scenario where Mana and Artifice encounters this issue when attempting to generate a random staff with a levitation component as part of a loot table:

java.lang.NullPointerException: Cannot invoke "net.minecraft.world.entity.LivingEntity.accessoriesCapability()" because "livingEntity" is null
	at top.theillusivec4.curios.mixin.CuriosImplMixinHooks.getCuriosInventory(CuriosImplMixinHooks.java:237) ~[accessories_cclayer-7.4.0-beta.18+1.20.1.jar%23206!/:?]
	at top.theillusivec4.curios.api.CuriosApi.getCuriosInventory(CuriosApi.java:144) ~[accessories_cclayer-7.4.0-beta.18+1.20.1.jar%23206!/:?]
	at com.mna.items.relic.CrystallizedWind.FindOn(CrystallizedWind.java:62) ~[mna-forge-1.20.1-3.1.0.5-all.jar%23230!/:3.1.0.5]
	at com.mna.spells.components.ComponentLevitation.getPermanencyReagents(ComponentLevitation.java:51) ~[mna-forge-1.20.1-3.1.0.5-all.jar%23230!/:3.1.0.5]
	at com.mna.spells.components.PotionEffectComponent.getRequiredReagents(PotionEffectComponent.java:212) ~[mna-forge-1.20.1-3.1.0.5-all.jar%23230!/:3.1.0.5]
	at com.mna.items.sorcery.MagicStaff.lambda$buildRandomSpellStaff$3(MagicStaff.java:342) ~[mna-forge-1.20.1-3.1.0.5-all.jar%23230!/:3.1.0.5]
	at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:178) ~[?:?]
	at java.util.Iterator.forEachRemaining(Iterator.java:133) ~[?:?]
	at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1845) ~[?:?]
	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509) ~[?:?]
	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) ~[?:?]
	at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921) ~[?:?]
	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[?:?]
	at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682) ~[?:?]
	at com.mna.items.sorcery.MagicStaff.buildRandomSpellStaff(MagicStaff.java:346) ~[mna-forge-1.20.1-3.1.0.5-all.jar%23230!/:3.1.0.5]
	at com.mna.loot.RandomSpellStaff.m_7372_(RandomSpellStaff.java:30) ~[mna-forge-1.20.1-3.1.0.5-all.jar%23230!/:3.1.0.5]
	at net.minecraft.world.level.storage.loot.functions.LootItemConditionalFunction.apply(LootItemConditionalFunction.java:31) ~[client-1.20.1-20230612.114412-srg.jar%23248!/:?]
	at net.minecraft.world.level.storage.loot.functions.LootItemConditionalFunction.apply(LootItemConditionalFunction.java:20) ~[client-1.20.1-20230612.114412-srg.jar%23248!/:?]
	at net.minecraft.world.level.storage.loot.functions.LootItemFunction.m_80728_(LootItemFunction.java:14) ~[client-1.20.1-20230612.114412-srg.jar%23248!/:?]
	at net.minecraft.world.level.storage.loot.entries.LootItem.m_6948_(LootItem.java:33) ~[client-1.20.1-20230612.114412-srg.jar%23248!/:?]
	at net.minecraft.world.level.storage.loot.entries.LootPoolSingletonContainer$1.m_6941_(LootPoolSingletonContainer.java:59) ~[client-1.20.1-20230612.114412-srg.jar%23248!/:?]
	at net.minecraft.world.level.storage.loot.LootPool.m_79058_(LootPool.java:72) ~[client-1.20.1-20230612.114412-srg.jar%23248!/:?]
	at net.minecraft.world.level.storage.loot.LootPool.m_79053_(LootPool.java:94) ~[client-1.20.1-20230612.114412-srg.jar%23248!/:?]
	at net.minecraft.world.level.storage.loot.LootTable.m_79131_(LootTable.java:85) ~[client-1.20.1-20230612.114412-srg.jar%23248!/:?]
	at net.minecraft.world.level.storage.loot.LootTable.m_230922_(LootTable.java:117) ~[client-1.20.1-20230612.114412-srg.jar%23248!/:?]
	at net.minecraft.world.level.storage.loot.LootTable.m_287188_(LootTable.java:139) ~[client-1.20.1-20230612.114412-srg.jar%23248!/:?]
	at net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity.m_59640_(RandomizableContainerBlockEntity.java:82) ~[client-1.20.1-20230612.114412-srg.jar%23248!/:?]
	at net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity.m_7208_(RandomizableContainerBlockEntity.java:154) ~[client-1.20.1-20230612.114412-srg.jar%23248!/:?]
	at net.minecraft.server.level.ServerPlayer.m_5893_(ServerPlayer.java:963) ~[client-1.20.1-20230612.114412-srg.jar%23248!/:?]
	at net.minecraft.world.level.block.ChestBlock.m_6227_(ChestBlock.java:236) ~[client-1.20.1-20230612.114412-srg.jar%23248!/:?]
	at net.minecraft.world.level.block.state.BlockBehaviour$BlockStateBase.m_60664_(BlockBehaviour.java:778) ~[client-1.20.1-20230612.114412-srg.jar%23248!/:?]
	at net.minecraft.server.level.ServerPlayerGameMode.m_7179_(ServerPlayerGameMode.java:343) ~[client-1.20.1-20230612.114412-srg.jar%23248!/:?]
	at net.minecraft.server.network.ServerGamePacketListenerImpl.m_6371_(ServerGamePacketListenerImpl.java:1055) ~[client-1.20.1-20230612.114412-srg.jar%23248!/:?]
	at net.minecraft.network.protocol.game.ServerboundUseItemOnPacket.m_5797_(ServerboundUseItemOnPacket.java:34) ~[client-1.20.1-20230612.114412-srg.jar%23248!/:?]
	at net.minecraft.network.protocol.game.ServerboundUseItemOnPacket.m_5797_(ServerboundUseItemOnPacket.java:8) ~[client-1.20.1-20230612.114412-srg.jar%23248!/:?]
	at net.minecraft.network.protocol.PacketUtils.m_263899_(PacketUtils.java:22) ~[client-1.20.1-20230612.114412-srg.jar%23248!/:?]
	at net.minecraft.server.TickTask.run(TickTask.java:18) ~[client-1.20.1-20230612.114412-srg.jar%23248!/:?]
	at net.minecraft.util.thread.BlockableEventLoop.m_6367_(BlockableEventLoop.java:156) ~[client-1.20.1-20230612.114412-srg.jar%23248!/:?]
	at net.minecraft.util.thread.ReentrantBlockableEventLoop.m_6367_(ReentrantBlockableEventLoop.java:23) ~[client-1.20.1-20230612.114412-srg.jar%23248!/:?]
	at net.minecraft.server.MinecraftServer.m_6367_(MinecraftServer.java:770) ~[client-1.20.1-20230612.114412-srg.jar%23248!/:?]
	at net.minecraft.server.MinecraftServer.m_6367_(MinecraftServer.java:161) ~[client-1.20.1-20230612.114412-srg.jar%23248!/:?]
	at net.minecraft.util.thread.BlockableEventLoop.m_7245_(BlockableEventLoop.java:130) ~[client-1.20.1-20230612.114412-srg.jar%23248!/:?]
	at net.minecraft.server.MinecraftServer.m_129961_(MinecraftServer.java:753) ~[client-1.20.1-20230612.114412-srg.jar%23248!/:?]
	at net.minecraft.server.MinecraftServer.m_7245_(MinecraftServer.java:747) ~[client-1.20.1-20230612.114412-srg.jar%23248!/:?]
	at net.minecraft.util.thread.BlockableEventLoop.m_18701_(BlockableEventLoop.java:139) ~[client-1.20.1-20230612.114412-srg.jar%23248!/:?]
	at net.minecraft.server.MinecraftServer.m_130012_(MinecraftServer.java:733) ~[client-1.20.1-20230612.114412-srg.jar%23248!/:?]
	at net.minecraft.server.MinecraftServer.m_130011_(MinecraftServer.java:665) ~[client-1.20.1-20230612.114412-srg.jar%23248!/:?]
	at net.minecraft.server.MinecraftServer.m_206580_(MinecraftServer.java:251) ~[client-1.20.1-20230612.114412-srg.jar%23248!/:?]
	at java.lang.Thread.run(Thread.java:833) ~[?:?]
commented

Sorry to say but support for 1.20.1 has been dropped due to not having the time to properly fix these issues at the this time while balancing other stuff.