Curios API (Forge/NeoForge)

Curios API (Forge/NeoForge)

140M Downloads

Curios are not dropped on death

williewillus opened this issue ยท 2 comments

commented

Versions (Be specific, do not write "latest"):

  • Curios: 5.0.6.3
  • Forge/Fabric: Forge

Observed Behavior:

Curios are not dropped on death, even when keepInventory is false and in the absence of custom drop rules

Expected Behavior:

Curios are dropped

Steps to Reproduce:

Reproducible by equipping a ring of magnetization from Botania and doing /kill, after respawning the ring is still present

Suspected cause:

The code responsible for this lives at https://github.com/TheIllusiveC4/Curios/blob/1.18.x/src/main/java/top/theillusivec4/curios/common/event/CuriosEventHandler.java#L267

However, during firing of LivingDropsEvent, the player is already dead, and forge (unhelpfully) hides all capabilities of dead players, so that ifPresent will never run the inner logic.

The "workaround" is that you are supposed to revive the player capabilities, then re-invalidate them after you're done looking. It's quite terrible.

We had to work around this in Botania ourselves, see here: https://github.com/VazkiiMods/Botania/blob/1.18.x/Forge/src/main/java/vazkii/botania/forge/xplat/ForgeXplatImpl.java#L306-L313

commented

However, during firing of LivingDropsEvent, the player is already dead, and forge (unhelpfully) hides all capabilities of dead players, so that ifPresent will never run the inner logic.

Are you sure about this? Perhaps I'm missing something, but that's not the behavior I'm seeing in my testing. Using the items in the Curios test mod with just Curios installed, the items drop appropriate to their defined behaviors. I also tested it with some actual Curios mods, namely Curious Elytra and Artifacts, where the drop behavior worked as well.

I couldn't be sure if this was being affected by some other logic in Curios so I also tested this with a new, blank mod. Setting up a capability and calling ifPresent in a LivingDropsEvent listener does fire the inner logic.

commented

Ah, figured it out, Botania was getting into a situation where I called invalidateCaps too early by accident, which prevented all downstream event handlers from seeing caps. Sorry for the noise.