2016-04-23 15:57:39 +00:00
|
|
|
From 7fb729ea5b3d71930bb208d8fc8156c0bae02f1f Mon Sep 17 00:00:00 2001
|
2016-04-23 01:35:24 +00:00
|
|
|
From: Zach Brown <zach.brown@destroystokyo.com>
|
|
|
|
Date: Fri, 22 Apr 2016 20:34:21 -0500
|
|
|
|
Subject: [PATCH] Check entity count additions and mark entities removed
|
|
|
|
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
|
2016-04-23 15:57:39 +00:00
|
|
|
index 5c1685d..137cbc6 100644
|
2016-04-23 01:35:24 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/Chunk.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/Chunk.java
|
2016-04-23 15:57:39 +00:00
|
|
|
@@ -661,6 +661,25 @@ public class Chunk {
|
2016-04-23 01:35:24 +00:00
|
|
|
k = this.entitySlices.length - 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
+ // Paper start - Try to catch plugins doing indecent things
|
2016-04-23 15:57:39 +00:00
|
|
|
+ if (entity.aa) {
|
|
|
|
+ boolean thisChunk = entity.getChunkX() == this.locX && entity.getChunkY() == k && entity.getChunkZ() == this.locZ;
|
|
|
|
+ String chunkName = entity.getWorld().getWorld().getName() + ":" + entity.getChunkX() + "," + entity.getChunkY() + "," + entity.getChunkZ();
|
|
|
|
+ if (!thisChunk) {
|
|
|
|
+ throw new IllegalStateException("Entity Already in another chunk: " + chunkName);
|
|
|
|
+ } else if (this.entitySlices[k].contains(entity)) {
|
|
|
|
+ throw new IllegalStateException("Double Chunk Add to: " + chunkName);
|
|
|
|
+ } else {
|
|
|
|
+ for (int i1 = 0; i1 < this.entitySlices.length; i1++) {
|
|
|
|
+ if (this.entitySlices[i1].contains(entity)) {
|
|
|
|
+ throw new IllegalStateException("Entity was found in another slice of this chunk, tried: " + k + ", was in: " + chunkName);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ new Throwable("Improperly detected double chunk add. Was not actually in this chunk.").printStackTrace();
|
|
|
|
+ }
|
2016-04-23 01:35:24 +00:00
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
+
|
|
|
|
entity.aa = true;
|
|
|
|
entity.ab = this.locX;
|
|
|
|
entity.ac = k;
|
2016-04-23 15:57:39 +00:00
|
|
|
@@ -711,6 +730,7 @@ public class Chunk {
|
2016-04-23 01:35:24 +00:00
|
|
|
} else if (entity instanceof IInventory) {
|
|
|
|
inventoryEntityCounts[i]--;
|
|
|
|
}
|
|
|
|
+ entity.aa = false; // You aren't added to chunk anymore
|
|
|
|
// Paper end
|
|
|
|
// Spigot start - decrement creature type count
|
|
|
|
// Keep this synced up with World.a(Class)
|
|
|
|
--
|
2016-04-23 15:57:39 +00:00
|
|
|
2.8.1
|
2016-04-23 01:35:24 +00:00
|
|
|
|