From 44216f12ed39a8cfb4100f03a5d7bc46a52622a6 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Mon, 28 Mar 2016 20:19:29 -0400
Subject: [PATCH] SPIGOT-2033: Re-add missed diff for entity.valid

---
 nms-patches/World.patch | 54 +++++++++++++++++++++++------------------
 1 file changed, 31 insertions(+), 23 deletions(-)

diff --git a/nms-patches/World.patch b/nms-patches/World.patch
index e758b4348b..f2550a5507 100644
--- a/nms-patches/World.patch
+++ b/nms-patches/World.patch
@@ -318,7 +318,15 @@
      }
  
      protected void c(Entity entity) {
-@@ -787,7 +998,15 @@
+@@ -752,6 +963,7 @@
+             ((IWorldAccess) this.u.get(i)).b(entity);
+         }
+ 
++        entity.valid = false; // CraftBukkit
+     }
+ 
+     public void kill(Entity entity) {
+@@ -787,7 +999,15 @@
              this.getChunkAt(i, j).b(entity);
          }
  
@@ -335,7 +343,7 @@
          this.c(entity);
      }
  
-@@ -1039,6 +1258,11 @@
+@@ -1039,6 +1259,11 @@
  
          for (i = 0; i < this.j.size(); ++i) {
              entity = (Entity) this.j.get(i);
@@ -347,7 +355,7 @@
  
              try {
                  ++entity.ticksLived;
-@@ -1087,8 +1311,10 @@
+@@ -1087,8 +1312,10 @@
          CrashReportSystemDetails crashreportsystemdetails1;
          CrashReport crashreport1;
  
@@ -360,7 +368,7 @@
              Entity entity1 = entity.by();
  
              if (entity1 != null) {
-@@ -1121,7 +1347,7 @@
+@@ -1121,7 +1348,7 @@
                      this.getChunkAt(j, l).b(entity);
                  }
  
@@ -369,7 +377,7 @@
                  this.c(entity);
              }
  
-@@ -1130,6 +1356,13 @@
+@@ -1130,6 +1357,13 @@
  
          this.methodProfiler.c("blockEntities");
          this.M = true;
@@ -383,7 +391,7 @@
          Iterator iterator = this.tileEntityListTick.iterator();
  
          while (iterator.hasNext()) {
-@@ -1140,7 +1373,7 @@
+@@ -1140,7 +1374,7 @@
  
                  if (this.isLoaded(blockposition) && this.N.a(blockposition)) {
                      try {
@@ -392,7 +400,7 @@
                          ((ITickable) tileentity).c();
                          this.methodProfiler.b();
                      } catch (Throwable throwable2) {
-@@ -1162,11 +1395,13 @@
+@@ -1162,11 +1396,13 @@
          }
  
          this.M = false;
@@ -406,7 +414,7 @@
  
          this.methodProfiler.c("pendingBlockEntities");
          if (!this.b.isEmpty()) {
-@@ -1174,9 +1409,11 @@
+@@ -1174,9 +1410,11 @@
                  TileEntity tileentity1 = (TileEntity) this.b.get(i1);
  
                  if (!tileentity1.x()) {
@@ -418,7 +426,7 @@
  
                      if (this.isLoaded(tileentity1.getPosition())) {
                          Chunk chunk = this.getChunkAtWorldCoords(tileentity1.getPosition());
-@@ -1184,6 +1421,12 @@
+@@ -1184,6 +1422,12 @@
  
                          chunk.a(tileentity1.getPosition(), tileentity1);
                          this.notify(tileentity1.getPosition(), iblockdata, iblockdata, 3);
@@ -431,7 +439,7 @@
                      }
                  }
              }
-@@ -1231,7 +1474,10 @@
+@@ -1231,7 +1475,10 @@
          int j = MathHelper.floor(entity.locZ);
          byte b0 = 32;
  
@@ -443,7 +451,7 @@
              entity.M = entity.locX;
              entity.N = entity.locY;
              entity.O = entity.locZ;
-@@ -1570,10 +1816,18 @@
+@@ -1570,10 +1817,18 @@
          }
      }
  
@@ -462,7 +470,7 @@
              TileEntity tileentity = null;
              int i;
              TileEntity tileentity1;
-@@ -1608,6 +1862,14 @@
+@@ -1608,6 +1863,14 @@
  
      public void setTileEntity(BlockPosition blockposition, TileEntity tileentity) {
          if (tileentity != null && !tileentity.x()) {
@@ -477,7 +485,7 @@
              if (this.M) {
                  tileentity.a(blockposition);
                  Iterator iterator = this.b.iterator();
-@@ -1762,6 +2024,14 @@
+@@ -1762,6 +2025,14 @@
                  }
  
                  this.o = MathHelper.a(this.o, 0.0F, 1.0F);
@@ -492,7 +500,7 @@
              }
          }
      }
-@@ -1893,7 +2163,10 @@
+@@ -1893,7 +2164,10 @@
      }
  
      public boolean c(EnumSkyBlock enumskyblock, BlockPosition blockposition) {
@@ -504,7 +512,7 @@
              return false;
          } else {
              int i = 0;
-@@ -2058,7 +2331,7 @@
+@@ -2058,7 +2332,7 @@
          while (iterator.hasNext()) {
              Entity entity = (Entity) iterator.next();
  
@@ -513,7 +521,7 @@
                  arraylist.add(entity);
              }
          }
-@@ -2073,7 +2346,7 @@
+@@ -2073,7 +2347,7 @@
          while (iterator.hasNext()) {
              Entity entity = (Entity) iterator.next();
  
@@ -522,7 +530,7 @@
                  arraylist.add(entity);
              }
          }
-@@ -2121,7 +2394,7 @@
+@@ -2121,7 +2395,7 @@
              }
          }
  
@@ -531,7 +539,7 @@
      }
  
      public Entity getEntity(int i) {
-@@ -2141,8 +2414,17 @@
+@@ -2141,8 +2415,17 @@
  
          while (iterator.hasNext()) {
              Entity entity = (Entity) iterator.next();
@@ -551,7 +559,7 @@
                  ++i;
              }
          }
-@@ -2151,12 +2433,18 @@
+@@ -2151,12 +2434,18 @@
      }
  
      public void a(Collection<Entity> collection) {
@@ -571,7 +579,7 @@
              this.b(entity);
          }
  
-@@ -2170,7 +2458,13 @@
+@@ -2170,7 +2459,13 @@
          IBlockData iblockdata = this.getType(blockposition);
          AxisAlignedBB axisalignedbb = flag ? null : block.getBlockData().d(this, blockposition);
  
@@ -586,7 +594,7 @@
      }
  
      public int K() {
-@@ -2270,6 +2564,11 @@
+@@ -2270,6 +2565,11 @@
  
          for (int i = 0; i < this.players.size(); ++i) {
              EntityHuman entityhuman1 = (EntityHuman) this.players.get(i);
@@ -598,7 +606,7 @@
  
              if ((IEntitySelector.d.apply(entityhuman1) || !flag) && (IEntitySelector.e.apply(entityhuman1) || flag)) {
                  double d5 = entityhuman1.e(d0, d1, d2);
-@@ -2433,6 +2732,16 @@
+@@ -2433,6 +2733,16 @@
  
      public void everyoneSleeping() {}
  
@@ -615,7 +623,7 @@
      public float h(float f) {
          return (this.p + (this.q - this.p) * f) * this.j(f);
      }
-@@ -2648,7 +2957,7 @@
+@@ -2648,7 +2958,7 @@
          int l = j * 16 + 8 - blockposition.getZ();
          short short0 = 128;