Cleanup Entity add to world fixes

This commit is contained in:
Shane Freeder 2018-12-18 02:07:05 +00:00
parent e293688578
commit 6c34639605
No known key found for this signature in database
GPG key ID: A3F61EA5A085289C
2 changed files with 8 additions and 17 deletions

View file

@ -1,4 +1,4 @@
From 3ad5ebde68a9a0a224d8c458cbf491555ecb120e Mon Sep 17 00:00:00 2001 From 230019864ac37b09b4b61f018ae1becd1e9d185b Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co> From: Aikar <aikar@aikar.co>
Date: Fri, 3 Aug 2018 22:47:46 -0400 Date: Fri, 3 Aug 2018 22:47:46 -0400
Subject: [PATCH] Entity add to world fixes Subject: [PATCH] Entity add to world fixes
@ -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. 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 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 --- a/src/main/java/net/minecraft/server/Chunk.java
+++ b/src/main/java/net/minecraft/server/Chunk.java +++ b/src/main/java/net/minecraft/server/Chunk.java
@@ -2,6 +2,8 @@ package net.minecraft.server; @@ -2,6 +2,8 @@ package net.minecraft.server;
@ -26,15 +26,7 @@ index 37bb6f40c..414c27516 100644
import java.util.HashMap; import java.util.HashMap;
import java.util.UUID; import java.util.UUID;
// Paper end // Paper end
@@ -916,6 +918,7 @@ public class Chunk implements IChunkAccess { @@ -964,16 +966,16 @@ 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
@@ -964,17 +967,17 @@ public class Chunk implements IChunkAccess {
} }
} }
// Paper end // Paper end
@ -48,7 +40,6 @@ index 37bb6f40c..414c27516 100644
- return !(entity instanceof EntityHuman); - return !(entity instanceof EntityHuman);
- })); - }));
- entityslice.removeAll(toRemove); - 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) + 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 + // Paper start - Inline event into stream
+ .filter((entity) -> { + .filter((entity) -> {
@ -59,9 +50,9 @@ index 37bb6f40c..414c27516 100644
+ }) + })
+ // Paper end - Inline event into stream + // 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) + .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 diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index 5e61826f6..bd6f64e52 100644 index 5e61826f6..bd6f64e52 100644
--- a/src/main/java/net/minecraft/server/World.java --- a/src/main/java/net/minecraft/server/World.java

View file

@ -1,4 +1,4 @@
From aa5ba3307b20dc28bb7487fac1fb9624ab18501e Mon Sep 17 00:00:00 2001 From 3bcc6ac72694b340f1bae2c69802b6db1fd5d2b8 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co> From: Aikar <aikar@aikar.co>
Date: Sat, 29 Sep 2018 01:18:16 -0400 Date: Sat, 29 Sep 2018 01:18:16 -0400
Subject: [PATCH] Fix Sending Chunks to Client Subject: [PATCH] Fix Sending Chunks to Client
@ -14,10 +14,10 @@ This fix always sends chunks to the client, and simply updates
the client anytime post processing is triggered with the new chunk data. 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 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 --- a/src/main/java/net/minecraft/server/Chunk.java
+++ b/src/main/java/net/minecraft/server/Chunk.java +++ b/src/main/java/net/minecraft/server/Chunk.java
@@ -1200,7 +1200,7 @@ public class Chunk implements IChunkAccess { @@ -1199,7 +1199,7 @@ public class Chunk implements IChunkAccess {
} }
public boolean isReady() { public boolean isReady() {
@ -26,7 +26,7 @@ index ccdc171d4..7751ae444 100644
} }
public boolean v() { public boolean v() {
@@ -1438,6 +1438,13 @@ public class Chunk implements IChunkAccess { @@ -1437,6 +1437,13 @@ public class Chunk implements IChunkAccess {
this.h.clear(); this.h.clear();
this.a(ChunkStatus.POSTPROCESSED); this.a(ChunkStatus.POSTPROCESSED);
this.m.a(this); this.m.a(this);