Finish moving patches back and improving compilable state

This commit is contained in:
Nassim Jahnke 2024-01-25 10:54:46 +01:00
parent 52438f04a0
commit d71804b7f8
17 changed files with 124 additions and 69 deletions

View file

@ -18,8 +18,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
// Spigot start // Spigot start
+ org.spigotmc.WatchdogThread.hasStarted = true; // Paper + org.spigotmc.WatchdogThread.hasStarted = true; // Paper
Arrays.fill( this.recentTps, 20 ); Arrays.fill( this.recentTps, 20 );
long tickSection = Util.getMillis(), tickCount = 1; // Paper start - further improve server tick loop
while (this.running) { long tickSection = Util.getNanos();
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

@ -51,7 +51,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java --- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
@@ -0,0 +0,0 @@ public final class CraftMagicNumbers implements UnsafeValues { @@ -0,0 +0,0 @@ public final class CraftMagicNumbers implements UnsafeValues {
return CraftItemStack.asCraftMirror(net.minecraft.world.item.ItemStack.of(ca.spottedleaf.dataconverter.minecraft.MCDataConverter.convertTag(ca.spottedleaf.dataconverter.minecraft.datatypes.MCTypeRegistry.ITEM_STACK, compound, dataVersion, getDataVersion()))); return CraftItemStack.asCraftMirror(net.minecraft.world.item.ItemStack.of(compound));
} }
+ @Override + @Override
@ -71,8 +71,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ +
+ CompoundTag compound = deserializeNbtFromBytes(data); + CompoundTag compound = deserializeNbtFromBytes(data);
+ int dataVersion = compound.getInt("DataVersion"); + int dataVersion = compound.getInt("DataVersion");
+ compound = ca.spottedleaf.dataconverter.minecraft.MCDataConverter.convertTag(ca.spottedleaf.dataconverter.minecraft.datatypes.MCTypeRegistry.ENTITY, compound, dataVersion, getDataVersion()); + compound = (CompoundTag) MinecraftServer.getServer().fixerUpper.update(References.ENTITY, new Dynamic<>(NbtOps.INSTANCE, compound), dataVersion, this.getDataVersion()).getValue();
+ if (!preserveUUID) compound.remove("UUID"); // Generate a new UUID so we don't have to worry about deserializing the same entity twice + if (!preserveUUID) {
+ // Generate a new UUID so we don't have to worry about deserializing the same entity twice
+ compound.remove("UUID");
+ }
+ return net.minecraft.world.entity.EntityType.create(compound, ((org.bukkit.craftbukkit.CraftWorld) world).getHandle()) + return net.minecraft.world.entity.EntityType.create(compound, ((org.bukkit.craftbukkit.CraftWorld) world).getHandle())
+ .orElseThrow(() -> new IllegalArgumentException("An ID was not found for the data. Did you downgrade?")).getBukkitEntity(); + .orElseThrow(() -> new IllegalArgumentException("An ID was not found for the data. Did you downgrade?")).getBukkitEntity();
+ } + }

View file

@ -28,8 +28,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ Preconditions.checkArgument(data.length > 0, "cannot deserialize nothing"); + Preconditions.checkArgument(data.length > 0, "cannot deserialize nothing");
+ +
+ CompoundTag compound = deserializeNbtFromBytes(data); + CompoundTag compound = deserializeNbtFromBytes(data);
+ int dataVersion = compound.getInt("DataVersion"); + final int dataVersion = compound.getInt("DataVersion");
+ return CraftItemStack.asCraftMirror(net.minecraft.world.item.ItemStack.of(ca.spottedleaf.dataconverter.minecraft.MCDataConverter.convertTag(ca.spottedleaf.dataconverter.minecraft.datatypes.MCTypeRegistry.ITEM_STACK, compound, dataVersion, getDataVersion()))); + compound = (CompoundTag) MinecraftServer.getServer().fixerUpper.update(References.ITEM_STACK, new Dynamic<>(NbtOps.INSTANCE, compound), dataVersion, this.getDataVersion()).getValue();
+ return CraftItemStack.asCraftMirror(net.minecraft.world.item.ItemStack.of(compound));
+ } + }
+ +
+ private byte[] serializeNbtToBytes(CompoundTag compound) { + private byte[] serializeNbtToBytes(CompoundTag compound) {

View file

@ -198,9 +198,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("reload"), new ReloadCommand());
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("syncloadinfo"), new SyncLoadInfoCommand()); + commands.put(Set.of("syncloadinfo"), new SyncLoadInfoCommand());
return commands.entrySet().stream() return commands.entrySet().stream()

View file

@ -14,7 +14,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("fixlight"), new FixLightCommand()); commands.put(Set.of("dumpplugins"), new DumpPluginsCommand());
commands.put(Set.of("syncloadinfo"), new SyncLoadInfoCommand()); commands.put(Set.of("syncloadinfo"), new SyncLoadInfoCommand());
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

@ -13,16 +13,16 @@ 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 {
private static final String SKYLIGHT_STATE_TAG = "starlight.skylight_state"; public static final String BLOCK_LIGHT_TAG = "BlockLight";
private static final String STARLIGHT_VERSION_TAG = "starlight.light_version"; public static final String SKY_LIGHT_TAG = "SkyLight";
// Paper end - replace light engine impl
+ // Paper start - Do not let the server load chunks from newer versions + // Paper start - Do not let the server load chunks from newer versions
+ private static final int CURRENT_DATA_VERSION = net.minecraft.SharedConstants.getCurrentVersion().getDataVersion().getVersion(); + private static final int CURRENT_DATA_VERSION = net.minecraft.SharedConstants.getCurrentVersion().getDataVersion().getVersion();
+ 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 ChunkSerializer() {} public ChunkSerializer() {}
// Paper start - guard against serializing mismatching coordinates
@@ -0,0 +0,0 @@ public class ChunkSerializer { @@ -0,0 +0,0 @@ public class ChunkSerializer {
} }
// Paper end - guard against serializing mismatching coordinates // Paper end - guard against serializing mismatching coordinates

View file

@ -16,11 +16,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/net/minecraft/server/MinecraftServer.java --- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -0,0 +0,0 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa @@ -0,0 +0,0 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
public org.bukkit.craftbukkit.CraftServer server;
public OptionSet options; public OptionSet options;
public org.bukkit.command.ConsoleCommandSender console; public org.bukkit.command.ConsoleCommandSender console;
public ConsoleReader reader;
- public static int currentTick = (int) (System.currentTimeMillis() / 50); - public static int currentTick = (int) (System.currentTimeMillis() / 50);
+ public static int currentTick = 0; // Paper - Further improve tick loop + public static int currentTick; // Paper - improve tick loop
public java.util.Queue<Runnable> processQueue = new java.util.concurrent.ConcurrentLinkedQueue<Runnable>(); public java.util.Queue<Runnable> processQueue = new java.util.concurrent.ConcurrentLinkedQueue<Runnable>();
public int autosavePeriod; public int autosavePeriod;
public Commands vanillaCommandDispatcher; public Commands vanillaCommandDispatcher;
@ -29,7 +29,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
public static final int TPS = 20; public static final int TPS = 20;
public static final int TICK_TIME = 1000000000 / MinecraftServer.TPS; public static final int TICK_TIME = 1000000000 / MinecraftServer.TPS;
- private static final int SAMPLE_INTERVAL = 100; - private static final int SAMPLE_INTERVAL = 100;
+ private static final int SAMPLE_INTERVAL = 20; // Paper + private static final int SAMPLE_INTERVAL = 20; // Paper - improve server tick loop
+ @Deprecated(forRemoval = true) // Paper
public final double[] recentTps = new double[ 3 ]; public final double[] recentTps = new double[ 3 ];
// Spigot end // Spigot end
public final io.papermc.paper.configuration.PaperConfigurations paperConfigurations; // Paper - add paper configuration files public final io.papermc.paper.configuration.PaperConfigurations paperConfigurations; // Paper - add paper configuration files
@ -90,43 +91,47 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ // Paper end + // Paper end
// Spigot End // Spigot End
public static volatile RuntimeException chunkSystemCrash; // Paper - rewrite chunk system protected void runServer() {
@@ -0,0 +0,0 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa @@ -0,0 +0,0 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
org.spigotmc.WatchdogThread.tick(); // Paper
org.spigotmc.WatchdogThread.hasStarted = true; // Paper // Spigot start
Arrays.fill( this.recentTps, 20 ); Arrays.fill( this.recentTps, 20 );
- long tickSection = Util.getMillis(), tickCount = 1; - long tickSection = Util.getMillis(), tickCount = 1;
+ long tickSection = Util.getNanos(), curTime, tickCount = 1; // Paper + // Paper start - further improve server tick loop
+ long tickSection = Util.getNanos();
+ long currentTime;
+ // Paper end - further improve server tick loop
while (this.running) { while (this.running) {
// Paper start - rewrite chunk system long i;
// guarantee that nothing can stop the server from halting if it can at least still tick
@@ -0,0 +0,0 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa @@ -0,0 +0,0 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
} }
// Spigot start // Spigot start
++MinecraftServer.currentTickLong; // Paper - track current tick as a long ++MinecraftServer.currentTickLong; // Paper - track current tick as a long
- if ( tickCount++ % MinecraftServer.SAMPLE_INTERVAL == 0 ) - if ( tickCount++ % MinecraftServer.SAMPLE_INTERVAL == 0 )
+ if ( ++MinecraftServer.currentTick % MinecraftServer.SAMPLE_INTERVAL == 0 ) // Paper - {
{
- long curTime = Util.getMillis(); - long curTime = Util.getMillis();
- double currentTps = 1E3 / ( curTime - tickSection ) * MinecraftServer.SAMPLE_INTERVAL; - double currentTps = 1E3 / ( curTime - tickSection ) * MinecraftServer.SAMPLE_INTERVAL;
- this.recentTps[0] = MinecraftServer.calcTps( this.recentTps[0], 0.92, currentTps ); // 1/exp(5sec/1min) - this.recentTps[0] = MinecraftServer.calcTps( this.recentTps[0], 0.92, currentTps ); // 1/exp(5sec/1min)
- this.recentTps[1] = MinecraftServer.calcTps( this.recentTps[1], 0.9835, currentTps ); // 1/exp(5sec/5min) - this.recentTps[1] = MinecraftServer.calcTps( this.recentTps[1], 0.9835, currentTps ); // 1/exp(5sec/5min)
- this.recentTps[2] = MinecraftServer.calcTps( this.recentTps[2], 0.9945, currentTps ); // 1/exp(5sec/15min) - this.recentTps[2] = MinecraftServer.calcTps( this.recentTps[2], 0.9945, currentTps ); // 1/exp(5sec/15min)
+ // Paper start - tickSection = curTime;
+ curTime = Util.getNanos(); + // Paper start - further improve server tick loop
+ final long diff = curTime - tickSection; + currentTime = Util.getNanos();
+ java.math.BigDecimal currentTps = TPS_BASE.divide(new java.math.BigDecimal(diff), 30, java.math.RoundingMode.HALF_UP); + if (++MinecraftServer.currentTick % MinecraftServer.SAMPLE_INTERVAL == 0) {
+ final long diff = currentTime - tickSection;
+ final java.math.BigDecimal currentTps = TPS_BASE.divide(new java.math.BigDecimal(diff), 30, java.math.RoundingMode.HALF_UP);
+ tps1.add(currentTps, diff); + tps1.add(currentTps, diff);
+ tps5.add(currentTps, diff); + tps5.add(currentTps, diff);
+ tps15.add(currentTps, diff); + tps15.add(currentTps, diff);
+
+ // Backwards compat with bad plugins + // Backwards compat with bad plugins
+ this.recentTps[0] = tps1.getAverage(); + this.recentTps[0] = tps1.getAverage();
+ this.recentTps[1] = tps5.getAverage(); + this.recentTps[1] = tps5.getAverage();
+ this.recentTps[2] = tps15.getAverage(); + this.recentTps[2] = tps15.getAverage();
+ // Paper end + tickSection = currentTime;
tickSection = curTime; }
- } + // Paper end - further improve server tick loop
+ } else curTime = Util.getNanos(); // Paper
// Spigot end // Spigot end
boolean flag = i == 0L; boolean flag = i == 0L;
@ -136,7 +141,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- MinecraftServer.currentTick = (int) (System.currentTimeMillis() / 50); // CraftBukkit - MinecraftServer.currentTick = (int) (System.currentTimeMillis() / 50); // CraftBukkit
+ //MinecraftServer.currentTick = (int) (System.currentTimeMillis() / 50); // CraftBukkit // Paper - don't overwrite current tick time + //MinecraftServer.currentTick = (int) (System.currentTimeMillis() / 50); // CraftBukkit // Paper - don't overwrite current tick time
+ lastTick = curTime; + lastTick = currentTime;
this.nextTickTimeNanos += i; this.nextTickTimeNanos += i;
this.startMetricsRecordingTick(); this.startMetricsRecordingTick();
this.profiler.push("tick"); this.profiler.push("tick");

