Ensure we actually removed entity from chunk before decrementing counts

If a plugin hacks into NMS and triggers entity removal, it could
result in an entity being attempted to remove from the chunk twice.

The 2nd pass will return false, as it did not find the entity in the list.

We should not touch entity counts if the entity was not removed, to avoid
going negative.
This commit is contained in:
Aikar
2016-04-15 21:31:12 -04:00
parent d42782457e
commit 75eb8243f7
2 changed files with 17 additions and 0 deletions

View File

@@ -120,6 +120,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ return new Location(entity.getWorld().getWorld(), entity.locX, entity.locY, entity.locZ);
+ }
+
+ public static BlockPosition toBlockPosition(Location loc) {
+ return new BlockPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
+ }
+
+ public static boolean isEdgeOfChunk(BlockPosition pos) {
+ final int modX = pos.getX() & 15;
+ final int modZ = pos.getZ() & 15;