sinkillerj / ProjectE

ProjectE. A complete rewrite of EE2 for modern Minecraft versions.
MIT License
394 stars 203 forks source link

ProjectEAPI.getTransmutationProxy().getKnowledgeProviderFor() can throw NPE following player death #2239

Closed desht closed 1 year ago

desht commented 1 year ago

Tickets that do not conform to this template will be closed without comment

Exact ProjectE version (do not say "latest", "latest on Curse", or similar): 1.18.2-PE1.0.1

Exact Forge version: 1.18.2-40.1.73

Link to crash log (please use a paste site, do not attach the .txt or paste the log inline): https://gist.github.com/desht/9cdf296a20b3cd1f19531c6f1ce2160e

Steps to reproduce:

  1. (Note - testing with in-dev code so reproducing will be difficult)
  2. Set up a ProjectEX link block, and add items to the output (filter) slots
  3. Put a Refined Storage storage bus on the link block
  4. Get your player killed!

What I expected to happen:

Not to crash

What happened instead:

The getKnowledgeProviderFor() method crashed, since the player's IKnowledgeProvider capability was briefly missing following the player's death. My guess is that the Refined Storage per-tick polling of the link block's item handler happened between the player being cloned after death, and the knowledge provider capability being re-attached.

I'm not sure about the best way to go about handling this; right now your API method just throws an NPE, and catching that does work around the problem (the link block will briefly report no items available). But that's not a pretty solution.

Just to note, this is in code I'm currently porting from 1.12.2; the ProjectEX link blocks allow a set of items to be added to a filter, and presents those items to item handler capability queries, allowing extraction at a cost of a player's personal EMC. It needs to know the owning player's EMC to determine how many virtual items are available via the link block.

sinkillerj commented 1 year ago

We want nothing to do with ProjectEX now, or in the future, this should be clear by now. You use the mod at your own risk.