Magic Fungi

Magic Fungi

1M Downloads

Uncaught NPE in PlayerEntityMixin

Linguardium opened this issue ยท 2 comments

commented

if(((StatusEffectInstanceAccessor) playerEntity.getActiveStatusEffects().get(StatusEffects.HEALTH_BOOST)).getDuration() == 2*20) {

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

commented

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)

commented

Fixed on 0.7.3-BETA+1.18.2, thanks for reporting ๐Ÿ‘๐Ÿผ