@Override public boolean shouldExecute() { if (!this.dragon.isStartled() || this.dragon.isTamed()) return false; if (this.avoidClass == EntityPlayer.class && (this.closestLiving = this.dragon.worldObj.getClosestPlayerToEntity(this.dragon, this.reactDist)) == null) return false; else { List<?> list = this.dragon.worldObj.selectEntitiesWithinAABB( this.avoidClass, this.dragon.boundingBox.expand(this.reactDist, this.reactDist * 0.4, this.reactDist), new IEntitySelector() { @Override public boolean isEntityApplicable(Entity e) { return e.isEntityAlive() && EntityAIStartled.this.dragon.getEntitySenses().canSee(e); } }); if (list.isEmpty()) return false; this.closestLiving = (EntityLivingBase) list.get(0); } if (!(this.willRun = this.dragon.getRNG().nextFloat() <= this.attackChance)) return true; Vec3 vec3 = RandomPositionGenerator.findRandomTargetBlockAwayFrom( this.dragon, 16, 7, this.closestLiving.getPosition(1)); if (vec3 == null || this.closestLiving.getDistanceSq(vec3.xCoord, vec3.yCoord, vec3.zCoord) < this.closestLiving.getDistanceSqToEntity(this.dragon)) return false; else { this.entityPathEntity = this.dragon.getNavigator().getPathToXYZ(vec3.xCoord, vec3.yCoord, vec3.zCoord); return this.entityPathEntity == null ? false : this.entityPathEntity.isDestinationSame(vec3); } }