View file

@ -25,10 +25,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- /* - /*
- if (!unloadChunk0(x, z, false)) { - if (!unloadChunk0(x, z, false)) {
- return false; - return false;
- }
-
- final long chunkKey = ChunkCoordIntPair.pair(x, z);
- world.getChunkProvider().unloadQueue.remove(chunkKey);
+ // Paper start - implement regenerateChunk method + // Paper start - implement regenerateChunk method
+ final ServerLevel serverLevel = this.world; + final ServerLevel serverLevel = this.world;
+ final net.minecraft.server.level.ServerChunkCache serverChunkCache = serverLevel.getChunkSource(); + final net.minecraft.server.level.ServerChunkCache serverChunkCache = serverLevel.getChunkSource();
@ -53,11 +49,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ list.add(chunkAccess); + list.add(chunkAccess);
+ } + }
+ } + }
+
- net.minecraft.server.Chunk chunk = world.getChunkProvider().generateChunk(x, z);
- PlayerChunk playerChunk = world.getPlayerChunkMap().getChunk(x, z);
- if (playerChunk != null) {
- playerChunk.chunk = chunk;
+ final java.util.concurrent.CompletableFuture<com.mojang.datafixers.util.Either<ChunkAccess, ChunkHolder.ChunkLoadingFailure>> future = chunkStatus.generate( + final java.util.concurrent.CompletableFuture<com.mojang.datafixers.util.Either<ChunkAccess, ChunkHolder.ChunkLoadingFailure>> future = chunkStatus.generate(
+ Runnable::run, + Runnable::run,
+ serverLevel, + serverLevel,
@ -75,21 +67,34 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
} }
- if (chunk != null) { - final long chunkKey = ChunkCoordIntPair.pair(x, z);
- refreshChunk(x, z); - world.getChunkProvider().unloadQueue.remove(chunkKey);
+ for (final BlockPos blockPos : BlockPos.betweenClosed(chunkPos.getMinBlockX(), serverLevel.getMinBuildHeight(), chunkPos.getMinBlockZ(), chunkPos.getMaxBlockX(), serverLevel.getMaxBuildHeight() - 1, chunkPos.getMaxBlockZ())) { + for (final BlockPos blockPos : BlockPos.betweenClosed(chunkPos.getMinBlockX(), serverLevel.getMinBuildHeight(), chunkPos.getMinBlockZ(), chunkPos.getMaxBlockX(), serverLevel.getMaxBuildHeight() - 1, chunkPos.getMaxBlockZ())) {
+ serverChunkCache.blockChanged(blockPos); + serverChunkCache.blockChanged(blockPos);
} + }
- return chunk != null; - net.minecraft.server.Chunk chunk = world.getChunkProvider().generateChunk(x, z);
- */ - PlayerChunk playerChunk = world.getPlayerChunkMap().getChunk(x, z);
- if (playerChunk != null) {
- playerChunk.chunk = chunk;
+ final Set<ChunkPos> chunksToRelight = new HashSet<>(9); + final Set<ChunkPos> chunksToRelight = new HashSet<>(9);
+ for (int chunkX = chunkPos.x - 1; chunkX <= chunkPos.x + 1 ; chunkX++) { + for (int chunkX = chunkPos.x - 1; chunkX <= chunkPos.x + 1 ; chunkX++) {
+ for (int chunkZ = chunkPos.z - 1; chunkZ <= chunkPos.z + 1 ; chunkZ++) { + for (int chunkZ = chunkPos.z - 1; chunkZ <= chunkPos.z + 1 ; chunkZ++) {
+ chunksToRelight.add(new ChunkPos(chunkX, chunkZ)); + chunksToRelight.add(new ChunkPos(chunkX, chunkZ));
+ } + }
+ } }
+ serverChunkCache.getLightEngine().relight(chunksToRelight, pos -> {}, relit -> {});
- if (chunk != null) {
- refreshChunk(x, z);
+ for (final ChunkPos pos : chunksToRelight) {
+ final ChunkAccess chunk = serverChunkCache.getChunk(pos.x, pos.z, false);
+ if (chunk != null) {
+ serverChunkCache.getLightEngine().lightChunk(chunk, false);
+ }
}
- return chunk != null;
- */
+ return true; + return true;
+ // Paper end - implement regenerate chunk method + // Paper end - implement regenerate chunk method
} }

