Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static boolean canEntityBeSeen(EntityLivingBase entity) {
- float maxSeenBound = 20f;
- 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));
- for(int i = 0; i < entityList.size(); i++) {
- if(entityList.get(i) instanceof EntityMob) {
- EntityMob mobEntity = (EntityMob) entityList.get(i);
- Vec3d entityLookVec = entity.getLook(1.0f).normalize();
- Vec3d distanceVec = new Vec3d(entity.posX - mobEntity.posX, entity.posY - mobEntity.posY, entity.posZ - mobEntity.posZ);
- double d0 = entityLookVec.lengthVector();
- distanceVec = distanceVec.normalize();
- double d1 = entityLookVec.dotProduct(distanceVec);
- if(d1 > 1.0D - 0.025D / d0)
- return mobEntity.canEntityBeSeen(entity);
- }
- }
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement