even even even even even more patches

This commit is contained in:
Jason Penilla 2021-11-24 19:06:43 -08:00 committed by MiniDigger | Martin
parent aa948d8338
commit fdde23eecf
7 changed files with 30 additions and 28 deletions

View file

@ -10,7 +10,7 @@ schedules. Effectively, use the callback executor as a tool of
finding issues rather than hiding these issues.
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index e8b68702d7f720ba9d2985984547d0dda9541d41..825ed5ff5ee9fe4484dc81d1b5086d96813050e1 100644
index e8b68702d7f720ba9d2985984547d0dda9541d41..db4d506852b92fc84fe052358599153fbd013d2a 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -156,17 +156,28 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@ -26,7 +26,7 @@ index e8b68702d7f720ba9d2985984547d0dda9541d41..825ed5ff5ee9fe4484dc81d1b5086d96
+ // Paper start - revert CB changes
+ org.spigotmc.AsyncCatcher.catchOp("Callback Executor execute");
+ if (this.queued != null) {
+ MinecraftServer.LOGGER.fatal("Failed to schedule runnable", new IllegalStateException("Already queued"));
+ net.minecraft.server.MinecraftServer.LOGGER.fatal("Failed to schedule runnable", new IllegalStateException("Already queued"));
+ throw new IllegalStateException("Already queued");
+ }
+ this.queued = runnable;

View file

