Reduce the chances of there being a NPE here

This commit is contained in:
Sollace 2021-02-26 13:41:19 +02:00
parent c2a959f031
commit 42670af93b

View file

@ -146,16 +146,16 @@ public class EntityPhysics<T extends Owned<? extends Entity>> implements Physics
if (master instanceof LivingEntity) {
if (((LivingEntity)master).isSleeping()) {
return 1;
}
if (((LivingEntity)master).getAttributes() == null) {
// may be null due to order of execution in the constructor.
// Will have the default (1) here in any case, so it's safe to ignore the attribute at this point.
return getBaseGravityModifier();
}
if (((LivingEntity)master).isSleeping()) {
return 1;
}
return getBaseGravityModifier() * (float)((LivingEntity)master).getAttributeValue(PlayerAttributes.ENTITY_GRAVTY_MODIFIER);
}