Advertisement
Guest User

Untitled

a guest
Jul 4th, 2015
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.27 KB | None | 0 0
  1. //Inside org.bukkit.craftbukkit.entity.CraftEntity
  2. public List<org.bukkit.entity.Entity> getNearbyEntities(double x, double y, double z)
  3.   {
  4.     List<net.minecraft.server.v1_8_R2.Entity> notchEntityList = this.entity.world.getEntities(this.entity, this.entity.getBoundingBox().grow(x, y, z);
  5.     List<org.bukkit.entity.Entity> bukkitEntityList = new ArrayList(notchEntityList.size());
  6.     for (net.minecraft.server.v1_8_R2.Entity e : notchEntityList) {
  7.       bukkitEntityList.add(e.getBukkitEntity());
  8.     }
  9.     return bukkitEntityList;
  10.   }
  11.  
  12. //Inside net.minecraft.server.World
  13.   public List<Entity> getEntities(Entity entity, AxisAlignedBB axisalignedbb)
  14.   {
  15.     return a(entity, axisalignedbb, IEntitySelector.d);
  16.   }
  17.   public List<Entity> a(Entity entity, AxisAlignedBB axisalignedbb, Predicate<? super Entity> predicate)
  18.   {
  19.     ArrayList arraylist = Lists.newArrayList();
  20.     int i = MathHelper.floor((axisalignedbb.a - 2.0D) / 16.0D);
  21.     int j = MathHelper.floor((axisalignedbb.d + 2.0D) / 16.0D);
  22.     int k = MathHelper.floor((axisalignedbb.c - 2.0D) / 16.0D);
  23.     int l = MathHelper.floor((axisalignedbb.f + 2.0D) / 16.0D);
  24.     if ((j - i > 10) || (l - k > 10))
  25.     {
  26.       getServer().getLogger().log(Level.WARNING, "Filtered out large getEntities call {0},{1} {2},{3}", new Object[] { Integer.valueOf(i), Integer.valueOf(j), Integer.valueOf(k), Integer.valueOf(j) });
  27.       return arraylist;
  28.     }
  29.     for (int i1 = i; i1 <= j; i1++) {
  30.       for (int j1 = k; j1 <= l; j1++) {
  31.         if (isChunkLoaded(i1, j1, true)) { //Look, it iterates over all chunks in the world, much faster than getting the world's entities :)
  32.           getChunkAt(i1, j1).a(entity, axisalignedbb, arraylist, predicate);
  33.         }
  34.       }
  35.     }
  36.     return arraylist;
  37.   }
  38. //Inside net.minecraft.server.Chunk
  39.   public void a(Entity entity, AxisAlignedBB axisalignedbb, List<Entity> list, Predicate<? super Entity> predicate)
  40.   {
  41.     int i = MathHelper.floor((axisalignedbb.b - 2.0D) / 16.0D);
  42.     int j = MathHelper.floor((axisalignedbb.e + 2.0D) / 16.0D);
  43.    
  44.     i = MathHelper.clamp(i, 0, this.entitySlices.length - 1);
  45.     j = MathHelper.clamp(j, 0, this.entitySlices.length - 1);
  46.     for (int k = i; k <= j; k++) {
  47.       if (!this.entitySlices[k].isEmpty())
  48.       {
  49.         Iterator iterator = this.entitySlices[k].iterator(); //Why look at this, it iterates over ALL entities, on EVERY chunk in the world. So what's it doing? Exactly the same as iterating over the world's entities! Good job! You talked total nonsense
  50.         while (iterator.hasNext())
  51.         {
  52.           Entity entity1 = (Entity)iterator.next();
  53.           if ((entity1.getBoundingBox().b(axisalignedbb)) && (entity1 != entity))
  54.           {
  55.             if ((predicate == null) || (predicate.apply(entity1))) {
  56.               list.add(entity1);
  57.             }
  58.             Entity[] aentity = entity1.aB();
  59.             if (aentity != null) {
  60.               for (int l = 0; l < aentity.length; l++)
  61.               {
  62.                 entity1 = aentity[l];
  63.                 if ((entity1 != entity) && (entity1.getBoundingBox().b(axisalignedbb)) && ((predicate == null) || (predicate.apply(entity1)))) {
  64.                   list.add(entity1);
  65.                 }
  66.               }
  67.             }
  68.           }
  69.         }
  70.       }
  71.     }
  72.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement