From 13a5b12206ab39accf3f6bca5ef62227a85930bf Mon Sep 17 00:00:00 2001
From: md_5 <git@md-5.net>
Date: Thu, 22 Dec 2016 16:50:24 +1100
Subject: [PATCH] SPIGOT-2944: Just apply filtering to players

---
 nms-patches/World.patch | 52 +++++++++++++++++++++--------------------
 1 file changed, 27 insertions(+), 25 deletions(-)

diff --git a/nms-patches/World.patch b/nms-patches/World.patch
index 20c488c1da..c093832c33 100644
--- a/nms-patches/World.patch
+++ b/nms-patches/World.patch
@@ -341,17 +341,19 @@
          this.c(entity);
      }
  
-@@ -872,6 +1095,9 @@
+@@ -872,6 +1095,11 @@
          int l = MathHelper.f(axisalignedbb.e) + 1;
          int i1 = MathHelper.floor(axisalignedbb.c) - 1;
          int j1 = MathHelper.f(axisalignedbb.f) + 1;
 +        // CraftBukkit start - filter out large ranges
-+        com.google.common.base.Preconditions.checkArgument((j - i) * (l - k) * (j1 - i1) <= 32 * 32 * 32, "Filtered out large getCubes call %s,%s %s,%s %s,%s", i, j, k, l, i1, j1);
++        if (entity instanceof EntityPlayer) {
++            com.google.common.base.Preconditions.checkArgument((j - i) * (l - k) * (j1 - i1) <= 32 * 32 * 32, "Filtered out large getCubes call %s,%s %s,%s %s,%s", i, j, k, l, i1, j1);
++        }
 +        // CraftBukkit end
          WorldBorder worldborder = this.getWorldBorder();
          boolean flag1 = entity != null && entity.br();
          boolean flag2 = entity != null && this.g(entity);
-@@ -974,7 +1200,7 @@
+@@ -974,7 +1202,7 @@
      }
  
      public boolean a(AxisAlignedBB axisalignedbb) {
@@ -360,7 +362,7 @@
      }
  
      public int a(float f) {
-@@ -1044,6 +1270,11 @@
+@@ -1044,6 +1272,11 @@
  
          for (i = 0; i < this.j.size(); ++i) {
              entity = (Entity) this.j.get(i);
@@ -372,7 +374,7 @@
  
              try {
                  ++entity.ticksLived;
-@@ -1092,8 +1323,10 @@
+@@ -1092,8 +1325,10 @@
          CrashReportSystemDetails crashreportsystemdetails1;
          CrashReport crashreport1;
  
@@ -385,7 +387,7 @@
              Entity entity1 = entity.bB();
  
              if (entity1 != null) {
-@@ -1126,7 +1359,7 @@
+@@ -1126,7 +1361,7 @@
                      this.getChunkAt(j, l).b(entity);
                  }
  
@@ -394,7 +396,7 @@
                  this.c(entity);
              }
  
-@@ -1135,6 +1368,13 @@
+@@ -1135,6 +1370,13 @@
  
          this.methodProfiler.c("blockEntities");
          this.M = true;
@@ -408,7 +410,7 @@
          Iterator iterator = this.tileEntityListTick.iterator();
  
          while (iterator.hasNext()) {
-@@ -1145,7 +1385,7 @@
+@@ -1145,7 +1387,7 @@
  
                  if (this.isLoaded(blockposition) && this.N.a(blockposition)) {
                      try {
@@ -417,7 +419,7 @@
                          ((ITickable) tileentity).F_();
                          this.methodProfiler.b();
                      } catch (Throwable throwable2) {
-@@ -1167,11 +1407,13 @@
+@@ -1167,11 +1409,13 @@
          }
  
          this.M = false;
@@ -431,7 +433,7 @@
  
          this.methodProfiler.c("pendingBlockEntities");
          if (!this.b.isEmpty()) {
-@@ -1179,9 +1421,11 @@
+@@ -1179,9 +1423,11 @@
                  TileEntity tileentity1 = (TileEntity) this.b.get(i1);
  
                  if (!tileentity1.y()) {
@@ -443,7 +445,7 @@
  
                      if (this.isLoaded(tileentity1.getPosition())) {
                          Chunk chunk = this.getChunkAtWorldCoords(tileentity1.getPosition());
-@@ -1189,6 +1433,12 @@
+@@ -1189,6 +1435,12 @@
  
                          chunk.a(tileentity1.getPosition(), tileentity1);
                          this.notify(tileentity1.getPosition(), iblockdata, iblockdata, 3);
@@ -456,7 +458,7 @@
                      }
                  }
              }
-@@ -1243,7 +1493,10 @@
+@@ -1243,7 +1495,10 @@
          int j = MathHelper.floor(entity.locZ);
          boolean flag1 = true;
  
@@ -468,7 +470,7 @@
              entity.M = entity.locX;
              entity.N = entity.locY;
              entity.O = entity.locZ;
-@@ -1547,11 +1800,18 @@
+@@ -1547,11 +1802,18 @@
          }
      }
  
@@ -487,7 +489,7 @@
              TileEntity tileentity = null;
  
              if (this.M) {
-@@ -1586,6 +1846,14 @@
+@@ -1586,6 +1848,14 @@
      public void setTileEntity(BlockPosition blockposition, @Nullable TileEntity tileentity) {
          if (!this.E(blockposition)) {
              if (tileentity != null && !tileentity.y()) {
@@ -502,7 +504,7 @@
                  if (this.M) {
                      tileentity.setPosition(blockposition);
                      Iterator iterator = this.b.iterator();
-@@ -1745,6 +2013,14 @@
+@@ -1745,6 +2015,14 @@
                  }
  
                  this.o = MathHelper.a(this.o, 0.0F, 1.0F);
@@ -517,7 +519,7 @@
              }
          }
      }
-@@ -1876,7 +2152,10 @@
+@@ -1876,7 +2154,10 @@
      }
  
      public boolean c(EnumSkyBlock enumskyblock, BlockPosition blockposition) {
@@ -529,7 +531,7 @@
              return false;
          } else {
              int i = 0;
-@@ -2043,7 +2322,7 @@
+@@ -2043,7 +2324,7 @@
          while (iterator.hasNext()) {
              Entity entity = (Entity) iterator.next();
  
@@ -538,7 +540,7 @@
                  arraylist.add(entity);
              }
          }
-@@ -2058,7 +2337,7 @@
+@@ -2058,7 +2339,7 @@
          while (iterator.hasNext()) {
              Entity entity = (Entity) iterator.next();
  
@@ -547,7 +549,7 @@
                  arraylist.add(entity);
              }
          }
-@@ -2107,7 +2386,7 @@
+@@ -2107,7 +2388,7 @@
              }
          }
  
@@ -556,7 +558,7 @@
      }
  
      @Nullable
-@@ -2128,8 +2407,17 @@
+@@ -2128,8 +2409,17 @@
  
          while (iterator.hasNext()) {
              Entity entity = (Entity) iterator.next();
@@ -576,7 +578,7 @@
                  ++i;
              }
          }
-@@ -2138,12 +2426,18 @@
+@@ -2138,12 +2428,18 @@
      }
  
      public void a(Collection<Entity> collection) {
@@ -596,7 +598,7 @@
              this.b(entity);
          }
  
-@@ -2157,7 +2451,13 @@
+@@ -2157,7 +2453,13 @@
          IBlockData iblockdata = this.getType(blockposition);
          AxisAlignedBB axisalignedbb = flag ? null : block.getBlockData().c(this, blockposition);
  
@@ -611,7 +613,7 @@
      }
  
      public int K() {
-@@ -2267,6 +2567,11 @@
+@@ -2267,6 +2569,11 @@
  
          for (int i = 0; i < this.players.size(); ++i) {
              EntityHuman entityhuman1 = (EntityHuman) this.players.get(i);
@@ -623,7 +625,7 @@
  
              if (predicate.apply(entityhuman1)) {
                  double d5 = entityhuman1.d(d0, d1, d2);
-@@ -2435,6 +2740,16 @@
+@@ -2435,6 +2742,16 @@
  
      public void everyoneSleeping() {}
  
@@ -640,7 +642,7 @@
      public float h(float f) {
          return (this.p + (this.q - this.p) * f) * this.j(f);
      }
-@@ -2652,7 +2967,7 @@
+@@ -2652,7 +2969,7 @@
          int l = j * 16 + 8 - blockposition.getZ();
          boolean flag = true;