2016-05-16 00:48:39 +02:00
|
|
|
From 96f6ebe5e1b8a63789ffffb307ef1cf856c434de Mon Sep 17 00:00:00 2001
|
2016-04-23 03:35:24 +02: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-05-16 00:48:39 +02:00
|
|
|
index b94cdad..904141a 100644
|
2016-04-23 03:35:24 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/Chunk.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/Chunk.java
|
2016-05-16 00:48:39 +02:00
|
|
|
@@ -631,12 +631,36 @@ public class Chunk {
|
2016-04-23 03:35:24 +02:00
|
|
|
k = this.entitySlices.length - 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
+ // Paper start - Try to catch plugins doing indecent things
|
2016-04-23 18:27:46 +02:00
|
|
|
+ boolean ignoreAdd = false;
|
2016-04-23 19:10:55 +02:00
|
|
|
+ if (entity.aa && entity.getChunkX() == this.locX && entity.getChunkY() == k && entity.getChunkZ() == this.locZ) {
|
2016-04-23 17:57:39 +02:00
|
|
|
+ String chunkName = entity.getWorld().getWorld().getName() + ":" + entity.getChunkX() + "," + entity.getChunkY() + "," + entity.getChunkZ();
|
2016-04-23 19:10:55 +02:00
|
|
|
+ if (this.entitySlices[k].contains(entity)) {
|
2016-04-23 18:27:46 +02:00
|
|
|
+ new Throwable("Double Chunk Add to: " + chunkName).printStackTrace();
|
|
|
|
+ ignoreAdd = true;
|
2016-04-23 17:57:39 +02:00
|
|
|
+ } else {
|
2016-04-23 18:27:46 +02:00
|
|
|
+ boolean found = false;
|
2016-04-23 17:57:39 +02:00
|
|
|
+ for (int i1 = 0; i1 < this.entitySlices.length; i1++) {
|
|
|
|
+ if (this.entitySlices[i1].contains(entity)) {
|
2016-04-23 18:27:46 +02:00
|
|
|
+ new Throwable("Entity was found in another slice of this chunk, tried: " + k + ", was in: " + chunkName).printStackTrace();
|
|
|
|
+ found = true;
|
|
|
|
+ ignoreAdd = true;
|
2016-04-23 17:57:39 +02:00
|
|
|
+ }
|
|
|
|
+ }
|
2016-04-23 18:27:46 +02:00
|
|
|
+ if (!found) {
|
|
|
|
+ new Throwable("Improperly detected double chunk add. Was not actually in this chunk.").printStackTrace();
|
|
|
|
+ }
|
2016-04-23 17:57:39 +02:00
|
|
|
+ }
|
2016-04-23 03:35:24 +02:00
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
+
|
|
|
|
entity.aa = true;
|
|
|
|
entity.ab = this.locX;
|
|
|
|
entity.ac = k;
|
2016-04-23 18:27:46 +02:00
|
|
|
entity.ad = this.locZ;
|
|
|
|
this.entitySlices[k].add(entity);
|
|
|
|
// Paper start - update count
|
|
|
|
+ if (ignoreAdd) return;
|
|
|
|
if (entity instanceof EntityItem) {
|
|
|
|
itemCounts[k]++;
|
|
|
|
} else if (entity instanceof IInventory) {
|
2016-05-16 00:48:39 +02:00
|
|
|
@@ -681,6 +705,7 @@ public class Chunk {
|
2016-04-23 03:35:24 +02: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 18:27:46 +02:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
|
2016-05-16 00:48:39 +02:00
|
|
|
index b3dd456..5c3e075 100644
|
2016-04-23 18:27:46 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/World.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/World.java
|
2016-05-16 00:48:39 +02:00
|
|
|
@@ -1739,7 +1739,7 @@ public abstract class World implements IBlockAccess {
|
2016-04-23 18:27:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
int k = MathHelper.floor(entity.locX / 16.0D);
|
|
|
|
- int l = MathHelper.floor(entity.locY / 16.0D);
|
|
|
|
+ int l = Math.min(15, Math.max(0, MathHelper.floor(entity.locY / 16.0D))); // Paper - stay consistent with chunk add/remove behavior
|
|
|
|
int i1 = MathHelper.floor(entity.locZ / 16.0D);
|
|
|
|
|
|
|
|
if (!entity.aa || entity.ab != k || entity.ac != l || entity.ad != i1) {
|
2016-04-23 03:35:24 +02:00
|
|
|
--
|
2016-05-12 04:07:46 +02:00
|
|
|
2.8.2
|
2016-04-23 03:35:24 +02:00
|
|
|
|