Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-11-15 20:40:07 +01:00
2a2d9fb508
1) Removed "Regen" mode of Dupe UUID resolver, forced safe. Some servers who updated before we had safe mode added still had this value. There's really no reason to keep this mode, as we've seen that vanilla triggers this often and 99.9999999% of cases will be an actual duplicate that needs to be deleted. 2) Made Vanilla Debug messages about dupe UUIDs and dupe uuid resolve messages only show up if the debug.entities flag is on. This will stop server owners from panicing from seeing these logs, and stop opening bug reports on this, only for us to tell you "don't worry about it". 3) Avoid adding entities to world that are already added to world. This can be triggered by anything that causes an entity to be added to the world during the chunk load process, such as chunk conversions. Issue #1544 was a case of this. 4) Removed debug warning about ExpiringMap. Nothing more I know to do about this anyways. We recover from it, stop warning to reduce noise of issues to us.
86 Zeilen
4.1 KiB
Diff
86 Zeilen
4.1 KiB
Diff
From 9bfc6b4bd66887fbc5b2641994f87db64f1ed69a Mon Sep 17 00:00:00 2001
|
|
From: Aikar <aikar@aikar.co>
|
|
Date: Fri, 3 Aug 2018 22:47:46 -0400
|
|
Subject: [PATCH] Entity add to world fixes
|
|
|
|
1) Chunk Registration might kill an entity, don't add it to the world if it did!
|
|
|
|
2) By default, entities are added to the world per slice iteration.
|
|
This opens risk of the slices being manipulated during chunk add if an
|
|
EntityAddToWorldEvent spawns an entity into this chunk.
|
|
Fix this by differing entity add to world for all entities at the same time
|
|
|
|
3) If a duplicate entity is attempted to add to the world of an entity, and
|
|
the original entity is dead, overwrite it as the logic does for unloaod queued entities.
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
|
|
index 0f79ad9588..a5f939f557 100644
|
|
--- a/src/main/java/net/minecraft/server/Chunk.java
|
|
+++ b/src/main/java/net/minecraft/server/Chunk.java
|
|
@@ -910,6 +910,7 @@ public class Chunk implements IChunkAccess {
|
|
this.world.a(this.tileEntities.values());
|
|
List[] aentityslice = this.entitySlices; // Spigot
|
|
int i = aentityslice.length;
|
|
+ List<Entity> toAdd = new java.util.ArrayList<>(32); // Paper
|
|
|
|
for (int j = 0; j < i; ++j) {
|
|
List entityslice = aentityslice[j]; // Spigot
|
|
@@ -956,12 +957,11 @@ public class Chunk implements IChunkAccess {
|
|
thisChunk.put(entity.uniqueID, entity);
|
|
}
|
|
}
|
|
- // Paper end
|
|
|
|
- this.world.a(entityslice.stream().filter((entity) -> {
|
|
- return !(entity instanceof EntityHuman);
|
|
- }));
|
|
+ toAdd.addAll(entityslice);
|
|
+ // Paper end
|
|
}
|
|
+ this.world.addChunkEntities(toAdd.stream().filter((entity) -> !(entity instanceof EntityHuman || entity.valid))); // Paper - add all at same time to avoid entities adding to world modifying slice state, skip already added entities (not normal, but can happen)
|
|
|
|
// CraftBukkit start
|
|
org.bukkit.Server server = this.world.getServer();
|
|
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
|
|
index 4cc7f7af0d..2474b96382 100644
|
|
--- a/src/main/java/net/minecraft/server/World.java
|
|
+++ b/src/main/java/net/minecraft/server/World.java
|
|
@@ -1103,6 +1103,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
|
|
}
|
|
|
|
this.getChunkAt(i, j).a(entity);
|
|
+ if (entity.dead) return false; // Paper - don't add dead entities, chunk registration may of killed it
|
|
this.entityList.add(entity);
|
|
this.b(entity);
|
|
return true;
|
|
@@ -2508,9 +2509,13 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
|
|
return j;
|
|
}
|
|
|
|
+ public void addChunkEntities(Stream<Entity> collection) { a(collection); } // Paper - OBFHELPER
|
|
public void a(Stream<Entity> stream) {
|
|
org.spigotmc.AsyncCatcher.catchOp( "entity world add"); // Spigot
|
|
stream.forEach((entity) -> {
|
|
+ if (entity == null || entity.dead || entity.valid) { // Paper - prevent adding already added or dead entities
|
|
+ return;
|
|
+ }
|
|
this.entityList.add(entity);
|
|
this.b(entity);
|
|
});
|
|
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
|
|
index 0e63a0b5cd..72c661ef2d 100644
|
|
--- a/src/main/java/net/minecraft/server/WorldServer.java
|
|
+++ b/src/main/java/net/minecraft/server/WorldServer.java
|
|
@@ -990,7 +990,7 @@ public class WorldServer extends World implements IAsyncTaskHandler {
|
|
if (this.entitiesByUUID.containsKey(uuid)) {
|
|
Entity entity1 = (Entity) this.entitiesByUUID.get(uuid);
|
|
|
|
- if (this.g.contains(entity1)) {
|
|
+ if (this.g.contains(entity1) || entity1.dead) { // Paper - if dupe is dead, overwrite
|
|
this.g.remove(entity1);
|
|
} else {
|
|
if (!(entity instanceof EntityHuman)) {
|
|
--
|
|
2.19.0
|
|
|