@ -9,10 +9,10 @@ chunk through it. This should also be OK from a leak prevention/
state desync POV because the TE is getting unloaded anyways.
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index f8c0574137cab33d0b5efe5d532efb132dcb914a..80f59abeb0081fe4784f3c0d027e8dfce752814b 100644
index b8e7f70f4ee1b28635537e04f7bd0d0cd6afb4b3..82ae5094025c7d86ba6fdbf4334b2575e7b6afa1 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -1292,9 +1292,13 @@ public class ServerLevel extends Level implements WorldGenLevel {
@@ -1272,9 +1272,13 @@ public class ServerLevel extends Level implements WorldGenLevel {
// Spigot Start
for (net.minecraft.world.level.block.entity.BlockEntity tileentity : chunk.getBlockEntities().values()) {
if (tileentity instanceof net.minecraft.world.Container) {
@ -28,10 +28,10 @@ index f8c0574137cab33d0b5efe5d532efb132dcb914a..80f59abeb0081fe4784f3c0d027e8dfc
}
// Spigot End
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
index 9b02f054493ad69c7a595374e6fd600c3d64e61e..e40587b9c13d9170ef5dd0811e96b02ecaccebb2 100644
index a6ec320bdca4a1c6e23461cd10a6f7bed681f243..67b482f6cafc55b6b262f23c2b56e4d8c6d089c2 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
@@ -1562,6 +1562,18 @@ public class ServerPlayer extends Player {
@@ -1559,6 +1559,18 @@ public class ServerPlayer extends Player {
this.connection.send(new ClientboundContainerClosePacket(this.containerMenu.containerId));
this.doCloseContainer();
}
@ -49,12 +49,12 @@ index 9b02f054493ad69c7a595374e6fd600c3d64e61e..e40587b9c13d9170ef5dd0811e96b02e
+ // Paper end - special close for unloaded inventory
public void doCloseContainer() {
this.containerMenu.removed((Player) this);
this.containerMenu.removed(this);
diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java
index fb66da46d2b3a46fe4b8d43f99a1a60f768f5f19..ce713e1857121ca52467ad561c4fbb30ae054d87 100644
index b6f8e94df86c174569ccbc69cfd031cc08271dd3..4e6364bea8f464bef690b8cc8f25a80ee699ed5a 100644
--- a/src/main/java/net/minecraft/world/entity/player/Player.java
+++ b/src/main/java/net/minecraft/world/entity/player/Player.java
@@ -498,6 +498,11 @@ public abstract class Player extends LivingEntity {
@@ -496,6 +496,11 @@ public abstract class Player extends LivingEntity {
this.containerMenu = this.inventoryMenu;
}
// Paper end

View file

@ -8,21 +8,20 @@ cause a recursive call which would handle the increase but then
the caller would think the chunk would be unloaded.
diff --git a/src/main/java/net/minecraft/server/level/ChunkHolder.java b/src/main/java/net/minecraft/server/level/ChunkHolder.java
index 823451570e02ee75bfce1c106779a0502187fcea..d4ea81824acdc1220616b24ea0f465db97f4a343 100644
index 292a26a2e13d97e4796bfe00c4d5789f94e67cc1..be8e63fb3e5c65157ea4ed9c0e3910aaba8c3d45 100644
--- a/src/main/java/net/minecraft/server/level/ChunkHolder.java
+++ b/src/main/java/net/minecraft/server/level/ChunkHolder.java
@@ -619,8 +619,10 @@ public class ChunkHolder {
@@ -400,7 +400,9 @@ public class ChunkHolder {
playerchunkmap.onFullChunkStatusChange(this.pos, playerchunk_state);
}
+ protected long updateCount; // Paper - correctly handle recursion
protected void updateFutures(ChunkMap chunkStorage, Executor executor) {
io.papermc.paper.util.TickThread.ensureTickThread("Async ticket level update"); // Paper
+ long updateCount = ++this.updateCount; // Paper - correctly handle recursion
ChunkStatus chunkstatus = ChunkHolder.getStatus(this.oldTicketLevel);
ChunkStatus chunkstatus1 = ChunkHolder.getStatus(this.ticketLevel);
boolean flag = this.oldTicketLevel <= ChunkMap.MAX_CHUNK_DISTANCE;
@@ -662,6 +664,12 @@ public class ChunkHolder {
@@ -429,6 +431,12 @@ public class ChunkHolder {
// Run callback right away if the future was already done
chunkStorage.callbackExecutor.run();
@ -34,4 +33,4 @@ index 823451570e02ee75bfce1c106779a0502187fcea..d4ea81824acdc1220616b24ea0f465db
+ // Paper end - correctly handle recursion
}
// CraftBukkit end
CompletableFuture completablefuture;

View file

@ -6,7 +6,7 @@ Subject: [PATCH] Separate lookup locking from state access in UserCache
Prevent lookups from stalling simple state access/write calls
diff --git a/src/main/java/net/minecraft/server/players/GameProfileCache.java b/src/main/java/net/minecraft/server/players/GameProfileCache.java
index 61405c2b53e03a4b83e2c70c6e4d3739ca9676cb..66dfa8c844963091b63e1f2f85d0da6dd2cd083c 100644
index 3789441e2df9410aa1c6efe59054aaba2c738633..a157f71cf55b9e97fac56c7c55b552da86000fd5 100644
--- a/src/main/java/net/minecraft/server/players/GameProfileCache.java
+++ b/src/main/java/net/minecraft/server/players/GameProfileCache.java
@@ -62,6 +62,11 @@ public class GameProfileCache {
@ -94,7 +94,7 @@ index 61405c2b53e03a4b83e2c70c6e4d3739ca9676cb..66dfa8c844963091b63e1f2f85d0da6d
}
public void setExecutor(Executor executor) {
@@ -322,7 +337,9 @@ public class GameProfileCache {
@@ -326,7 +341,9 @@ public class GameProfileCache {
}
private Stream<GameProfileCache.GameProfileInfo> getTopMRUProfiles(int limit) {

View file

@ -10,11 +10,11 @@ chunk future to complete. We can simply schedule to the immediate
executor to get this effect, rather than the main mailbox.
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index dcb5b1022eb72c50dc1df3654b0c9db7c782517c..efaab00b73f48e267a033a4ef466dcbaf2af2044 100644
index db4d506852b92fc84fe052358599153fbd013d2a..6463bd3a796661a9077837ce01822a7ca69f89e2 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -1451,9 +1451,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
chunk.unpackTicks();
@@ -1018,9 +1018,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
return chunk;
});
- }, (runnable) -> {

View file

@ -8,18 +8,18 @@ Sync loading the chunk at this stage would cause it to load
older data, as well as screwing our region state.
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index ba1c55c4f2486cae25ce570132d9222f6ab77d49..fe15f8fdb886674278513c5fdbf17f066c9f0b4f 100644
index 6463bd3a796661a9077837ce01822a7ca69f89e2..0a3aa9808c7308917b990b8aee3740ada23a4b24 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -341,6 +341,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -235,6 +235,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
}
// Paper end
+ boolean unloadingPlayerChunk = false; // Paper - do not allow ticket level changes while unloading chunks
public ChunkMap(ServerLevel world, LevelStorageSource.LevelStorageAccess session, DataFixer dataFixer, StructureManager structureManager, Executor executor, BlockableEventLoop<Runnable> mainThreadExecutor, LightChunkGetter chunkProvider, ChunkGenerator chunkGenerator, ChunkProgressListener worldGenerationProgressListener, ChunkStatusUpdateListener chunkStatusChangeListener, Supplier<DimensionDataStorage> persistentStateManagerFactory, int viewDistance, boolean dsync) {
super(new File(session.getDimensionPath(world.dimension()), "region"), dataFixer, dsync);
super(session.getDimensionPath(world.dimension()).resolve("region"), dataFixer, dsync);
this.visibleChunkMap = this.updatingChunkMap.clone();
@@ -802,6 +803,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -499,6 +500,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@Nullable
ChunkHolder updateChunkScheduling(long pos, int level, @Nullable ChunkHolder holder, int k) {
@ -27,7 +27,7 @@ index ba1c55c4f2486cae25ce570132d9222f6ab77d49..fe15f8fdb886674278513c5fdbf17f06
if (k > ChunkMap.MAX_CHUNK_DISTANCE && level > ChunkMap.MAX_CHUNK_DISTANCE) {
return holder;
} else {
@@ -1058,6 +1060,12 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -658,6 +660,12 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
if (completablefuture1 != completablefuture) {
this.scheduleUnload(pos, holder);
} else {
@ -40,7 +40,7 @@ index ba1c55c4f2486cae25ce570132d9222f6ab77d49..fe15f8fdb886674278513c5fdbf17f06
// Paper start
boolean removed;
if ((removed = this.pendingUnloads.remove(pos, holder)) && ichunkaccess != null) {
@@ -1094,6 +1102,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -693,6 +701,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
this.regionManagers.get(index).removeChunk(holder.pos.x, holder.pos.z);
}
} // Paper end
@ -49,13 +49,13 @@ index ba1c55c4f2486cae25ce570132d9222f6ab77d49..fe15f8fdb886674278513c5fdbf17f06
}
};
diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
index d03ca9b30380209397aed5371686e0022bf631d5..e88cae362fa167252aaa785895e378caec6ad757 100644
index 3c95e322a2ecf4fc212e168c4aa475d2e4e7ce69..7908e35a5842beb422edfed624561caffe08e6ef 100644
--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
@@ -842,6 +842,7 @@ public class ServerChunkCache extends ChunkSource {
@@ -787,6 +787,7 @@ public class ServerChunkCache extends ChunkSource {
}
public boolean runDistanceManagerUpdates() {
if (distanceManager.delayDistanceManagerTick) return false; // Paper - Chunk priority
+ if (this.chunkMap.unloadingPlayerChunk) { net.minecraft.server.MinecraftServer.LOGGER.fatal("Cannot tick distance manager while unloading playerchunks", new Throwable()); throw new IllegalStateException("Cannot tick distance manager while unloading playerchunks"); } // Paper
boolean flag = this.distanceManager.runAllUpdates(this.chunkMap);
boolean flag1 = this.chunkMap.promoteChunkMap();

View file

@ -23,3 +23,6 @@ index 48812329969b7192acd948db974bb77bb546f979..5b1e0ea40dea6c7d787699ed25160c8b
initial = blockState.getCollisionShape(world, mutableBlockPos, context).collide(axis3, box.move((double)(-mutableBlockPos.getX()), (double)(-mutableBlockPos.getY()), (double)(-mutableBlockPos.getZ())), initial);
if (Math.abs(initial) < 1.0E-7D) {
check ChunkHolder#updateFutures async catcher