Luligabi1 / MagicFungi

An original magic mod for the Fabric Loader.
Other
12 stars 2 forks source link

Uncaught NPE in PlayerEntityMixin #59

Closed Linguardium closed 2 years ago

Linguardium commented 2 years ago

https://github.com/Luligabi1/MagicFungi/blob/ee509b6c05ff6ed18d23780409e177e535069b1e/src/main/java/me/luligabi/magicfungi/mixin/PlayerEntityMixin.java#L33

if there is no instance that matches the provided HEALTH_BOOST, then it will be null and the call to getDuration will crash. do a null check

Linguardium commented 2 years ago

if(playerEntity.getActiveStatusEffects().get(StatusEffects.HEALTH_BOOST) instanceof StatusEffectInstanceAccessor instance && instance.getDuration() == 2*20) for instance this will nullcheck and cast all at once (instanceof will nullcheck and on modern java you can create a variable of type automatically in the same line)

Luligabi1 commented 2 years ago

Fixed on 0.7.3-BETA+1.18.2, thanks for reporting 👍🏼