View file

@ -169,7 +169,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ org.spigotmc.WatchdogThread.tick(); // Paper + org.spigotmc.WatchdogThread.tick(); // Paper
org.spigotmc.WatchdogThread.hasStarted = true; // Paper org.spigotmc.WatchdogThread.hasStarted = true; // Paper
Arrays.fill( this.recentTps, 20 ); Arrays.fill( this.recentTps, 20 );
long tickSection = Util.getMillis(), tickCount = 1; // Paper start - further improve server tick loop
@@ -0,0 +0,0 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa @@ -0,0 +0,0 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
JvmProfiler.INSTANCE.onServerTick(this.smoothedTickTimeMillis); JvmProfiler.INSTANCE.onServerTick(this.smoothedTickTimeMillis);
} }

View file

@ -10,6 +10,7 @@ public org.bukkit.craftbukkit.inventory.CraftItemStack handle
public net.minecraft.server.level.ChunkMap getVisibleChunkIfPresent(J)Lnet/minecraft/server/level/ChunkHolder; public net.minecraft.server.level.ChunkMap getVisibleChunkIfPresent(J)Lnet/minecraft/server/level/ChunkHolder;
public net.minecraft.server.level.ServerChunkCache mainThreadProcessor public net.minecraft.server.level.ServerChunkCache mainThreadProcessor
public net.minecraft.server.level.ServerChunkCache$MainThreadExecutor public net.minecraft.server.level.ServerChunkCache$MainThreadExecutor
public net.minecraft.world.level.chunk.LevelChunkSection states
diff --git a/src/main/java/com/destroystokyo/paper/util/concurrent/WeakSeqLock.java b/src/main/java/com/destroystokyo/paper/util/concurrent/WeakSeqLock.java diff --git a/src/main/java/com/destroystokyo/paper/util/concurrent/WeakSeqLock.java b/src/main/java/com/destroystokyo/paper/util/concurrent/WeakSeqLock.java
new file mode 100644 new file mode 100644

