Curios API Continuation [Frozen]

Curios API Continuation [Frozen]

2M Downloads

[1.21 NeoForge] Accessing curios inventory during `canEquip` cause infinite recursion

lcy0x1 opened this issue ยท 3 comments

commented
	at java.base/java.util.Optional.ifPresent(Optional.java:178) ~[?:?] {re:mixin}
	at TRANSFORMER/[email protected]+1.21/top.theillusivec4.curios.common.capability.CurioInventory.init(CurioInventory.java:88) ~[curios-neoforge-9.0.11+1.21.jar%23205!/:9.0.11+1.21] {re:classloading}
	at TRANSFORMER/[email protected]+1.21/top.theillusivec4.curios.common.capability.CurioInventoryCapability.reset(CurioInventoryCapability.java:73) ~[curios-neoforge-9.0.11+1.21.jar%23205!/:9.0.11+1.21] {re:classloading}
	at TRANSFORMER/[email protected]+1.21/top.theillusivec4.curios.common.capability.CurioInventoryCapability.<init>(CurioInventoryCapability.java:67) ~[curios-neoforge-9.0.11+1.21.jar%23205!/:9.0.11+1.21] {re:classloading}
	at TRANSFORMER/[email protected]+1.21/top.theillusivec4.curios.Curios.lambda$registerCaps$1(Curios.java:135) ~[curios-neoforge-9.0.11+1.21.jar%23205!/:9.0.11+1.21] {re:classloading}
	at TRANSFORMER/[email protected]/net.neoforged.neoforge.capabilities.EntityCapability.getCapability(EntityCapability.java:101) ~[neoforge-21.1.61.jar%23183!/:?] {re:classloading}
	at TRANSFORMER/[email protected]/net.minecraft.world.entity.Entity.getCapability(Entity.java:3800) ~[neoforge-21.1.61.jar%23182!/:?] {re:mixin,pl:accesstransformer:B,re:computing_frames,pl:accesstransformer:B,re:classloading,pl:accesstransformer:B,pl:mixin:APP:l2complements.mixins.json:EntityMixin from mod l2complements,pl:mixin:APP:curios.mixins.json:AccessorEntity from mod curios,pl:mixin:APP:l2library.mixins.json:EntityMixin from mod l2library,pl:mixin:APP:glimmeringtales.mixins.json:EntityMixin from mod glimmeringtales,pl:mixin:A}
	at TRANSFORMER/[email protected]+1.21/top.theillusivec4.curios.mixin.CuriosImplMixinHooks.getCuriosInventory(CuriosImplMixinHooks.java:117) ~[curios-neoforge-9.0.11+1.21.jar%23205!/:9.0.11+1.21] {re:mixin,re:classloading}
	at TRANSFORMER/[email protected]+1.21/top.theillusivec4.curios.api.CuriosApi.handler$zce000$curios$getCuriosInventory(CuriosApi.java:665) ~[curios-neoforge-9.0.11+1.21.jar%23205!/:9.0.11+1.21] {re:mixin,re:classloading,pl:mixin:A}
	at TRANSFORMER/[email protected]+1.21/top.theillusivec4.curios.api.CuriosApi.getCuriosInventory(CuriosApi.java) ~[curios-neoforge-9.0.11+1.21.jar%23205!/:9.0.11+1.21] {re:mixin,re:classloading,pl:mixin:A}
	at TRANSFORMER/[email protected]+10/dev.xkmc.glimmeringtales.content.item.curio.GTCurioItem.canEquip(GTCurioItem.java:22) ~[%23184!/:?] {re:classloading}
	at TRANSFORMER/[email protected]+1.21/top.theillusivec4.curios.common.capability.ItemizedCurioCapability.canEquip(ItemizedCurioCapability.java:62) ~[curios-neoforge-9.0.11+1.21.jar%23205!/:9.0.11+1.21] {re:classloading}
	at TRANSFORMER/[email protected]+1.21/top.theillusivec4.curios.common.inventory.DynamicStackHandler.lambda$isItemValid$0(DynamicStackHandler.java:76) ~[curios-neoforge-9.0.11+1.21.jar%23205!/:9.0.11+1.21] {re:classloading}
	at java.base/java.util.Optional.map(Optional.java:260) ~[?:?] {re:mixin}

I have an curio that can only have 1 equipped. I do so by checking if there are any other curios of this type equipped already. It cause crash when entering the world again.

commented

The message above is a scam, do not download the file!!! @SSKirillSS fyi

commented

This issue also seems to be the root of #18 here and an issue in one of my repositories (AnonymousHacker1279/IWCompatibilityBridge#19). Interestingly enough both of us are trying to do the same thing for our curios; my event handler also prevents multiple curios of the same type from being equipped.

The event handler can be found here, and infinite recursion occurs when calling CuriosApi#getCuriosInventory(). I have discovered that the Adorned fork of Curios does not seem to cause stack overflows in this scenario.

commented

Should be fixed since 9.0.14