Advertisement
Guest User

Untitled

a guest
Apr 28th, 2016
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. public static boolean canEntityBeSeen(EntityLivingBase entity) {
  2. float maxSeenBound = 20f;
  3. List<Entity> entityList = entity.worldObj.getEntitiesWithinAABBExcludingEntity(entity, new AxisAlignedBB(entity.posX - maxSeenBound, entity.posY, entity.posZ - maxSeenBound, entity.posX + maxSeenBound, entity.posY + maxSeenBound, entity.posZ + maxSeenBound));
  4.  
  5. for(int i = 0; i < entityList.size(); i++) {
  6. if(entityList.get(i) instanceof EntityMob) {
  7. EntityMob mobEntity = (EntityMob) entityList.get(i);
  8. Vec3d entityLookVec = entity.getLook(1.0f).normalize();
  9. Vec3d distanceVec = new Vec3d(entity.posX - mobEntity.posX, entity.posY - mobEntity.posY, entity.posZ - mobEntity.posZ);
  10. double d0 = entityLookVec.lengthVector();
  11. distanceVec = distanceVec.normalize();
  12. double d1 = entityLookVec.dotProduct(distanceVec);
  13.  
  14. return d1 > 1.0D - 0.025D / d0 ? mobEntity.canEntityBeSeen(entity) : false;
  15. }
  16. }
  17.  
  18. return false;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement