Coders-After-Dark / Reskillable

Other
7 stars 17 forks source link

PlayerDataHandler may throw NullPointerException #181

Closed Charnuz closed 4 years ago

Charnuz commented 4 years ago

https://github.com/Coders-After-Dark/Reskillable/blob/58d6b434d163c9e80432a6be4b3998233c8afc65/src/main/java/codersafterdark/reskillable/api/data/PlayerDataHandler.java#L39 Related to #175, either data and/or playerWR may be null.

Changing it to be: if (data !=null && data.playerWR != null && data.playerWR.get() != player) { would fix this. If PlayerData.get() cannot ever return null then the first null check is not needed.

crash-2019-11-03_08.56.11-client.txt

pupnewfster commented 4 years ago

The first check would not be needed because if it is not already contained it gets added a few lines up. I am not to sure about how WeakReferences work but I believe the data.playerWR should never be null either (though data.playerWR.get() might be able to be null). Though my best guess is that some other mod (some mods that are known to screw with vanilla logic: optifine, vanilllafix), is force clearing the weak references instead of letting java handle them as they expect to. I believe with vanilla fix this can be disabled by changing the "Optimizations and vanilla bug fixes" to false in their config. Given I see that you do have VanillaFix I would recommend trying that (or trying without vanillafix installed at all) and seeing if it fixes the issue. If it does I would recommend reporting the bug to them.

Charnuz commented 4 years ago

Will do some testing to see if I can replicate the issue with vanillafix bug fixes off or disabled in general.