View file

@ -11,8 +11,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java --- a/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java
+++ b/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java +++ b/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java
@@ -0,0 +0,0 @@ public abstract class BlockBehaviour implements FeatureElement { @@ -0,0 +0,0 @@ public abstract class BlockBehaviour implements FeatureElement {
this.instrument = blockbase_info.instrument;
this.replaceable = blockbase_info.replaceable; this.replaceable = blockbase_info.replaceable;
this.conditionallyFullOpaque = this.canOcclude & this.useShapeForLightOcclusion; // Paper
} }
+ // Paper start - Perf: impl cached craft block data, lazy load to fix issue with loading at the wrong time + // Paper start - Perf: impl cached craft block data, lazy load to fix issue with loading at the wrong time
+ private org.bukkit.craftbukkit.block.data.CraftBlockData cachedCraftBlockData; + private org.bukkit.craftbukkit.block.data.CraftBlockData cachedCraftBlockData;

View file

@ -10,8 +10,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("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("syncloadinfo"), new SyncLoadInfoCommand()); commands.put(Set.of("syncloadinfo"), new SyncLoadInfoCommand());
+ commands.put(Set.of("dumpitem"), new DumpItemCommand()); + commands.put(Set.of("dumpitem"), new DumpItemCommand());

View file

@ -15270,9 +15270,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("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());
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());
return commands.entrySet().stream() return commands.entrySet().stream()
@ -16748,7 +16748,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
public String getLocalIp() { public String getLocalIp() {
@@ -0,0 +0,0 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa @@ -0,0 +0,0 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
} // Paper end
// Spigot End // Spigot End
+ public static volatile RuntimeException chunkSystemCrash; // Paper - rewrite chunk system + public static volatile RuntimeException chunkSystemCrash; // Paper - rewrite chunk system
@ -16757,8 +16757,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
try { try {
if (!this.initServer()) { if (!this.initServer()) {
@@ -0,0 +0,0 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa @@ -0,0 +0,0 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
Arrays.fill( this.recentTps, 20 ); long currentTime;
long tickSection = Util.getMillis(), tickCount = 1; // Paper end - further improve server tick loop
while (this.running) { while (this.running) {
+ // Paper start - rewrite chunk system + // Paper start - rewrite chunk system
+ // guarantee that nothing can stop the server from halting if it can at least still tick + // guarantee that nothing can stop the server from halting if it can at least still tick

View file

@ -24938,3 +24938,26 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
player.load(nbttagcompound); player.load(nbttagcompound);
} }
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
@@ -0,0 +0,0 @@ public final class CraftMagicNumbers implements UnsafeValues {
CompoundTag compound = deserializeNbtFromBytes(data);
final int dataVersion = compound.getInt("DataVersion");
- compound = (CompoundTag) MinecraftServer.getServer().fixerUpper.update(References.ITEM_STACK, new Dynamic<>(NbtOps.INSTANCE, compound), dataVersion, this.getDataVersion()).getValue();
- return CraftItemStack.asCraftMirror(net.minecraft.world.item.ItemStack.of(compound));
+ return CraftItemStack.asCraftMirror(net.minecraft.world.item.ItemStack.of(ca.spottedleaf.dataconverter.minecraft.MCDataConverter.convertTag(ca.spottedleaf.dataconverter.minecraft.datatypes.MCTypeRegistry.ITEM_STACK, compound, dataVersion, this.getDataVersion()))); // Paper - rewrite dataconverter
}
@Override
@@ -0,0 +0,0 @@ public final class CraftMagicNumbers implements UnsafeValues {
CompoundTag compound = deserializeNbtFromBytes(data);
int dataVersion = compound.getInt("DataVersion");
- compound = (CompoundTag) MinecraftServer.getServer().fixerUpper.update(References.ENTITY, new Dynamic<>(NbtOps.INSTANCE, compound), dataVersion, this.getDataVersion()).getValue();
+ compound = ca.spottedleaf.dataconverter.minecraft.MCDataConverter.convertTag(ca.spottedleaf.dataconverter.minecraft.datatypes.MCTypeRegistry.ENTITY, compound, dataVersion, getDataVersion()); // Paper - rewrite dataconverter
if (!preserveUUID) {
// Generate a new UUID so we don't have to worry about deserializing the same entity twice
compound.remove("UUID");

View file

@ -7,7 +7,6 @@ See https://github.com/PaperMC/Starlight
== AT == == AT ==
public net.minecraft.server.level.ChunkHolder broadcast(Lnet/minecraft/network/protocol/Packet;Z)V public net.minecraft.server.level.ChunkHolder broadcast(Lnet/minecraft/network/protocol/Packet;Z)V
public net.minecraft.world.level.chunk.LevelChunkSection states
diff --git a/src/main/java/ca/spottedleaf/starlight/common/light/BlockStarLightEngine.java b/src/main/java/ca/spottedleaf/starlight/common/light/BlockStarLightEngine.java diff --git a/src/main/java/ca/spottedleaf/starlight/common/light/BlockStarLightEngine.java b/src/main/java/ca/spottedleaf/starlight/common/light/BlockStarLightEngine.java
new file mode 100644 new file mode 100644
@ -4351,9 +4350,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("reload"), new ReloadCommand()); commands.put(Set.of("dumpitem"), new DumpItemCommand());
commands.put(Set.of("version"), new VersionCommand()); commands.put(Set.of("mobcaps", "playermobcaps"), new MobcapsCommand());
commands.put(Set.of("dumpplugins"), new DumpPluginsCommand()); commands.put(Set.of("dumplisteners"), new DumpListenersCommand());
+ commands.put(Set.of("fixlight"), new FixLightCommand()); + commands.put(Set.of("fixlight"), new FixLightCommand());
return commands.entrySet().stream() return commands.entrySet().stream()
@ -4892,8 +4891,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
this.replaceable = blockbase_info.replaceable; this.replaceable = blockbase_info.replaceable;
+ this.conditionallyFullOpaque = this.canOcclude & this.useShapeForLightOcclusion; // Paper + this.conditionallyFullOpaque = this.canOcclude & this.useShapeForLightOcclusion; // Paper
} }
// Paper start - Perf: impl cached craft block data, lazy load to fix issue with loading at the wrong time
private boolean calculateSolid() { private org.bukkit.craftbukkit.block.data.CraftBlockData cachedCraftBlockData;
@@ -0,0 +0,0 @@ public abstract class BlockBehaviour implements FeatureElement { @@ -0,0 +0,0 @@ public abstract class BlockBehaviour implements FeatureElement {
return this.shapeExceedsCube; return this.shapeExceedsCube;
} }
@ -5200,9 +5199,9 @@ 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 static final String BLOCK_LIGHT_TAG = "BlockLight"; private static final int CURRENT_DATA_VERSION = net.minecraft.SharedConstants.getCurrentVersion().getDataVersion().getVersion();
public static final String SKY_LIGHT_TAG = "SkyLight"; private static final boolean JUST_CORRUPT_IT = Boolean.getBoolean("Paper.ignoreWorldDataVersion");
// Paper end - Do not let the server load chunks from newer versions
+ // Paper start - replace light engine impl + // Paper start - replace light engine impl
+ private static final int STARLIGHT_LIGHT_VERSION = 9; + private static final int STARLIGHT_LIGHT_VERSION = 9;
+ +
@ -5213,7 +5212,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ +
public ChunkSerializer() {} public ChunkSerializer() {}
public static ProtoChunk read(ServerLevel world, PoiManager poiStorage, ChunkPos chunkPos, CompoundTag nbt) { // Paper start - guard against serializing mismatching coordinates
@@ -0,0 +0,0 @@ public class ChunkSerializer { @@ -0,0 +0,0 @@ public class ChunkSerializer {
} }
@ -5403,3 +5402,21 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
public static ChunkStatus.ChunkType getChunkTypeFromTag(@Nullable CompoundTag nbt) { public static ChunkStatus.ChunkType getChunkTypeFromTag(@Nullable CompoundTag nbt) {
return nbt != null ? ChunkStatus.byName(nbt.getString("Status")).getChunkType() : ChunkStatus.ChunkType.PROTOCHUNK; return nbt != null ? ChunkStatus.byName(nbt.getString("Status")).getChunkType() : ChunkStatus.ChunkType.PROTOCHUNK;
} }
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -0,0 +0,0 @@ public class CraftWorld extends CraftRegionAccessor implements World {
}
}
- for (final ChunkPos pos : chunksToRelight) {
- final ChunkAccess chunk = serverChunkCache.getChunk(pos.x, pos.z, false);
- if (chunk != null) {
- serverChunkCache.getLightEngine().lightChunk(chunk, false);
- }
- }
+ serverChunkCache.getLightEngine().relight(chunksToRelight, pos -> {}, relit -> {}); // Paper - Starlight
return true;
// Paper end - implement regenerate chunk method

View file

@ -267,7 +267,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
public OptionSet options; public OptionSet options;
public org.bukkit.command.ConsoleCommandSender console; public org.bukkit.command.ConsoleCommandSender console;
- public ConsoleReader reader; - public ConsoleReader reader;
public static int currentTick = (int) (System.currentTimeMillis() / 50); public static int currentTick; // Paper - improve tick loop
public java.util.Queue<Runnable> processQueue = new java.util.concurrent.ConcurrentLinkedQueue<Runnable>(); public java.util.Queue<Runnable> processQueue = new java.util.concurrent.ConcurrentLinkedQueue<Runnable>();
public int autosavePeriod; public int autosavePeriod;
@@ -0,0 +0,0 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa @@ -0,0 +0,0 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa

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 'Rewrite chunk system' # py ../../scripts/moveback.py ''
patch_target = 992 # TODO: Update this patch_target = 990 # TODO: Update this
def increment_number(filename): def increment_number(filename):