[ci skip] Move chunk system patch back a bit

This commit is contained in:
Nassim Jahnke 2024-01-24 13:07:40 +01:00
parent bafdfefb83
commit fae4fc60c9
32 changed files with 214 additions and 191 deletions

View file

@ -2038,9 +2038,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/net/minecraft/world/level/Level.java --- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -0,0 +0,0 @@ public abstract class Level implements LevelAccessor, AutoCloseable { @@ -0,0 +0,0 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
} return ret;
} }
// Paper end - notify observers even if grow failed // Paper end
+ // Paper start - optimize redstone (Alternate Current) + // Paper start - optimize redstone (Alternate Current)
+ public alternate.current.wire.WireHandler getWireHandler() { + public alternate.current.wire.WireHandler getWireHandler() {
+ // This method is overridden in ServerLevel. + // This method is overridden in ServerLevel.

View file

@ -69,7 +69,7 @@ diff --git a/src/main/java/org/spigotmc/WatchdogThread.java b/src/main/java/org/
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/spigotmc/WatchdogThread.java --- a/src/main/java/org/spigotmc/WatchdogThread.java
+++ b/src/main/java/org/spigotmc/WatchdogThread.java +++ b/src/main/java/org/spigotmc/WatchdogThread.java
@@ -0,0 +0,0 @@ public final class WatchdogThread extends io.papermc.paper.util.TickThread // Pa @@ -0,0 +0,0 @@ public class WatchdogThread extends Thread
private static WatchdogThread instance; private static WatchdogThread instance;
private long timeoutTime; private long timeoutTime;
private boolean restart; private boolean restart;
@ -80,7 +80,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
private volatile long lastTick; private volatile long lastTick;
private volatile boolean stopping; private volatile boolean stopping;
@@ -0,0 +0,0 @@ public final class WatchdogThread extends io.papermc.paper.util.TickThread // Pa @@ -0,0 +0,0 @@ public class WatchdogThread extends Thread
super( "Paper Watchdog Thread" ); super( "Paper Watchdog Thread" );
this.timeoutTime = timeoutTime; this.timeoutTime = timeoutTime;
this.restart = restart; this.restart = restart;
@ -89,7 +89,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
} }
private static long monotonicMillis() private static long monotonicMillis()
@@ -0,0 +0,0 @@ public final class WatchdogThread extends io.papermc.paper.util.TickThread // Pa @@ -0,0 +0,0 @@ public class WatchdogThread extends Thread
while ( !this.stopping ) while ( !this.stopping )
{ {
// //
@ -110,10 +110,21 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
log.log( Level.SEVERE, "------------------------------" ); log.log( Level.SEVERE, "------------------------------" );
log.log( Level.SEVERE, "The server has stopped responding! This is (probably) not a Paper bug." ); // Paper log.log( Level.SEVERE, "The server has stopped responding! This is (probably) not a Paper bug." ); // Paper
log.log( Level.SEVERE, "If you see a plugin in the Server thread dump below, then please report it to that author" ); log.log( Level.SEVERE, "If you see a plugin in the Server thread dump below, then please report it to that author" );
@@ -0,0 +0,0 @@ public final class WatchdogThread extends io.papermc.paper.util.TickThread // Pa @@ -0,0 +0,0 @@ public class WatchdogThread extends Thread
} log.log( Level.SEVERE, "near " + net.minecraft.world.level.Level.lastPhysicsProblem );
} }
// Paper end //
+ // Paper start - Warn in watchdog if an excessive velocity was ever set
+ if (org.bukkit.craftbukkit.CraftServer.excessiveVelEx != null) {
+ log.log( Level.SEVERE, "------------------------------" );
+ log.log( Level.SEVERE, "During the run of the server, a plugin set an excessive velocity on an entity" );
+ log.log( Level.SEVERE, "This may be the cause of the issue, or it may be entirely unrelated" );
+ log.log( Level.SEVERE, org.bukkit.craftbukkit.CraftServer.excessiveVelEx.getMessage());
+ for (StackTraceElement stack : org.bukkit.craftbukkit.CraftServer.excessiveVelEx.getStackTrace()) {
+ log.log(Level.SEVERE, "\t\t" + stack);
+ }
+ }
+ // Paper end
+ } else + } else
+ { + {
+ log.log(Level.SEVERE, "--- DO NOT REPORT THIS TO PAPER - THIS IS NOT A BUG OR A CRASH - " + Bukkit.getServer().getVersion() + " ---"); + log.log(Level.SEVERE, "--- DO NOT REPORT THIS TO PAPER - THIS IS NOT A BUG OR A CRASH - " + Bukkit.getServer().getVersion() + " ---");
@ -122,7 +133,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ // Paper end - Different message for short timeout + // Paper end - Different message for short timeout
log.log( Level.SEVERE, "------------------------------" ); log.log( Level.SEVERE, "------------------------------" );
log.log( Level.SEVERE, "Server thread dump (Look for plugins here before reporting to Paper!):" ); // Paper log.log( Level.SEVERE, "Server thread dump (Look for plugins here before reporting to Paper!):" ); // Paper
io.papermc.paper.chunk.system.scheduling.ChunkTaskScheduler.dumpAllChunkLoadInfo(isLongTimeout); // Paper // Paper - rewrite chunk system
WatchdogThread.dumpThread( ManagementFactory.getThreadMXBean().getThreadInfo( MinecraftServer.getServer().serverThread.getId(), Integer.MAX_VALUE ), log ); WatchdogThread.dumpThread( ManagementFactory.getThreadMXBean().getThreadInfo( MinecraftServer.getServer().serverThread.getId(), Integer.MAX_VALUE ), log );
log.log( Level.SEVERE, "------------------------------" ); log.log( Level.SEVERE, "------------------------------" );
// //

View file

@ -198,10 +198,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/io/papermc/paper/command/PaperCommand.java --- a/src/main/java/io/papermc/paper/command/PaperCommand.java
+++ b/src/main/java/io/papermc/paper/command/PaperCommand.java +++ b/src/main/java/io/papermc/paper/command/PaperCommand.java
@@ -0,0 +0,0 @@ public final class PaperCommand extends Command { @@ -0,0 +0,0 @@ public final class PaperCommand extends Command {
commands.put(Set.of("version"), new VersionCommand());
commands.put(Set.of("dumpplugins"), new DumpPluginsCommand()); commands.put(Set.of("dumpplugins"), new DumpPluginsCommand());
commands.put(Set.of("fixlight"), new FixLightCommand()); commands.put(Set.of("fixlight"), new FixLightCommand());
commands.put(Set.of("debug", "chunkinfo", "holderinfo"), new ChunkDebugCommand()); + commands.put(Set.of("debug", "chunkinfo", "holderinfo"), new ChunkDebugCommand());
+ commands.put(Set.of("syncloadinfo"), new SyncLoadInfoCommand());
return commands.entrySet().stream() return commands.entrySet().stream()
.flatMap(entry -> entry.getKey().stream().map(s -> Map.entry(s, entry.getValue()))) .flatMap(entry -> entry.getKey().stream().map(s -> Map.entry(s, entry.getValue())))
@ -304,19 +304,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java --- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java +++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
@@ -0,0 +0,0 @@ public class ServerChunkCache extends ChunkSource { @@ -0,0 +0,0 @@ public class ServerChunkCache extends ChunkSource {
// Paper start - async chunk io/loading
io.papermc.paper.chunk.system.scheduling.ChunkTaskScheduler.pushChunkWait(this.level, x1, z1); // Paper - rewrite chunk system Objects.requireNonNull(completablefuture);
// Paper end if (!completablefuture.isDone()) { // Paper
+ com.destroystokyo.paper.io.SyncLoadFinder.logSyncLoad(this.level, x1, z1); // Paper - Add debug for sync chunk loads + com.destroystokyo.paper.io.SyncLoadFinder.logSyncLoad(this.level, x, z); // Paper - Add debug for sync chunk loads
this.level.timings.syncChunkLoad.startTiming(); // Paper this.level.timings.syncChunkLoad.startTiming(); // Paper
chunkproviderserver_b.managedBlock(completablefuture::isDone); chunkproviderserver_b.managedBlock(completablefuture::isDone);
io.papermc.paper.chunk.system.scheduling.ChunkTaskScheduler.popChunkWait(); // Paper - async chunk debug // Paper - rewrite chunk system this.level.timings.syncChunkLoad.stopTiming(); // Paper
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java --- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -0,0 +0,0 @@ public class ServerLevel extends Level implements WorldGenLevel { @@ -0,0 +0,0 @@ public class ServerLevel extends Level implements WorldGenLevel {
this.entityLookup = new io.papermc.paper.chunk.system.entity.EntityLookup(this, new EntityCallbacks()); // Paper - rewrite chunk system this.getCraftServer().addWorld(this.getWorld()); // CraftBukkit
} }
+ // Paper start + // Paper start

View file

@ -10,7 +10,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/io/papermc/paper/command/PaperCommand.java --- a/src/main/java/io/papermc/paper/command/PaperCommand.java
+++ b/src/main/java/io/papermc/paper/command/PaperCommand.java +++ b/src/main/java/io/papermc/paper/command/PaperCommand.java
@@ -0,0 +0,0 @@ public final class PaperCommand extends Command { @@ -0,0 +0,0 @@ public final class PaperCommand extends Command {
commands.put(Set.of("syncloadinfo"), new SyncLoadInfoCommand()); commands.put(Set.of("debug", "chunkinfo", "holderinfo"), new ChunkDebugCommand()); //
commands.put(Set.of("dumpitem"), new DumpItemCommand()); commands.put(Set.of("dumpitem"), new DumpItemCommand());
commands.put(Set.of("mobcaps", "playermobcaps"), new MobcapsCommand()); commands.put(Set.of("mobcaps", "playermobcaps"), new MobcapsCommand());
+ commands.put(Set.of("dumplisteners"), new DumpListenersCommand()); + commands.put(Set.of("dumplisteners"), new DumpListenersCommand());

View file

@ -14,8 +14,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/io/papermc/paper/command/PaperCommand.java --- a/src/main/java/io/papermc/paper/command/PaperCommand.java
+++ b/src/main/java/io/papermc/paper/command/PaperCommand.java +++ b/src/main/java/io/papermc/paper/command/PaperCommand.java
@@ -0,0 +0,0 @@ public final class PaperCommand extends Command { @@ -0,0 +0,0 @@ public final class PaperCommand extends Command {
commands.put(Set.of("debug", "chunkinfo", "holderinfo"), new ChunkDebugCommand()); commands.put(Set.of("fixlight"), new FixLightCommand());
commands.put(Set.of("syncloadinfo"), new SyncLoadInfoCommand()); commands.put(Set.of("debug", "chunkinfo", "holderinfo"), new ChunkDebugCommand()); //
commands.put(Set.of("dumpitem"), new DumpItemCommand()); commands.put(Set.of("dumpitem"), new DumpItemCommand());
+ commands.put(Set.of("mobcaps", "playermobcaps"), new MobcapsCommand()); + commands.put(Set.of("mobcaps", "playermobcaps"), new MobcapsCommand());

View file

@ -65,24 +65,21 @@ diff --git a/src/main/java/org/spigotmc/WatchdogThread.java b/src/main/java/org/
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/spigotmc/WatchdogThread.java --- a/src/main/java/org/spigotmc/WatchdogThread.java
+++ b/src/main/java/org/spigotmc/WatchdogThread.java +++ b/src/main/java/org/spigotmc/WatchdogThread.java
@@ -0,0 +0,0 @@ public final class WatchdogThread extends io.papermc.paper.util.TickThread // Pa @@ -0,0 +0,0 @@ public class WatchdogThread extends Thread
log.log( Level.SEVERE, "During the run of the server, a physics stackoverflow was supressed" ); }
log.log( Level.SEVERE, "near " + net.minecraft.world.level.Level.lastPhysicsProblem ); log.log( Level.SEVERE, "\tStack:" );
} //
- // + // Paper start - Warn in watchdog if an excessive velocity was ever set
+ // Paper start - Warn in watchdog if an excessive velocity was ever set + if (org.bukkit.craftbukkit.CraftServer.excessiveVelEx != null) {
+ if ( org.bukkit.craftbukkit.CraftServer.excessiveVelEx != null ) + log.log(Level.SEVERE, "------------------------------");
+ { + log.log(Level.SEVERE, "During the run of the server, a plugin set an excessive velocity on an entity");
+ log.log( Level.SEVERE, "------------------------------" ); + log.log(Level.SEVERE, "This may be the cause of the issue, or it may be entirely unrelated");
+ log.log( Level.SEVERE, "During the run of the server, a plugin set an excessive velocity on an entity" ); + log.log(Level.SEVERE, org.bukkit.craftbukkit.CraftServer.excessiveVelEx.getMessage());
+ log.log( Level.SEVERE, "This may be the cause of the issue, or it may be entirely unrelated" ); + for (StackTraceElement stack : org.bukkit.craftbukkit.CraftServer.excessiveVelEx.getStackTrace()) {
+ log.log( Level.SEVERE, org.bukkit.craftbukkit.CraftServer.excessiveVelEx.getMessage()); + log.log( Level.SEVERE, "\t\t" + stack );
+ for ( StackTraceElement stack : org.bukkit.craftbukkit.CraftServer.excessiveVelEx.getStackTrace() ) + }
+ { + }
+ log.log( Level.SEVERE, "\t\t" + stack ); + // Paper end
+ } for ( StackTraceElement stack : thread.getStackTrace() )
+ } {
+ // Paper end log.log( Level.SEVERE, "\t\t" + stack );
log.log( Level.SEVERE, "------------------------------" );
log.log( Level.SEVERE, "Server thread dump (Look for plugins here before reporting to Paper!):" ); // Paper
io.papermc.paper.chunk.system.scheduling.ChunkTaskScheduler.dumpAllChunkLoadInfo(isLongTimeout); // Paper // Paper - rewrite chunk system

View file

@ -16,7 +16,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ this.getProfileCache().save(false); // Paper - Perf: Async GameProfileCache saving + this.getProfileCache().save(false); // Paper - Perf: Async GameProfileCache saving
} }
// Spigot end // Spigot end
io.papermc.paper.chunk.system.io.RegionFileIOThread.close(true); // Paper // Paper - rewrite chunk system
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java --- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java

View file

@ -37,10 +37,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ server.scheduleOnMain(() -> this.disconnect(Component.translatable("disconnect.spam"))); // Paper - AsyncTabCompleteEvent + server.scheduleOnMain(() -> this.disconnect(Component.translatable("disconnect.spam"))); // Paper - AsyncTabCompleteEvent
return; return;
} }
// Paper start
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
}
// Paper end
// CraftBukkit end // CraftBukkit end
+ // Paper start - AsyncTabCompleteEvent + // Paper start - AsyncTabCompleteEvent
+ TAB_COMPLETE_EXECUTOR.execute(() -> { + TAB_COMPLETE_EXECUTOR.execute(() -> {

View file

@ -557,8 +557,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
import com.google.common.util.concurrent.ThreadFactoryBuilder; import com.google.common.util.concurrent.ThreadFactoryBuilder;
import io.papermc.paper.math.BlockPosition; import io.papermc.paper.math.BlockPosition;
import io.papermc.paper.math.FinePosition; import io.papermc.paper.math.FinePosition;
@@ -0,0 +0,0 @@ import net.minecraft.world.level.chunk.ChunkAccess; @@ -0,0 +0,0 @@ import net.minecraft.world.level.ClipContext;
import net.minecraft.world.level.chunk.ChunkStatus; import net.minecraft.world.level.Level;
import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.Vec3;
import org.apache.commons.lang.exception.ExceptionUtils; import org.apache.commons.lang.exception.ExceptionUtils;
+import com.mojang.authlib.GameProfile; +import com.mojang.authlib.GameProfile;

View file

@ -23,10 +23,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java --- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java +++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
@@ -0,0 +0,0 @@ public class RegionFileStorage implements AutoCloseable { @@ -0,0 +0,0 @@ public class RegionFileStorage implements AutoCloseable {
}
// Paper end - rewrite chunk system protected void write(ChunkPos pos, @Nullable CompoundTag nbt) throws IOException {
try { // Paper RegionFile regionfile = this.getRegionFile(pos, false); // CraftBukkit
+ int attempts = 0; Exception laste = null; while (attempts++ < 5) { try { // Paper - Chunk save reattempt + // Paper start - Chunk save reattempt
+ int attempts = 0;
+ Exception lastException = null;
+ while (attempts++ < 5) {
+ try {
+ // Paper end - Chunk save reattempt
if (nbt == null) { if (nbt == null) {
regionfile.clear(pos); regionfile.clear(pos);
@ -35,17 +40,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
} }
} }
+ // Paper start - Chunk save reattempt + // Paper start - Chunk save reattempt
+ return; + return;
+ } catch (Exception ex) { + } catch (Exception ex) {
+ laste = ex; + lastException = ex;
+ } + }
+ } + }
+ if (laste != null) { + if (lastException != null) {
+ com.destroystokyo.paper.exception.ServerInternalException.reportInternalException(laste); + com.destroystokyo.paper.exception.ServerInternalException.reportInternalException(lastException);
+ net.minecraft.server.MinecraftServer.LOGGER.error("Failed to save chunk " + pos, laste); + net.minecraft.server.MinecraftServer.LOGGER.error("Failed to save chunk {}", pos, lastException);
+ } + }
+ // Paper end - Chunk save reattempt + // Paper end - Chunk save reattempt
} finally { // Paper start }
regionfile.fileLock.unlock();
} // Paper end public void close() throws IOException {

View file

@ -641,19 +641,25 @@ diff --git a/src/main/java/org/spigotmc/WatchdogThread.java b/src/main/java/org/
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/spigotmc/WatchdogThread.java --- a/src/main/java/org/spigotmc/WatchdogThread.java
+++ b/src/main/java/org/spigotmc/WatchdogThread.java +++ b/src/main/java/org/spigotmc/WatchdogThread.java
@@ -0,0 +0,0 @@ public final class WatchdogThread extends io.papermc.paper.util.TickThread // Pa @@ -0,0 +0,0 @@ public class WatchdogThread extends Thread
log.log( Level.SEVERE, "During the run of the server, a plugin set an excessive velocity on an entity" ); log.log( Level.SEVERE, "During the run of the server, a plugin set an excessive velocity on an entity" );
log.log( Level.SEVERE, "This may be the cause of the issue, or it may be entirely unrelated" ); log.log( Level.SEVERE, "This may be the cause of the issue, or it may be entirely unrelated" );
log.log( Level.SEVERE, org.bukkit.craftbukkit.CraftServer.excessiveVelEx.getMessage()); log.log( Level.SEVERE, org.bukkit.craftbukkit.CraftServer.excessiveVelEx.getMessage());
- for ( StackTraceElement stack : org.bukkit.craftbukkit.CraftServer.excessiveVelEx.getStackTrace() ) - for (StackTraceElement stack : org.bukkit.craftbukkit.CraftServer.excessiveVelEx.getStackTrace()) {
+ for ( StackTraceElement stack : io.papermc.paper.util.StacktraceDeobfuscator.INSTANCE.deobfuscateStacktrace(org.bukkit.craftbukkit.CraftServer.excessiveVelEx.getStackTrace()) ) // Paper + for (StackTraceElement stack : io.papermc.paper.util.StacktraceDeobfuscator.INSTANCE.deobfuscateStacktrace(org.bukkit.craftbukkit.CraftServer.excessiveVelEx.getStackTrace())) { // Paper
{ log.log(Level.SEVERE, "\t\t" + stack);
log.log( Level.SEVERE, "\t\t" + stack );
} }
@@ -0,0 +0,0 @@ public final class WatchdogThread extends io.papermc.paper.util.TickThread // Pa }
@@ -0,0 +0,0 @@ public class WatchdogThread extends Thread
log.log(Level.SEVERE, "During the run of the server, a plugin set an excessive velocity on an entity");
log.log(Level.SEVERE, "This may be the cause of the issue, or it may be entirely unrelated");
log.log(Level.SEVERE, org.bukkit.craftbukkit.CraftServer.excessiveVelEx.getMessage());
- for (StackTraceElement stack : org.bukkit.craftbukkit.CraftServer.excessiveVelEx.getStackTrace()) {
+ for (StackTraceElement stack : io.papermc.paper.util.StacktraceDeobfuscator.INSTANCE.deobfuscateStacktrace(org.bukkit.craftbukkit.CraftServer.excessiveVelEx.getStackTrace())) { // Paper
log.log( Level.SEVERE, "\t\t" + stack );
}
} }
log.log( Level.SEVERE, "\tStack:" ); // Paper end
//
- for ( StackTraceElement stack : thread.getStackTrace() ) - for ( StackTraceElement stack : thread.getStackTrace() )
+ for ( StackTraceElement stack : io.papermc.paper.util.StacktraceDeobfuscator.INSTANCE.deobfuscateStacktrace(thread.getStackTrace()) ) // Paper + for ( StackTraceElement stack : io.papermc.paper.util.StacktraceDeobfuscator.INSTANCE.deobfuscateStacktrace(thread.getStackTrace()) ) // Paper
{ {

View file

@ -289,7 +289,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@@ -0,0 +0,0 @@ public final class WatchdogThread extends io.papermc.paper.util.TickThread // Pa @@ -0,0 +0,0 @@ public final class WatchdogThread extends io.papermc.paper.util.TickThread // Pa
log.log( Level.SEVERE, "------------------------------" ); log.log( Level.SEVERE, "------------------------------" );
log.log( Level.SEVERE, "Server thread dump (Look for plugins here before reporting to Paper!):" ); // Paper log.log( Level.SEVERE, "Server thread dump (Look for plugins here before reporting to Paper!):" ); // Paper
io.papermc.paper.chunk.system.scheduling.ChunkTaskScheduler.dumpAllChunkLoadInfo(isLongTimeout); // Paper // Paper - rewrite chunk system io.papermc.paper.chunk.system.scheduling.ChunkTaskScheduler.dumpAllChunkLoadInfo(isLongTimeout); // Paper - rewrite chunk system
+ this.dumpTickingInfo(); // Paper - log detailed tick information + this.dumpTickingInfo(); // Paper - log detailed tick information
WatchdogThread.dumpThread( ManagementFactory.getThreadMXBean().getThreadInfo( MinecraftServer.getServer().serverThread.getId(), Integer.MAX_VALUE ), log ); WatchdogThread.dumpThread( ManagementFactory.getThreadMXBean().getThreadInfo( MinecraftServer.getServer().serverThread.getId(), Integer.MAX_VALUE ), log );
log.log( Level.SEVERE, "------------------------------" ); log.log( Level.SEVERE, "------------------------------" );

View file

@ -13,7 +13,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java --- a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java +++ b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java
@@ -0,0 +0,0 @@ public class ChunkSerializer { @@ -0,0 +0,0 @@ public class ChunkSerializer {
InProgressChunkHolder holder = loadChunk(world, poiStorage, chunkPos, nbt, true); InProgressChunkHolder holder = readInProgressChunkHolder(world, poiStorage, chunkPos, nbt);
return holder.protoChunk; return holder.protoChunk;
} }
+ // Paper start - Do not let the server load chunks from newer versions + // Paper start - Do not let the server load chunks from newer versions
@ -21,15 +21,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ private static final boolean JUST_CORRUPT_IT = Boolean.getBoolean("Paper.ignoreWorldDataVersion"); + private static final boolean JUST_CORRUPT_IT = Boolean.getBoolean("Paper.ignoreWorldDataVersion");
+ // Paper end - Do not let the server load chunks from newer versions + // Paper end - Do not let the server load chunks from newer versions
public static InProgressChunkHolder loadChunk(ServerLevel world, PoiManager poiStorage, ChunkPos chunkPos, CompoundTag nbt, boolean distinguish) { public static InProgressChunkHolder readInProgressChunkHolder(ServerLevel world, PoiManager poiStorage, ChunkPos chunkPos, CompoundTag nbt) {
// Paper end - rewrite chunk system
+ // Paper start - Do not let the server load chunks from newer versions + // Paper start - Do not let the server load chunks from newer versions
+ if (nbt.contains("DataVersion", net.minecraft.nbt.Tag.TAG_ANY_NUMERIC)) { + if (nbt.contains("DataVersion", net.minecraft.nbt.Tag.TAG_ANY_NUMERIC)) {
+ int dataVersion = nbt.getInt("DataVersion"); + final int dataVersion = nbt.getInt("DataVersion");
+ if (!JUST_CORRUPT_IT && dataVersion > CURRENT_DATA_VERSION) { + if (!JUST_CORRUPT_IT && dataVersion > CURRENT_DATA_VERSION) {
+ new RuntimeException("Server attempted to load chunk saved with newer version of minecraft! " + dataVersion + " > " + CURRENT_DATA_VERSION).printStackTrace(); + new RuntimeException("Server attempted to load chunk saved with newer version of minecraft! " + dataVersion + " > " + CURRENT_DATA_VERSION).printStackTrace();
+ System.exit(1); + System.exit(1);
+ } + }
+ } + }
// Paper end + // Paper end - Do not let the server load chunks from newer versions
ChunkPos chunkcoordintpair1 = new ChunkPos(nbt.getInt("xPos"), nbt.getInt("zPos")); // Paper - guard against serializing mismatching coordinates; diff on change, see ChunkSerializer#getChunkCoordinate ChunkPos chunkcoordintpair1 = new ChunkPos(nbt.getInt("xPos"), nbt.getInt("zPos")); // Paper - guard against serializing mismatching coordinates; diff on change, see ChunkSerializer#getChunkCoordinate
if (!Objects.equals(chunkPos, chunkcoordintpair1)) {

View file

@ -20,4 +20,4 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ if (objectset == null || objectset.isEmpty()) { // Paper + if (objectset == null || objectset.isEmpty()) { // Paper
this.playersPerChunk.remove(i); this.playersPerChunk.remove(i);
this.naturalSpawnChunkCounter.update(i, Integer.MAX_VALUE, false); this.naturalSpawnChunkCounter.update(i, Integer.MAX_VALUE, false);
//this.playerTicketManager.update(i, Integer.MAX_VALUE, false); // Paper - no longer used this.playerTicketManager.update(i, Integer.MAX_VALUE, false);

View file

@ -42,10 +42,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
} }
+ checkDupeUUID(world, entity); // Paper - duplicate uuid resolving + checkDupeUUID(world, entity); // Paper - duplicate uuid resolving
return !needsRemoval; return !needsRemoval;
}), position); // Paper - rewrite chunk system }));
// CraftBukkit end // CraftBukkit end
@@ -0,0 +0,0 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -0,0 +0,0 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
throw new UnsupportedOperationException(); // Paper - rewrite chunk system });
} }
+ // Paper start - duplicate uuid resolving + // Paper start - duplicate uuid resolving
@ -88,5 +88,5 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ // Paper end - duplicate uuid resolving + // Paper end - duplicate uuid resolving
public CompletableFuture<Either<LevelChunk, ChunkHolder.ChunkLoadingFailure>> prepareTickingChunk(ChunkHolder holder) { public CompletableFuture<Either<LevelChunk, ChunkHolder.ChunkLoadingFailure>> prepareTickingChunk(ChunkHolder holder) {
throw new UnsupportedOperationException(); // Paper - rewrite chunk system CompletableFuture<Either<List<ChunkAccess>, ChunkHolder.ChunkLoadingFailure>> completablefuture = this.getChunkRangeFuture(holder, 1, (i) -> {
} return ChunkStatus.FULL;

View file

@ -47,9 +47,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ return; + return;
+ } + }
+ // Paper end - Block invalid positions and bounding box + // Paper end - Block invalid positions and bounding box
// Paper start - rewrite chunk system if (this.position.x != x || this.position.y != y || this.position.z != z) {
if (this.updatingSectionStatus) { this.position = new Vec3(x, y, z);
LOGGER.error("Refusing to update position for entity " + this + " to position " + new Vec3(x, y, z) + " since it is processing a section status update", new Throwable()); int i = Mth.floor(x);
@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S @@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
this.levelCallback.onMove(); this.levelCallback.onMove();
} }

View file

@ -85,10 +85,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/net/minecraft/world/level/Level.java --- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -0,0 +0,0 @@ public abstract class Level implements LevelAccessor, AutoCloseable { @@ -0,0 +0,0 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
return ret;
private ExplosionInteraction() {}
} }
// Paper end
+
+ // Paper start - respect global sound events gamerule + // Paper start - respect global sound events gamerule
+ public List<net.minecraft.server.level.ServerPlayer> getPlayersForGlobalSoundGamerule() { + public List<net.minecraft.server.level.ServerPlayer> getPlayersForGlobalSoundGamerule() {
+ return this.getGameRules().getBoolean(GameRules.RULE_GLOBAL_SOUND_EVENTS) ? ((ServerLevel) this).getServer().getPlayerList().players : ((ServerLevel) this).players(); + return this.getGameRules().getBoolean(GameRules.RULE_GLOBAL_SOUND_EVENTS) ? ((ServerLevel) this).getServer().getPlayerList().players : ((ServerLevel) this).players();

View file

@ -15,7 +15,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ // Paper start - guard against serializing mismatching coordinates + // Paper start - guard against serializing mismatching coordinates
+ // TODO Note: This needs to be re-checked each update + // TODO Note: This needs to be re-checked each update
+ public static ChunkPos getChunkCoordinate(CompoundTag chunkData) { + public static ChunkPos getChunkCoordinate(final CompoundTag chunkData) {
+ final int dataVersion = ChunkStorage.getVersion(chunkData); + final int dataVersion = ChunkStorage.getVersion(chunkData);
+ if (dataVersion < 2842) { // Level tag is removed after this version + if (dataVersion < 2842) { // Level tag is removed after this version
+ final CompoundTag levelData = chunkData.getCompound("Level"); + final CompoundTag levelData = chunkData.getCompound("Level");
@ -25,13 +25,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ } + }
+ // Paper end - guard against serializing mismatching coordinates + // Paper end - guard against serializing mismatching coordinates
// Paper start public static ProtoChunk read(ServerLevel world, PoiManager poiStorage, ChunkPos chunkPos, CompoundTag nbt) {
public static final class InProgressChunkHolder {
@@ -0,0 +0,0 @@ public class ChunkSerializer {
public static InProgressChunkHolder loadChunk(ServerLevel world, PoiManager poiStorage, ChunkPos chunkPos, CompoundTag nbt, boolean distinguish) {
// Paper end
- ChunkPos chunkcoordintpair1 = new ChunkPos(nbt.getInt("xPos"), nbt.getInt("zPos")); - ChunkPos chunkcoordintpair1 = new ChunkPos(nbt.getInt("xPos"), nbt.getInt("zPos"));
+ ChunkPos chunkcoordintpair1 = new ChunkPos(nbt.getInt("xPos"), nbt.getInt("zPos")); // Paper - guard against serializing mismatching coordinates; diff on change, see ChunkSerializer#getChunkCoordinate + ChunkPos chunkcoordintpair1 = new ChunkPos(nbt.getInt("xPos"), nbt.getInt("zPos")); // Paper - guard against serializing mismatching coordinates; diff on change, see ChunkSerializer#getChunkCoordinate
@ -42,16 +36,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java --- a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java +++ b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java
@@ -0,0 +0,0 @@ public class ChunkStorage implements AutoCloseable { @@ -0,0 +0,0 @@ public class ChunkStorage implements AutoCloseable {
}
// Paper start - async chunk io public void write(ChunkPos chunkPos, CompoundTag nbt) {
public void write(ChunkPos chunkPos, CompoundTag nbt) throws IOException {
+ // Paper start - guard against serializing mismatching coordinates + // Paper start - guard against serializing mismatching coordinates
+ if (nbt != null && !chunkPos.equals(ChunkSerializer.getChunkCoordinate(nbt))) { + if (nbt != null && !chunkPos.equals(ChunkSerializer.getChunkCoordinate(nbt))) {
+ String world = (this instanceof net.minecraft.server.level.ChunkMap) ? ((net.minecraft.server.level.ChunkMap)this).level.getWorld().getName() : null; + final String world = (this instanceof net.minecraft.server.level.ChunkMap) ? ((net.minecraft.server.level.ChunkMap) this).level.getWorld().getName() : null;
+ throw new IllegalArgumentException("Chunk coordinate and serialized data do not have matching coordinates, trying to serialize coordinate " + chunkPos.toString() + throw new IllegalArgumentException("Chunk coordinate and serialized data do not have matching coordinates, trying to serialize coordinate " + chunkPos
+ + " but compound says coordinate is " + ChunkSerializer.getChunkCoordinate(nbt).toString() + (world == null ? " for an unknown world" : (" for world: " + world))); + + " but compound says coordinate is " + ChunkSerializer.getChunkCoordinate(nbt) + (world == null ? " for an unknown world" : (" for world: " + world)));
+ } + }
+ // Paper end - guard against serializing mismatching coordinates + // Paper end - guard against serializing mismatching coordinates
this.regionFileCache.write(chunkPos, nbt); this.worker.store(chunkPos, nbt);
// Paper end - Async chunk loading
if (this.legacyStructureHandler != null) { if (this.legacyStructureHandler != null) {
this.legacyStructureHandler.removeIndex(chunkPos.toLong());

View file

@ -46,7 +46,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ } + }
+ // Paper end - notify observers even if grow failed + // Paper end - notify observers even if grow failed
} // Paper start
//protected final io.papermc.paper.world.EntitySliceManager entitySliceManager; // Paper - rewrite chunk system
diff --git a/src/main/java/net/minecraft/world/level/block/SaplingBlock.java b/src/main/java/net/minecraft/world/level/block/SaplingBlock.java diff --git a/src/main/java/net/minecraft/world/level/block/SaplingBlock.java b/src/main/java/net/minecraft/world/level/block/SaplingBlock.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/block/SaplingBlock.java --- a/src/main/java/net/minecraft/world/level/block/SaplingBlock.java

View file

@ -77,7 +77,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ // Paper - don't write garbage data to disk if writing serialization fails; move into try block to only write if successfully serialized + // Paper - don't write garbage data to disk if writing serialization fails; move into try block to only write if successfully serialized
} }
// Paper start - Chunk save reattempt // Paper start - Chunk save reattempt
return; return;
@@ -0,0 +0,0 @@ public class RegionFileStorage implements AutoCloseable { @@ -0,0 +0,0 @@ public class RegionFileStorage implements AutoCloseable {
} }

View file

@ -10,8 +10,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java --- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -0,0 +0,0 @@ public class ServerLevel extends Level implements WorldGenLevel { @@ -0,0 +0,0 @@ public class ServerLevel extends Level implements WorldGenLevel {
});
} }
// Paper end
+ // Paper start - optimise getPlayerByUUID + // Paper start - optimise getPlayerByUUID
+ @Nullable + @Nullable

View file

@ -24,7 +24,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
gameprofilerfiller.incrementCounter("getChunk"); gameprofilerfiller.incrementCounter("getChunk");
@@ -0,0 +0,0 @@ public class ServerChunkCache extends ChunkSource { @@ -0,0 +0,0 @@ public class ServerChunkCache extends ChunkSource {
if (!io.papermc.paper.util.TickThread.isTickThread()) { // Paper - rewrite chunk system if (Thread.currentThread() != this.mainThread) {
return null; return null;
} else { } else {
- this.level.getProfiler().incrementCounter("getChunkNow"); - this.level.getProfiler().incrementCounter("getChunkNow");

View file

@ -26,5 +26,5 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
} }
+ // Paper end - Perf: Optimize capturedTileEntities lookup + // Paper end - Perf: Optimize capturedTileEntities lookup
// CraftBukkit end // CraftBukkit end
return this.isOutsideBuildHeight(blockposition) ? null : (!this.isClientSide && !io.papermc.paper.util.TickThread.isTickThread() ? null : this.getChunkAt(blockposition).getBlockEntity(blockposition, LevelChunk.EntityCreationType.IMMEDIATE)); // Paper - rewrite chunk system return this.isOutsideBuildHeight(blockposition) ? null : (!this.isClientSide && Thread.currentThread() != this.thread ? null : this.getChunkAt(blockposition).getBlockEntity(blockposition, LevelChunk.EntityCreationType.IMMEDIATE));
} }

View file

@ -10,9 +10,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/io/papermc/paper/command/PaperCommand.java --- a/src/main/java/io/papermc/paper/command/PaperCommand.java
+++ b/src/main/java/io/papermc/paper/command/PaperCommand.java +++ b/src/main/java/io/papermc/paper/command/PaperCommand.java
@@ -0,0 +0,0 @@ public final class PaperCommand extends Command { @@ -0,0 +0,0 @@ public final class PaperCommand extends Command {
commands.put(Set.of("dumpplugins"), new DumpPluginsCommand());
commands.put(Set.of("fixlight"), new FixLightCommand()); commands.put(Set.of("fixlight"), new FixLightCommand());
commands.put(Set.of("debug", "chunkinfo", "holderinfo"), new ChunkDebugCommand()); commands.put(Set.of("debug", "chunkinfo", "holderinfo"), new ChunkDebugCommand());
commands.put(Set.of("syncloadinfo"), new SyncLoadInfoCommand());
+ commands.put(Set.of("dumpitem"), new DumpItemCommand()); + commands.put(Set.of("dumpitem"), new DumpItemCommand());
return commands.entrySet().stream() return commands.entrySet().stream()

View file

@ -69,5 +69,5 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
public final com.destroystokyo.paper.util.misc.PooledLinkedHashSets.PooledObjectLinkedOpenHashSet<ServerPlayer> cachedSingleHashSet; // Paper public final com.destroystokyo.paper.util.misc.PooledLinkedHashSets.PooledObjectLinkedOpenHashSet<ServerPlayer> cachedSingleHashSet; // Paper
+ public com.destroystokyo.paper.event.entity.PlayerNaturallySpawnCreaturesEvent playerNaturallySpawnedEvent; // Paper - PlayerNaturallySpawnCreaturesEvent + public com.destroystokyo.paper.event.entity.PlayerNaturallySpawnCreaturesEvent playerNaturallySpawnedEvent; // Paper - PlayerNaturallySpawnCreaturesEvent
// Paper start - replace player chunk loader public ServerPlayer(MinecraftServer server, ServerLevel world, GameProfile profile, ClientInformation clientOptions) {
private final java.util.concurrent.atomic.AtomicReference<io.papermc.paper.chunk.system.RegionizedPlayerChunkLoader.ViewDistances> viewDistances = new java.util.concurrent.atomic.AtomicReference<>(new io.papermc.paper.chunk.system.RegionizedPlayerChunkLoader.ViewDistances(-1, -1, -1)); super(world, world.getSharedSpawnPos(), world.getSharedSpawnAngle(), profile);

View file

@ -8509,8 +8509,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ chunkPos, this.world + chunkPos, this.world
+ ); + );
+ // deserialize + // deserialize
+ final ChunkSerializer.InProgressChunkHolder chunkHolder = ChunkSerializer.loadChunk( + final ChunkSerializer.InProgressChunkHolder chunkHolder = ChunkSerializer.readInProgressChunkHolder(
+ this.world, chunkMap.getPoiManager(), chunkPos, converted, true + this.world, chunkMap.getPoiManager(), chunkPos, converted
+ ); + );
+ +
+ return new TaskResult<>(chunkHolder.protoChunk, null); + return new TaskResult<>(chunkHolder.protoChunk, null);
@ -15289,10 +15289,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
commands.put(Set.of("version"), new VersionCommand()); commands.put(Set.of("version"), new VersionCommand());
commands.put(Set.of("dumpplugins"), new DumpPluginsCommand()); commands.put(Set.of("dumpplugins"), new DumpPluginsCommand());
commands.put(Set.of("fixlight"), new FixLightCommand()); commands.put(Set.of("fixlight"), new FixLightCommand());
+ commands.put(Set.of("debug", "chunkinfo", "holderinfo"), new ChunkDebugCommand()); - commands.put(Set.of("debug", "chunkinfo", "holderinfo"), new ChunkDebugCommand());
+ commands.put(Set.of("debug", "chunkinfo", "holderinfo"), new ChunkDebugCommand()); //
commands.put(Set.of("dumpitem"), new DumpItemCommand());
return commands.entrySet().stream() return commands.entrySet().stream()
.flatMap(entry -> entry.getKey().stream().map(s -> Map.entry(s, entry.getValue())))
diff --git a/src/main/java/io/papermc/paper/command/subcommands/ChunkDebugCommand.java b/src/main/java/io/papermc/paper/command/subcommands/ChunkDebugCommand.java diff --git a/src/main/java/io/papermc/paper/command/subcommands/ChunkDebugCommand.java b/src/main/java/io/papermc/paper/command/subcommands/ChunkDebugCommand.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
@ -15760,7 +15761,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import net.minecraft.world.level.chunk.ChunkStatus; +import net.minecraft.world.level.chunk.ChunkStatus;
import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.Vec3;
import org.apache.commons.lang.exception.ExceptionUtils; import org.apache.commons.lang.exception.ExceptionUtils;
import org.bukkit.Location; import com.mojang.authlib.GameProfile;
@@ -0,0 +0,0 @@ import org.spigotmc.AsyncCatcher; @@ -0,0 +0,0 @@ import org.spigotmc.AsyncCatcher;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
@ -16753,7 +16754,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
this.isSaving = false; this.isSaving = false;
this.resources.close(); this.resources.close();
@@ -0,0 +0,0 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa @@ -0,0 +0,0 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
this.getProfileCache().save(); this.getProfileCache().save(false); // Paper - Perf: Async GameProfileCache saving
} }
// Spigot end // Spigot end
- -
@ -16840,7 +16841,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ return; + return;
+ } + }
+ // Paper end - rewrite chunk system + // Paper end - rewrite chunk system
this.consoleInput.add(new ConsoleInput(command, commandSource)); this.serverCommandQueue.add(new ConsoleInput(command, commandSource)); // Paper - Perf: use proper queue
} }
diff --git a/src/main/java/net/minecraft/server/level/ChunkHolder.java b/src/main/java/net/minecraft/server/level/ChunkHolder.java diff --git a/src/main/java/net/minecraft/server/level/ChunkHolder.java b/src/main/java/net/minecraft/server/level/ChunkHolder.java
@ -18168,8 +18169,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
// CraftBukkit start - these are spawned serialized (DefinedStructure) and we don't call an add event below at the moment due to ordering complexities // CraftBukkit start - these are spawned serialized (DefinedStructure) and we don't call an add event below at the moment due to ordering complexities
world.addWorldGenChunkEntities(EntityType.loadEntitiesRecursive(nbt, world).filter((entity) -> { world.addWorldGenChunkEntities(EntityType.loadEntitiesRecursive(nbt, world).filter((entity) -> {
@@ -0,0 +0,0 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -0,0 +0,0 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
needsRemoval = true;
} }
checkDupeUUID(world, entity); // Paper - duplicate uuid resolving
return !needsRemoval; return !needsRemoval;
- })); - }));
+ }), position); // Paper - rewrite chunk system + }), position); // Paper - rewrite chunk system
@ -18222,6 +18223,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ throw new UnsupportedOperationException(); // Paper - rewrite chunk system + throw new UnsupportedOperationException(); // Paper - rewrite chunk system
} }
// Paper start - duplicate uuid resolving
@@ -0,0 +0,0 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
}
// Paper end - duplicate uuid resolving
public CompletableFuture<Either<LevelChunk, ChunkHolder.ChunkLoadingFailure>> prepareTickingChunk(ChunkHolder holder) { public CompletableFuture<Either<LevelChunk, ChunkHolder.ChunkLoadingFailure>> prepareTickingChunk(ChunkHolder holder) {
- CompletableFuture<Either<List<ChunkAccess>, ChunkHolder.ChunkLoadingFailure>> completablefuture = this.getChunkRangeFuture(holder, 1, (i) -> { - CompletableFuture<Either<List<ChunkAccess>, ChunkHolder.ChunkLoadingFailure>> completablefuture = this.getChunkRangeFuture(holder, 1, (i) -> {
- return ChunkStatus.FULL; - return ChunkStatus.FULL;
@ -18912,7 +18917,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
public void removePlayer(SectionPos pos, ServerPlayer player) { public void removePlayer(SectionPos pos, ServerPlayer player) {
@@ -0,0 +0,0 @@ public abstract class DistanceManager { @@ -0,0 +0,0 @@ public abstract class DistanceManager {
if (objectset.isEmpty()) { if (objectset == null || objectset.isEmpty()) { // Paper
this.playersPerChunk.remove(i); this.playersPerChunk.remove(i);
this.naturalSpawnChunkCounter.update(i, Integer.MAX_VALUE, false); this.naturalSpawnChunkCounter.update(i, Integer.MAX_VALUE, false);
- this.playerTicketManager.update(i, Integer.MAX_VALUE, false); - this.playerTicketManager.update(i, Integer.MAX_VALUE, false);
@ -19295,12 +19300,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
Objects.requireNonNull(completablefuture); Objects.requireNonNull(completablefuture);
if (!completablefuture.isDone()) { // Paper if (!completablefuture.isDone()) { // Paper
+ // Paper start - async chunk io/loading
+ io.papermc.paper.chunk.system.scheduling.ChunkTaskScheduler.pushChunkWait(this.level, x1, z1); // Paper - rewrite chunk system + io.papermc.paper.chunk.system.scheduling.ChunkTaskScheduler.pushChunkWait(this.level, x1, z1); // Paper - rewrite chunk system
+ // Paper end com.destroystokyo.paper.io.SyncLoadFinder.logSyncLoad(this.level, x, z); // Paper - Add debug for sync chunk loads
this.level.timings.syncChunkLoad.startTiming(); // Paper this.level.timings.syncChunkLoad.startTiming(); // Paper
chunkproviderserver_b.managedBlock(completablefuture::isDone); chunkproviderserver_b.managedBlock(completablefuture::isDone);
+ io.papermc.paper.chunk.system.scheduling.ChunkTaskScheduler.popChunkWait(); // Paper - async chunk debug // Paper - rewrite chunk system + io.papermc.paper.chunk.system.scheduling.ChunkTaskScheduler.popChunkWait(); // Paper - rewrite chunk system
this.level.timings.syncChunkLoad.stopTiming(); // Paper this.level.timings.syncChunkLoad.stopTiming(); // Paper
} // Paper } // Paper
ichunkaccess = (ChunkAccess) ((Either) completablefuture.join()).map((ichunkaccess1) -> { ichunkaccess = (ChunkAccess) ((Either) completablefuture.join()).map((ichunkaccess1) -> {
@ -19312,7 +19316,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ if (!io.papermc.paper.util.TickThread.isTickThread()) { // Paper - rewrite chunk system + if (!io.papermc.paper.util.TickThread.isTickThread()) { // Paper - rewrite chunk system
return null; return null;
} else { } else {
this.level.getProfiler().incrementCounter("getChunkNow"); return this.getChunkAtIfLoadedMainThread(chunkX, chunkZ); // Paper - Perf: Optimise getChunkAt calls for loaded chunks
@@ -0,0 +0,0 @@ public class ServerChunkCache extends ChunkSource { @@ -0,0 +0,0 @@ public class ServerChunkCache extends ChunkSource {
} }
@ -19649,10 +19653,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
io.papermc.paper.chunk.system.ChunkSystem.scheduleChunkLoad( io.papermc.paper.chunk.system.ChunkSystem.scheduleChunkLoad(
- this, cx, cz, net.minecraft.world.level.chunk.ChunkStatus.FULL, true, priority, consumer - this, cx, cz, net.minecraft.world.level.chunk.ChunkStatus.FULL, true, priority, consumer
+ this, cx, cz, chunkStatus, true, priority, consumer + this, cx, cz, chunkStatus, true, priority, consumer
+ ); );
+ } }
+ } }
+ } }
- // Paper end
+ +
+ public final void loadChunksForMoveAsync(AABB axisalignedbb, ca.spottedleaf.concurrentutil.executor.standard.PrioritisedExecutor.Priority priority, + public final void loadChunksForMoveAsync(AABB axisalignedbb, ca.spottedleaf.concurrentutil.executor.standard.PrioritisedExecutor.Priority priority,
+ java.util.function.Consumer<List<net.minecraft.world.level.chunk.ChunkAccess>> onLoad) { + java.util.function.Consumer<List<net.minecraft.world.level.chunk.ChunkAccess>> onLoad) {
@ -19742,8 +19747,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ throw new IllegalArgumentException( + throw new IllegalArgumentException(
+ "Entity chunk coordinate and serialized data do not have matching coordinates, trying to serialize coordinate " + pos.toString() + "Entity chunk coordinate and serialized data do not have matching coordinates, trying to serialize coordinate " + pos.toString()
+ + " but compound says coordinate is " + nbtPos + " for world: " + this + + " but compound says coordinate is " + nbtPos + " for world: " + this
); + );
} + }
+ super.write(pos, nbt); + super.write(pos, nbt);
+ } + }
+ } + }
@ -19841,9 +19846,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ if (this.viewDistances.compareAndSet(curr, update.apply(curr))) { + if (this.viewDistances.compareAndSet(curr, update.apply(curr))) {
+ return; + return;
+ } + }
} + }
} + }
- // Paper end
+ +
+ public void setTickViewDistance(final int distance) { + public void setTickViewDistance(final int distance) {
+ if ((distance < io.papermc.paper.chunk.system.RegionizedPlayerChunkLoader.MIN_VIEW_DISTANCE || distance > io.papermc.paper.chunk.system.RegionizedPlayerChunkLoader.MAX_VIEW_DISTANCE)) { + if ((distance < io.papermc.paper.chunk.system.RegionizedPlayerChunkLoader.MIN_VIEW_DISTANCE || distance > io.papermc.paper.chunk.system.RegionizedPlayerChunkLoader.MAX_VIEW_DISTANCE)) {
@ -19872,8 +19876,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ }); + });
+ } + }
// Add env and gen to constructor, IWorldDataServer -> WorldDataServer // Paper start - optimise getPlayerByUUID
public ServerLevel(MinecraftServer minecraftserver, Executor executor, LevelStorageSource.LevelStorageAccess convertable_conversionsession, PrimaryLevelData iworlddataserver, ResourceKey<Level> resourcekey, LevelStem worlddimension, ChunkProgressListener worldloadlistener, boolean flag, long i, List<CustomSpawner> list, boolean flag1, @Nullable RandomSequences randomsequences, org.bukkit.World.Environment env, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider) { @Nullable
@@ -0,0 +0,0 @@ public class ServerLevel extends Level implements WorldGenLevel { @@ -0,0 +0,0 @@ public class ServerLevel extends Level implements WorldGenLevel {
// CraftBukkit end // CraftBukkit end
boolean flag2 = minecraftserver.forceSynchronousWrites(); boolean flag2 = minecraftserver.forceSynchronousWrites();
@ -19905,7 +19909,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ this.entityLookup = new io.papermc.paper.chunk.system.entity.EntityLookup(this, new EntityCallbacks()); // Paper - rewrite chunk system + this.entityLookup = new io.papermc.paper.chunk.system.entity.EntityLookup(this, new EntityCallbacks()); // Paper - rewrite chunk system
} }
/** @deprecated */ // Paper start
@@ -0,0 +0,0 @@ public class ServerLevel extends Level implements WorldGenLevel { @@ -0,0 +0,0 @@ public class ServerLevel extends Level implements WorldGenLevel {
gameprofilerfiller.push("checkDespawn"); gameprofilerfiller.push("checkDespawn");
entity.checkDespawn(); entity.checkDespawn();
@ -19935,7 +19939,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
protected void tickTime() { protected void tickTime() {
@@ -0,0 +0,0 @@ public class ServerLevel extends Level implements WorldGenLevel { @@ -0,0 +0,0 @@ public class ServerLevel extends Level implements WorldGenLevel {
} // Paper end - Incremental chunk and player saving
public void save(@Nullable ProgressListener progressListener, boolean flush, boolean savingDisabled) { public void save(@Nullable ProgressListener progressListener, boolean flush, boolean savingDisabled) {
+ // Paper start - rewrite chunk system - add close param + // Paper start - rewrite chunk system - add close param
@ -20127,8 +20131,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java --- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java +++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
@@ -0,0 +0,0 @@ public class ServerPlayer extends Player { @@ -0,0 +0,0 @@ public class ServerPlayer extends Player {
public boolean isRealPlayer; // Paper
public final com.destroystokyo.paper.util.misc.PooledLinkedHashSets.PooledObjectLinkedOpenHashSet<ServerPlayer> cachedSingleHashSet; // Paper public final com.destroystokyo.paper.util.misc.PooledLinkedHashSets.PooledObjectLinkedOpenHashSet<ServerPlayer> cachedSingleHashSet; // Paper
public com.destroystokyo.paper.event.entity.PlayerNaturallySpawnCreaturesEvent playerNaturallySpawnedEvent; // Paper - PlayerNaturallySpawnCreaturesEvent
+ // Paper start - replace player chunk loader + // Paper start - replace player chunk loader
+ private final java.util.concurrent.atomic.AtomicReference<io.papermc.paper.chunk.system.RegionizedPlayerChunkLoader.ViewDistances> viewDistances = new java.util.concurrent.atomic.AtomicReference<>(new io.papermc.paper.chunk.system.RegionizedPlayerChunkLoader.ViewDistances(-1, -1, -1)); + private final java.util.concurrent.atomic.AtomicReference<io.papermc.paper.chunk.system.RegionizedPlayerChunkLoader.ViewDistances> viewDistances = new java.util.concurrent.atomic.AtomicReference<>(new io.papermc.paper.chunk.system.RegionizedPlayerChunkLoader.ViewDistances(-1, -1, -1));
@ -20498,7 +20502,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl @@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
this.disconnect(Component.translatable("disconnect.spam")); server.scheduleOnMain(() -> this.disconnect(Component.translatable("disconnect.spam"))); // Paper - AsyncTabCompleteEvent
return; return;
} }
+ // Paper start + // Paper start
@ -20509,8 +20513,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ // Paper end + // Paper end
// CraftBukkit end // CraftBukkit end
StringReader stringreader = new StringReader(packet.getCommand()); // Paper start - AsyncTabCompleteEvent
TAB_COMPLETE_EXECUTOR.execute(() -> {
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/players/PlayerList.java --- a/src/main/java/net/minecraft/server/players/PlayerList.java
@ -20757,12 +20761,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
return this.countPlayerPassengers() == 1; return this.countPlayerPassengers() == 1;
} }
@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S @@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
} return;
}
public final void setPosRaw(double x, double y, double z) { // Paper end - Block invalid positions and bounding box
+ // Paper start - rewrite chunk system + // Paper start - rewrite chunk system
+ if (this.updatingSectionStatus) { + if (this.updatingSectionStatus) {
+ LOGGER.error("Refusing to update position for entity " + this + " to position " + new Vec3(x, y, z) + " since it is processing a section status update", new Throwable()); + LOGGER.error("Refusing to update position for entity {} to position {} since it is processing a section status update", this, new Vec3(x, y, z), new Throwable());
+ return; + return;
+ } + }
+ // Paper end - rewrite chunk system + // Paper end - rewrite chunk system
@ -21092,8 +21096,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
if ((i & 1) != 0) { if ((i & 1) != 0) {
@@ -0,0 +0,0 @@ public abstract class Level implements LevelAccessor, AutoCloseable { @@ -0,0 +0,0 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
return this.capturedTileEntities.get(blockposition);
} }
// Paper end - Perf: Optimize capturedTileEntities lookup
// CraftBukkit end // CraftBukkit end
- return this.isOutsideBuildHeight(blockposition) ? null : (!this.isClientSide && Thread.currentThread() != this.thread ? null : this.getChunkAt(blockposition).getBlockEntity(blockposition, LevelChunk.EntityCreationType.IMMEDIATE)); - return this.isOutsideBuildHeight(blockposition) ? null : (!this.isClientSide && Thread.currentThread() != this.thread ? null : this.getChunkAt(blockposition).getBlockEntity(blockposition, LevelChunk.EntityCreationType.IMMEDIATE));
+ return this.isOutsideBuildHeight(blockposition) ? null : (!this.isClientSide && !io.papermc.paper.util.TickThread.isTickThread() ? null : this.getChunkAt(blockposition).getBlockEntity(blockposition, LevelChunk.EntityCreationType.IMMEDIATE)); // Paper - rewrite chunk system + return this.isOutsideBuildHeight(blockposition) ? null : (!this.isClientSide && !io.papermc.paper.util.TickThread.isTickThread() ? null : this.getChunkAt(blockposition).getBlockEntity(blockposition, LevelChunk.EntityCreationType.IMMEDIATE)); // Paper - rewrite chunk system
@ -21180,9 +21184,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@Nullable @Nullable
@@ -0,0 +0,0 @@ public abstract class Level implements LevelAccessor, AutoCloseable { @@ -0,0 +0,0 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
return range <= 0 ? 64.0 * 64.0 : range * range; // 64 is taken from default in ServerLevel#levelEvent
private ExplosionInteraction() {}
} }
// Paper end - respect global sound events gamerule
+ // Paper start + // Paper start
+ //protected final io.papermc.paper.world.EntitySliceManager entitySliceManager; // Paper - rewrite chunk system + //protected final io.papermc.paper.world.EntitySliceManager entitySliceManager; // Paper - rewrite chunk system
+ +
@ -21524,10 +21528,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java --- a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java +++ b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java
@@ -0,0 +0,0 @@ public class ChunkSerializer { @@ -0,0 +0,0 @@ public class ChunkSerializer {
}
public ChunkSerializer() {} }
// Paper end - guard against serializing mismatching coordinates
+ // Paper start + // Paper start - rewrite chunk system
+ public static final class InProgressChunkHolder { + public static final class InProgressChunkHolder {
+ +
+ public final ProtoChunk protoChunk; + public final ProtoChunk protoChunk;
@ -21538,17 +21542,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ this.protoChunk = protoChunk; + this.protoChunk = protoChunk;
+ } + }
+ } + }
+ // Paper end
+
public static ProtoChunk read(ServerLevel world, PoiManager poiStorage, ChunkPos chunkPos, CompoundTag nbt) { public static ProtoChunk read(ServerLevel world, PoiManager poiStorage, ChunkPos chunkPos, CompoundTag nbt) {
+ // Paper start - add variant for async calls + InProgressChunkHolder holder = readInProgressChunkHolder(world, poiStorage, chunkPos, nbt);
+ InProgressChunkHolder holder = loadChunk(world, poiStorage, chunkPos, nbt, true);
+ return holder.protoChunk; + return holder.protoChunk;
+ } + }
+ +
+ public static InProgressChunkHolder loadChunk(ServerLevel world, PoiManager poiStorage, ChunkPos chunkPos, CompoundTag nbt, boolean distinguish) { + public static InProgressChunkHolder readInProgressChunkHolder(ServerLevel world, PoiManager poiStorage, ChunkPos chunkPos, CompoundTag nbt) {
+ // Paper end + // Paper end - rewrite chunk system
ChunkPos chunkcoordintpair1 = new ChunkPos(nbt.getInt("xPos"), nbt.getInt("zPos")); ChunkPos chunkcoordintpair1 = new ChunkPos(nbt.getInt("xPos"), nbt.getInt("zPos")); // Paper - guard against serializing mismatching coordinates; diff on change, see ChunkSerializer#getChunkCoordinate
if (!Objects.equals(chunkPos, chunkcoordintpair1)) { if (!Objects.equals(chunkPos, chunkcoordintpair1)) {
@@ -0,0 +0,0 @@ public class ChunkSerializer { @@ -0,0 +0,0 @@ public class ChunkSerializer {
@ -21768,15 +21769,20 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ // Paper end - async chunk io + // Paper end - async chunk io
- public void write(ChunkPos chunkPos, CompoundTag nbt) { - public void write(ChunkPos chunkPos, CompoundTag nbt) {
+ public void write(ChunkPos chunkPos, CompoundTag nbt) throws IOException { // Paper - rewrite chunk system; async chunk io
// Paper start - guard against serializing mismatching coordinates
if (nbt != null && !chunkPos.equals(ChunkSerializer.getChunkCoordinate(nbt))) {
final String world = (this instanceof net.minecraft.server.level.ChunkMap) ? ((net.minecraft.server.level.ChunkMap) this).level.getWorld().getName() : null;
@@ -0,0 +0,0 @@ public class ChunkStorage implements AutoCloseable {
+ " but compound says coordinate is " + ChunkSerializer.getChunkCoordinate(nbt) + (world == null ? " for an unknown world" : (" for world: " + world)));
}
// Paper end - guard against serializing mismatching coordinates
- this.worker.store(chunkPos, nbt); - this.worker.store(chunkPos, nbt);
+ // Paper start - async chunk io + this.regionFileCache.write(chunkPos, nbt); // Paper - rewrite chunk system; async chunk io
+ public void write(ChunkPos chunkPos, CompoundTag nbt) throws IOException {
+ this.regionFileCache.write(chunkPos, nbt);
+ // Paper end - Async chunk loading
if (this.legacyStructureHandler != null) { if (this.legacyStructureHandler != null) {
+ synchronized (this.persistentDataLock) { // Paper - Async chunk loading + synchronized (this.persistentDataLock) { // Paper - rewrite chunk system; async chunk io
this.legacyStructureHandler.removeIndex(chunkPos.toLong()); this.legacyStructureHandler.removeIndex(chunkPos.toLong());
+ } // Paper - Async chunk loading + } // Paper - rewrite chunk system; async chunk io
} }
} }
@ -22084,7 +22090,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ return null; + return null;
+ } + }
+ // Paper end - cache regionfile does not exist state + // Paper end - cache regionfile does not exist state
if (this.regionCache.size() >= 256) { if (this.regionCache.size() >= io.papermc.paper.configuration.GlobalConfiguration.get().misc.regionFileCacheSize) { // Paper - Sanitise RegionFileCache and make configurable
((RegionFile) this.regionCache.removeLast()).close(); ((RegionFile) this.regionCache.removeLast()).close();
} }
@ -22143,22 +22149,28 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
protected void write(ChunkPos pos, @Nullable CompoundTag nbt) throws IOException { protected void write(ChunkPos pos, @Nullable CompoundTag nbt) throws IOException {
- RegionFile regionfile = this.getRegionFile(pos, false); // CraftBukkit - RegionFile regionfile = this.getRegionFile(pos, false); // CraftBukkit
+ RegionFile regionfile = this.getRegionFile(pos, nbt == null, true); // CraftBukkit // Paper // Paper start - rewrite chunk system + // Paper start - rewrite chunk system
+ RegionFile regionfile = this.getRegionFile(pos, nbt == null, true); // CraftBukkit
+ if (nbt == null && regionfile == null) { + if (nbt == null && regionfile == null) {
+ return; + return;
+ } + }
+ // Paper end - rewrite chunk system + // Paper end - rewrite chunk system
+ try { // Paper // Paper start - Chunk save reattempt
int attempts = 0;
if (nbt == null) { Exception lastException = null;
regionfile.clear(pos);
@@ -0,0 +0,0 @@ public class RegionFileStorage implements AutoCloseable { @@ -0,0 +0,0 @@ public class RegionFileStorage implements AutoCloseable {
return;
} catch (Exception ex) {
lastException = ex;
+ // Paper start - rewrite chunk system
+ } finally {
+ regionfile.fileLock.unlock();
+ // Paper end - rewrite chunk system
} }
} }
+ } finally { // Paper start @@ -0,0 +0,0 @@ public class RegionFileStorage implements AutoCloseable {
+ regionfile.fileLock.unlock(); // Paper end - Chunk save reattempt
+ } // Paper end
} }
- public void close() throws IOException { - public void close() throws IOException {
@ -23004,10 +23016,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
private static WatchdogThread instance; private static WatchdogThread instance;
@@ -0,0 +0,0 @@ public class WatchdogThread extends Thread @@ -0,0 +0,0 @@ public class WatchdogThread extends Thread
// // Paper end - Different message for short timeout
log.log( Level.SEVERE, "------------------------------" ); log.log( Level.SEVERE, "------------------------------" );
log.log( Level.SEVERE, "Server thread dump (Look for plugins here before reporting to Spigot!):" ); log.log( Level.SEVERE, "Server thread dump (Look for plugins here before reporting to Paper!):" ); // Paper
+ io.papermc.paper.chunk.system.scheduling.ChunkTaskScheduler.dumpAllChunkLoadInfo(isLongTimeout); // Paper // Paper - rewrite chunk system + io.papermc.paper.chunk.system.scheduling.ChunkTaskScheduler.dumpAllChunkLoadInfo(isLongTimeout); // Paper - rewrite chunk system
WatchdogThread.dumpThread( ManagementFactory.getThreadMXBean().getThreadInfo( MinecraftServer.getServer().serverThread.getId(), Integer.MAX_VALUE ), log ); WatchdogThread.dumpThread( ManagementFactory.getThreadMXBean().getThreadInfo( MinecraftServer.getServer().serverThread.getId(), Integer.MAX_VALUE ), log );
log.log( Level.SEVERE, "------------------------------" ); log.log( Level.SEVERE, "------------------------------" );
// //

View file

@ -15,11 +15,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java --- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java +++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
@@ -0,0 +0,0 @@ public class RegionFileStorage implements AutoCloseable { @@ -0,0 +0,0 @@ public class RegionFileStorage implements AutoCloseable {
return null; if (regionfile != null) {
} return regionfile;
// Paper end - cache regionfile does not exist state } else {
- if (this.regionCache.size() >= 256) { - if (this.regionCache.size() >= 256) {
+ if (this.regionCache.size() >= io.papermc.paper.configuration.GlobalConfiguration.get().misc.regionFileCacheSize) { // Paper - Sanitise RegionFileCache and make configurable. + if (this.regionCache.size() >= io.papermc.paper.configuration.GlobalConfiguration.get().misc.regionFileCacheSize) { // Paper - Sanitise RegionFileCache and make configurable
((RegionFile) this.regionCache.removeLast()).close(); ((RegionFile) this.regionCache.removeLast()).close();
} }

View file

@ -66,7 +66,7 @@ diff --git a/src/main/java/org/spigotmc/WatchdogThread.java b/src/main/java/org/
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/spigotmc/WatchdogThread.java --- a/src/main/java/org/spigotmc/WatchdogThread.java
+++ b/src/main/java/org/spigotmc/WatchdogThread.java +++ b/src/main/java/org/spigotmc/WatchdogThread.java
@@ -0,0 +0,0 @@ public final class WatchdogThread extends io.papermc.paper.util.TickThread // Pa @@ -0,0 +0,0 @@ public class WatchdogThread extends Thread
private WatchdogThread(long timeoutTime, boolean restart) private WatchdogThread(long timeoutTime, boolean restart)
{ {
@ -75,7 +75,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
this.timeoutTime = timeoutTime; this.timeoutTime = timeoutTime;
this.restart = restart; this.restart = restart;
} }
@@ -0,0 +0,0 @@ public final class WatchdogThread extends io.papermc.paper.util.TickThread // Pa @@ -0,0 +0,0 @@ public class WatchdogThread extends Thread
{ {
Logger log = Bukkit.getServer().getLogger(); Logger log = Bukkit.getServer().getLogger();
log.log( Level.SEVERE, "------------------------------" ); log.log( Level.SEVERE, "------------------------------" );
@ -93,12 +93,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
// //
if ( net.minecraft.world.level.Level.lastPhysicsProblem != null ) if ( net.minecraft.world.level.Level.lastPhysicsProblem != null )
{ {
@@ -0,0 +0,0 @@ public final class WatchdogThread extends io.papermc.paper.util.TickThread // Pa @@ -0,0 +0,0 @@ public class WatchdogThread extends Thread
} }
// //
log.log( Level.SEVERE, "------------------------------" ); log.log( Level.SEVERE, "------------------------------" );
- log.log( Level.SEVERE, "Server thread dump (Look for plugins here before reporting to Spigot!):" ); - log.log( Level.SEVERE, "Server thread dump (Look for plugins here before reporting to Spigot!):" );
+ log.log( Level.SEVERE, "Server thread dump (Look for plugins here before reporting to Paper!):" ); // Paper + log.log( Level.SEVERE, "Server thread dump (Look for plugins here before reporting to Paper!):" ); // Paper
io.papermc.paper.chunk.system.scheduling.ChunkTaskScheduler.dumpAllChunkLoadInfo(isLongTimeout); // Paper // Paper - rewrite chunk system
WatchdogThread.dumpThread( ManagementFactory.getThreadMXBean().getThreadInfo( MinecraftServer.getServer().serverThread.getId(), Integer.MAX_VALUE ), log ); WatchdogThread.dumpThread( ManagementFactory.getThreadMXBean().getThreadInfo( MinecraftServer.getServer().serverThread.getId(), Integer.MAX_VALUE ), log );
log.log( Level.SEVERE, "------------------------------" ); log.log( Level.SEVERE, "------------------------------" );
//

View file

@ -8,7 +8,7 @@ diff --git a/src/main/java/org/spigotmc/WatchdogThread.java b/src/main/java/org/
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/spigotmc/WatchdogThread.java --- a/src/main/java/org/spigotmc/WatchdogThread.java
+++ b/src/main/java/org/spigotmc/WatchdogThread.java +++ b/src/main/java/org/spigotmc/WatchdogThread.java
@@ -0,0 +0,0 @@ public final class WatchdogThread extends io.papermc.paper.util.TickThread // Pa @@ -0,0 +0,0 @@ public class WatchdogThread extends Thread
while ( !this.stopping ) while ( !this.stopping )
{ {
// //

View file

@ -19,9 +19,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
private QueryThreadGs4 queryThreadGs4; private QueryThreadGs4 queryThreadGs4;
// private final RemoteControlCommandListener rconConsoleSource; // CraftBukkit - remove field // private final RemoteControlCommandListener rconConsoleSource; // CraftBukkit - remove field
@@ -0,0 +0,0 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface @@ -0,0 +0,0 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
return; }
}
// Paper end - rewrite chunk system public void handleConsoleInput(String command, CommandSourceStack commandSource) {
- this.consoleInput.add(new ConsoleInput(command, commandSource)); - this.consoleInput.add(new ConsoleInput(command, commandSource));
+ this.serverCommandQueue.add(new ConsoleInput(command, commandSource)); // Paper - Perf: use proper queue + this.serverCommandQueue.add(new ConsoleInput(command, commandSource)); // Paper - Perf: use proper queue
} }

View file

@ -115,8 +115,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ // Paper end - Incremental chunk and player saving + // Paper end - Incremental chunk and player saving
+ +
public void save(@Nullable ProgressListener progressListener, boolean flush, boolean savingDisabled) { public void save(@Nullable ProgressListener progressListener, boolean flush, boolean savingDisabled) {
// Paper start - rewrite chunk system - add close param ServerChunkCache chunkproviderserver = this.getChunkSource();
this.save(progressListener, flush, savingDisabled, false);
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java --- a/src/main/java/net/minecraft/server/level/ServerPlayer.java

View file

@ -2,8 +2,8 @@ import os
import sys import sys
# Use inside of server patch dir # Use inside of server patch dir
# py ../../scripts/moveback.py '' # py ../../scripts/moveback.py 'Rewrite chunk system'
patch_target = 100 # TODO: Update this patch_target = 400 # TODO: Update this
def increment_number(filename): def increment_number(filename):