Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Inside org.bukkit.craftbukkit.entity.CraftEntity
- public List<org.bukkit.entity.Entity> getNearbyEntities(double x, double y, double z)
- {
- List<net.minecraft.server.v1_8_R2.Entity> notchEntityList = this.entity.world.getEntities(this.entity, this.entity.getBoundingBox().grow(x, y, z);
- List<org.bukkit.entity.Entity> bukkitEntityList = new ArrayList(notchEntityList.size());
- for (net.minecraft.server.v1_8_R2.Entity e : notchEntityList) {
- bukkitEntityList.add(e.getBukkitEntity());
- }
- return bukkitEntityList;
- }
- //Inside net.minecraft.server.World
- public List<Entity> getEntities(Entity entity, AxisAlignedBB axisalignedbb)
- {
- return a(entity, axisalignedbb, IEntitySelector.d);
- }
- public List<Entity> a(Entity entity, AxisAlignedBB axisalignedbb, Predicate<? super Entity> predicate)
- {
- ArrayList arraylist = Lists.newArrayList();
- int i = MathHelper.floor((axisalignedbb.a - 2.0D) / 16.0D);
- int j = MathHelper.floor((axisalignedbb.d + 2.0D) / 16.0D);
- int k = MathHelper.floor((axisalignedbb.c - 2.0D) / 16.0D);
- int l = MathHelper.floor((axisalignedbb.f + 2.0D) / 16.0D);
- if ((j - i > 10) || (l - k > 10))
- {
- 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) });
- return arraylist;
- }
- for (int i1 = i; i1 <= j; i1++) {
- for (int j1 = k; j1 <= l; j1++) {
- if (isChunkLoaded(i1, j1, true)) { //Look, it iterates over all chunks in the world, much faster than getting the world's entities :)
- getChunkAt(i1, j1).a(entity, axisalignedbb, arraylist, predicate);
- }
- }
- }
- return arraylist;
- }
- //Inside net.minecraft.server.Chunk
- public void a(Entity entity, AxisAlignedBB axisalignedbb, List<Entity> list, Predicate<? super Entity> predicate)
- {
- int i = MathHelper.floor((axisalignedbb.b - 2.0D) / 16.0D);
- int j = MathHelper.floor((axisalignedbb.e + 2.0D) / 16.0D);
- i = MathHelper.clamp(i, 0, this.entitySlices.length - 1);
- j = MathHelper.clamp(j, 0, this.entitySlices.length - 1);
- for (int k = i; k <= j; k++) {
- if (!this.entitySlices[k].isEmpty())
- {
- 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
- while (iterator.hasNext())
- {
- Entity entity1 = (Entity)iterator.next();
- if ((entity1.getBoundingBox().b(axisalignedbb)) && (entity1 != entity))
- {
- if ((predicate == null) || (predicate.apply(entity1))) {
- list.add(entity1);
- }
- Entity[] aentity = entity1.aB();
- if (aentity != null) {
- for (int l = 0; l < aentity.length; l++)
- {
- entity1 = aentity[l];
- if ((entity1 != entity) && (entity1.getBoundingBox().b(axisalignedbb)) && ((predicate == null) || (predicate.apply(entity1)))) {
- list.add(entity1);
- }
- }
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement