Restore preventing saving bad entities patch to full effect

This commit is contained in:
Aikar 2020-04-12 16:50:50 -04:00
parent b03a0ea94b
commit bc1203ad20
3 changed files with 50 additions and 27 deletions

View file

@ -2569,7 +2569,7 @@ index b582171c5..03d7ce829 100644
} finally {
playerChunkMap.callbackExecutor.run();
diff --git a/src/main/java/net/minecraft/server/ChunkRegionLoader.java b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
index a950ad801..26f1a4b09 100644
index 8816c90e2..0b61ee3ba 100644
--- a/src/main/java/net/minecraft/server/ChunkRegionLoader.java
+++ b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
@@ -0,0 +0,0 @@ import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
@ -2786,18 +2786,22 @@ index a950ad801..26f1a4b09 100644
nbttagcompound2 = new NBTTagCompound();
nbttagcompound2.setByte("Y", (byte) (i & 255));
@@ -0,0 +0,0 @@ public class ChunkRegionLoader {
// Paper start
if ((int) Math.floor(entity.locX()) >> 4 != chunk.getPos().x || (int) Math.floor(entity.locZ()) >> 4 != chunk.getPos().z) {
LogManager.getLogger().warn(entity + " is not in this chunk, skipping save. This a bug fix to a vanilla bug. Do not report this to PaperMC please.");
- toUpdate.add(entity);
+ if (asyncsavedata == null) toUpdate.add(entity); // todo fix this broken code, entityJoinedWorld wont work in this case!
continue;
}
- if (entity.dead) {
+ if (asyncsavedata == null && entity.dead) { // todo
continue;
}
// Paper end
}
// Paper start - move entities to the correct chunk
- for (Entity entity : toUpdate) {
- worldserver.chunkCheck(entity);
- }
+ worldserver.getMinecraftServer().execute(() -> {
+ for (Entity entity : toUpdate) {
+ if (!entity.dead) {
+ worldserver.chunkCheck(entity);
+ }
+ }
+ });
// Paper end
} else {
@@ -0,0 +0,0 @@ public class ChunkRegionLoader {
}

View file

@ -8,7 +8,7 @@ This patch also adds a chunk status cache on region files (note that
its only purpose is to cache the status on DISK)
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java
index 462b224dfe..b582171c51 100644
index 462b224df..b582171c5 100644
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
@@ -0,0 +0,0 @@ public class ChunkProviderServer extends IChunkProvider {
@ -43,12 +43,12 @@ index 462b224dfe..b582171c51 100644
@Nullable
diff --git a/src/main/java/net/minecraft/server/ChunkRegionLoader.java b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
index 6371f2f5b1..961228e9df 100644
index 83bcef7e6..47e074a12 100644
--- a/src/main/java/net/minecraft/server/ChunkRegionLoader.java
+++ b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
@@ -0,0 +0,0 @@ public class ChunkRegionLoader {
return nbttagcompound;
}
// Paper end
+ // Paper start
+ public static ChunkStatus getStatus(NBTTagCompound compound) {
@ -65,7 +65,7 @@ index 6371f2f5b1..961228e9df 100644
if (nbttagcompound != null) {
ChunkStatus chunkstatus = ChunkStatus.a(nbttagcompound.getCompound("Level").getString("Status"));
diff --git a/src/main/java/net/minecraft/server/ChunkStatus.java b/src/main/java/net/minecraft/server/ChunkStatus.java
index efdf611e66..134a4f0b7d 100644
index efdf611e6..134a4f0b7 100644
--- a/src/main/java/net/minecraft/server/ChunkStatus.java
+++ b/src/main/java/net/minecraft/server/ChunkStatus.java
@@ -0,0 +0,0 @@ public class ChunkStatus {
@ -95,7 +95,7 @@ index efdf611e66..134a4f0b7d 100644
return (ChunkStatus) IRegistry.CHUNK_STATUS.get(MinecraftKey.a(s));
}
diff --git a/src/main/java/net/minecraft/server/IChunkLoader.java b/src/main/java/net/minecraft/server/IChunkLoader.java
index f0a052eec2..2f95174fcc 100644
index f0a052eec..2f95174fc 100644
--- a/src/main/java/net/minecraft/server/IChunkLoader.java
+++ b/src/main/java/net/minecraft/server/IChunkLoader.java
@@ -0,0 +0,0 @@ import javax.annotation.Nullable;
@ -108,7 +108,7 @@ index f0a052eec2..2f95174fcc 100644
@Nullable
private PersistentStructureLegacy c;
diff --git a/src/main/java/net/minecraft/server/PlayerChunk.java b/src/main/java/net/minecraft/server/PlayerChunk.java
index 66a389a67e..027a6b0fd2 100644
index 66a389a67..027a6b0fd 100644
--- a/src/main/java/net/minecraft/server/PlayerChunk.java
+++ b/src/main/java/net/minecraft/server/PlayerChunk.java
@@ -0,0 +0,0 @@ public class PlayerChunk {
@ -132,7 +132,7 @@ index 66a389a67e..027a6b0fd2 100644
public CompletableFuture<Either<IChunkAccess, PlayerChunk.Failure>> getStatusFutureUnchecked(ChunkStatus chunkstatus) {
diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java
index 18c71609c0..57b1341b5a 100644
index 18c71609c..57b1341b5 100644
--- a/src/main/java/net/minecraft/server/PlayerChunkMap.java
+++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java
@@ -0,0 +0,0 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@ -201,7 +201,7 @@ index 18c71609c0..57b1341b5a 100644
// Spigot start
return isOutsideOfRange(chunkcoordintpair, false);
diff --git a/src/main/java/net/minecraft/server/RegionFile.java b/src/main/java/net/minecraft/server/RegionFile.java
index 6b543f89d4..d37abf2cf3 100644
index 6b543f89d..d37abf2cf 100644
--- a/src/main/java/net/minecraft/server/RegionFile.java
+++ b/src/main/java/net/minecraft/server/RegionFile.java
@@ -0,0 +0,0 @@ public class RegionFile implements AutoCloseable {
@ -250,7 +250,7 @@ index 6b543f89d4..d37abf2cf3 100644
this.c();
} finally {
diff --git a/src/main/java/net/minecraft/server/RegionFileCache.java b/src/main/java/net/minecraft/server/RegionFileCache.java
index b3d1bb5fd8..e07ae98540 100644
index b3d1bb5fd..e07ae9854 100644
--- a/src/main/java/net/minecraft/server/RegionFileCache.java
+++ b/src/main/java/net/minecraft/server/RegionFileCache.java
@@ -0,0 +0,0 @@ public final class RegionFileCache implements AutoCloseable {
@ -280,7 +280,7 @@ index b3d1bb5fd8..e07ae98540 100644
throwable = throwable1;
throw throwable1;
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index 661a89c5d6..a71bb86508 100644
index 661a89c5d..a71bb8650 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -0,0 +0,0 @@ import java.util.Objects;

View file

@ -18,7 +18,7 @@ an invalid entity.
This should reduce log occurrences of dupe uuid messages.
diff --git a/src/main/java/net/minecraft/server/ChunkRegionLoader.java b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
index 4af5a230ba..6371f2f5b1 100644
index 4af5a230b..83bcef7e6 100644
--- a/src/main/java/net/minecraft/server/ChunkRegionLoader.java
+++ b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
@@ -0,0 +0,0 @@ public class ChunkRegionLoader {
@ -36,11 +36,10 @@ index 4af5a230ba..6371f2f5b1 100644
-
+ // Paper start
+ if ((int) Math.floor(entity.locX()) >> 4 != chunk.getPos().x || (int) Math.floor(entity.locZ()) >> 4 != chunk.getPos().z) {
+ LogManager.getLogger().warn(entity + " is not in this chunk, skipping save. This a bug fix to a vanilla bug. Do not report this to PaperMC please.");
+ toUpdate.add(entity);
+ continue;
+ }
+ if (entity.dead) {
+ if (entity.dead || hasPlayerPassenger(entity)) {
+ continue;
+ }
+ // Paper end
@ -53,11 +52,31 @@ index 4af5a230ba..6371f2f5b1 100644
+
+ // Paper start - move entities to the correct chunk
+ for (Entity entity : toUpdate) {
+ worldserver.entityJoinedWorld(entity);
+ worldserver.chunkCheck(entity);
+ }
+ // Paper end
+
} else {
ProtoChunk protochunk = (ProtoChunk) ichunkaccess;
@@ -0,0 +0,0 @@ public class ChunkRegionLoader {
nbttagcompound1.set("Structures", a(chunkcoordintpair, ichunkaccess.h(), ichunkaccess.v()));
return nbttagcompound;
}
+ // Paper start - this is saved with the player
+ private static boolean hasPlayerPassenger(Entity entity) {
+ for (Entity passenger : entity.passengers) {
+ if (passenger instanceof EntityPlayer) {
+ return true;
+ }
+ if (hasPlayerPassenger(passenger)) {
+ return true;
+ }
+ }
+ return false;
+ }
+ // Paper end
public static ChunkStatus.Type a(@Nullable NBTTagCompound nbttagcompound) {
if (nbttagcompound != null) {
--