
NullPointerException when using the sunburn ability
mja00 opened this issue ยท 2 comments
It seems that when you're not riding a vehicle the check for a vehicle crashes the game with a NullPointerException. If you're in a boat/horse it doesn't crash.
I've attached the crash report here
I tried out trying to fix it and got
private static boolean isInDaylight(LivingEntity entity)
{
World world = entity.getEntityWorld();
BlockPos position;
Entity ridingEntity = entity.getRidingEntity();
if(world.isDaytime() && !world.isRemote)
{
float light = entity.getBrightness();
if (ridingEntity != null) {
if (ridingEntity.getType() == EntityType.BOAT) {
position = new BlockPos(entity.getPosX(), (double) Math.round(entity.getPosY()), entity.getPosZ()).up();
} else {
position = new BlockPos(entity.getPosX(), (double) Math.round(entity.getPosY()), entity.getPosZ());
}
} else {
position = new BlockPos(entity.getPosX(), (double) Math.round(entity.getPosY()), entity.getPosZ());
}
return light > 0.5F && entity.getRNG().nextFloat() * 30F < (light - 0.4F) * 2F && world.canSeeSky(position);
}
return false;
}