Cleanup Entity add to world fixes

This commit is contained in:
Shane Freeder 2018-12-18 02:07:05 +00:00
parent 9e20d8d87b
commit 1cd0cdf543
2 changed files with 3 additions and 12 deletions

View file

@ -14,7 +14,7 @@ Fix this by differing entity add to world for all entities at the same time
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 37bb6f40c..414c27516 100644
index 37bb6f40c..55104d00f 100644
--- a/src/main/java/net/minecraft/server/Chunk.java
+++ b/src/main/java/net/minecraft/server/Chunk.java
@@ -0,0 +0,0 @@ package net.minecraft.server;
@ -26,14 +26,6 @@ index 37bb6f40c..414c27516 100644
import java.util.HashMap;
import java.util.UUID;
// Paper end
@@ -0,0 +0,0 @@ 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) {
// CraftBukkit start
@@ -0,0 +0,0 @@ public class Chunk implements IChunkAccess {
}
}
@ -48,7 +40,6 @@ index 37bb6f40c..414c27516 100644
- return !(entity instanceof EntityHuman);
- }));
- entityslice.removeAll(toRemove);
// CraftBukkit end
+ this.world.addChunkEntities(entityslice.stream() // Paper - add all at same time to avoid entities adding to world modifying slice state, skip already added entities (not normal, but can happen)
+ // Paper start - Inline event into stream
+ .filter((entity) -> {
@ -59,9 +50,9 @@ index 37bb6f40c..414c27516 100644
+ })
+ // Paper end - Inline event into 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 end
}
// CraftBukkit start
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index 5e61826f6..bd6f64e52 100644
--- a/src/main/java/net/minecraft/server/World.java

View file

@ -14,7 +14,7 @@ This fix always sends chunks to the client, and simply updates
the client anytime post processing is triggered with the new chunk data.
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
index ccdc171d4..7751ae444 100644
index 2253092a9..811a63e04 100644
--- a/src/main/java/net/minecraft/server/Chunk.java
+++ b/src/main/java/net/minecraft/server/Chunk.java
@@ -0,0 +0,0 @@ public class Chunk implements IChunkAccess {