mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-23 09:27:45 +01:00
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:
parent
8672653871
commit
845090e570
@ -1,4 +1,4 @@
|
||||
From c3b8ab1a653c005db884e9393ddcf82f0e71a73e Mon Sep 17 00:00:00 2001
|
||||
From a3092ca4d2f76ef79198b6011d380dadd4d5d601 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Mon, 28 Mar 2016 20:55:47 -0400
|
||||
Subject: [PATCH] MC Utils
|
||||
@ -7,10 +7,10 @@ Collection of utils to help reduce NMS diff
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/MCUtil.java b/src/main/java/net/minecraft/server/MCUtil.java
|
||||
new file mode 100644
|
||||
index 0000000..349f2fc
|
||||
index 0000000..ffd3152
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/net/minecraft/server/MCUtil.java
|
||||
@@ -0,0 +1,115 @@
|
||||
@@ -0,0 +1,119 @@
|
||||
+package net.minecraft.server;
|
||||
+
|
||||
+import org.bukkit.Location;
|
||||
@ -120,6 +120,10 @@ index 0000000..349f2fc
|
||||
+ 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;
|
||||
|
@ -1,4 +1,4 @@
|
||||
From 8ff5e997fd6df8487be017803e257e0b664e4886 Mon Sep 17 00:00:00 2001
|
||||
From e4e4bb6ea35b2bf711d57c1f9f694c366a6fa105 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Thu, 14 Apr 2016 21:01:39 -0400
|
||||
Subject: [PATCH] Fix Bugs with Spigot Mob Spawn Logic
|
||||
@ -13,6 +13,19 @@ Specially with servers using smaller mob spawn ranges than view distance, as wel
|
||||
|
||||
This patch returns mob counting to use all loaded chunks, and 17x17 division.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
|
||||
index 9334a0a..5c1685d 100644
|
||||
--- a/src/main/java/net/minecraft/server/Chunk.java
|
||||
+++ b/src/main/java/net/minecraft/server/Chunk.java
|
||||
@@ -704,7 +704,7 @@ public class Chunk {
|
||||
i = this.entitySlices.length - 1;
|
||||
}
|
||||
|
||||
- this.entitySlices[i].remove(entity);
|
||||
+ if (!this.entitySlices[i].remove(entity)) { return; } // Paper
|
||||
// Paper start - update counts
|
||||
if (entity instanceof EntityItem) {
|
||||
itemCounts[i]--;
|
||||
diff --git a/src/main/java/net/minecraft/server/SpawnerCreature.java b/src/main/java/net/minecraft/server/SpawnerCreature.java
|
||||
index 15a0ce9..b47feb2 100644
|
||||
--- a/src/main/java/net/minecraft/server/SpawnerCreature.java
|
||||
|
Loading…
Reference in New Issue
Block a user