diff --git a/patches/server/Add-Early-Warning-Feature-to-WatchDog.patch b/patches/server/Add-Early-Warning-Feature-to-WatchDog.patch index 07359592df..614d4d1c79 100644 --- a/patches/server/Add-Early-Warning-Feature-to-WatchDog.patch +++ b/patches/server/Add-Early-Warning-Feature-to-WatchDog.patch @@ -43,10 +43,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 this.updateStatusIcon(this.status); // Spigot start -+ org.spigotmc.WatchdogThread.hasStarted = true; // Paper ++ org.spigotmc.WatchdogThread.hasStarted = true; // Paper Arrays.fill( recentTps, 20 ); - long start = System.nanoTime(), curTime, tickSection = start; // Paper - Further improve server tick loop - lastTick = start - TICK_TIME; // Paper + long start = System.nanoTime(), curTime, tickSection = start; // Paper - Further improve server tick loop + lastTick = start - TICK_TIME; // Paper diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java diff --git a/patches/unapplied/server/Dead-Player-s-shouldn-t-be-able-to-move.patch b/patches/server/Dead-Player-s-shouldn-t-be-able-to-move.patch similarity index 100% rename from patches/unapplied/server/Dead-Player-s-shouldn-t-be-able-to-move.patch rename to patches/server/Dead-Player-s-shouldn-t-be-able-to-move.patch diff --git a/patches/unapplied/server/Do-not-allow-bees-to-load-chunks-for-beehives.patch b/patches/server/Do-not-allow-bees-to-load-chunks-for-beehives.patch similarity index 100% rename from patches/unapplied/server/Do-not-allow-bees-to-load-chunks-for-beehives.patch rename to patches/server/Do-not-allow-bees-to-load-chunks-for-beehives.patch diff --git a/patches/unapplied/server/Don-t-move-existing-players-to-world-spawn.patch b/patches/server/Don-t-move-existing-players-to-world-spawn.patch similarity index 100% rename from patches/unapplied/server/Don-t-move-existing-players-to-world-spawn.patch rename to patches/server/Don-t-move-existing-players-to-world-spawn.patch diff --git a/patches/unapplied/server/Don-t-tick-dead-players.patch b/patches/server/Don-t-tick-dead-players.patch similarity index 100% rename from patches/unapplied/server/Don-t-tick-dead-players.patch rename to patches/server/Don-t-tick-dead-players.patch diff --git a/patches/server/Further-improve-server-tick-loop.patch b/patches/server/Further-improve-server-tick-loop.patch index 2c94589f19..8e013b114f 100644 --- a/patches/server/Further-improve-server-tick-loop.patch +++ b/patches/server/Further-improve-server-tick-loop.patch @@ -96,11 +96,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 // Spigot start Arrays.fill( recentTps, 20 ); - long curTime, tickSection = Util.getMillis(), tickCount = 1; -+ long start = System.nanoTime(), curTime, tickSection = start; // Paper - Further improve server tick loop -+ lastTick = start - TICK_TIME; // Paper ++ long start = System.nanoTime(), curTime, tickSection = start; // Paper - Further improve server tick loop ++ lastTick = start - TICK_TIME; // Paper while (this.running) { - long i = (curTime = Util.getMillis()) - this.nextTickTime; -+ long i = ((curTime = System.nanoTime()) / (1000L * 1000L)) - this.nextTickTime; // Paper ++ long i = ((curTime = System.nanoTime()) / (1000L * 1000L)) - this.nextTickTime; // Paper if (i > 5000L && this.nextTickTime - this.lastOverloadWarning >= 30000L) { // CraftBukkit long j = i / 50L; @@ -114,22 +114,22 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 ++MinecraftServer.currentTickLong; // Paper - if ( tickCount++ % MinecraftServer.SAMPLE_INTERVAL == 0 ) -+ if ( ++MinecraftServer.currentTick % MinecraftServer.SAMPLE_INTERVAL == 0 ) ++ if ( ++MinecraftServer.currentTick % MinecraftServer.SAMPLE_INTERVAL == 0 ) { - 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[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) -+ final long diff = curTime - tickSection; -+ java.math.BigDecimal currentTps = TPS_BASE.divide(new java.math.BigDecimal(diff), 30, java.math.RoundingMode.HALF_UP); -+ tps1.add(currentTps, diff); -+ tps5.add(currentTps, diff); -+ tps15.add(currentTps, diff); -+ // Backwards compat with bad plugins -+ this.recentTps[0] = tps1.getAverage(); -+ this.recentTps[1] = tps5.getAverage(); -+ this.recentTps[2] = tps15.getAverage(); -+ // Paper end ++ final long diff = curTime - tickSection; ++ java.math.BigDecimal currentTps = TPS_BASE.divide(new java.math.BigDecimal(diff), 30, java.math.RoundingMode.HALF_UP); ++ tps1.add(currentTps, diff); ++ tps5.add(currentTps, diff); ++ tps15.add(currentTps, diff); ++ // Backwards compat with bad plugins ++ this.recentTps[0] = tps1.getAverage(); ++ this.recentTps[1] = tps5.getAverage(); ++ this.recentTps[2] = tps15.getAverage(); ++ // Paper end tickSection = curTime; } // Spigot end @@ -138,8 +138,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } - MinecraftServer.currentTick = (int) (System.currentTimeMillis() / 50); // CraftBukkit -+ //MinecraftServer.currentTick = (int) (System.currentTimeMillis() / 50); // CraftBukkit // Paper - don't overwrite current tick time -+ lastTick = curTime; ++ //MinecraftServer.currentTick = (int) (System.currentTimeMillis() / 50); // CraftBukkit // Paper - don't overwrite current tick time ++ lastTick = curTime; this.nextTickTime += 50L; this.startMetricsRecordingTick(); this.profiler.push("tick"); diff --git a/patches/unapplied/server/Improved-Watchdog-Support.patch b/patches/server/Improved-Watchdog-Support.patch similarity index 94% rename from patches/unapplied/server/Improved-Watchdog-Support.patch rename to patches/server/Improved-Watchdog-Support.patch index 65351e56dd..29f5fecce6 100644 --- a/patches/unapplied/server/Improved-Watchdog-Support.patch +++ b/patches/server/Improved-Watchdog-Support.patch @@ -119,8 +119,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + // Paper end // CraftBukkit end - MinecraftServer.LOGGER.info("Stopping server"); - MinecraftTimings.stopServer(); // Paper + if (this.metricsRecorder.isRecording()) { + this.cancelRecordingMetrics(); @@ -0,0 +0,0 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop 0) { @@ -70,7 +70,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 return 0; + } + -+ net.minecraft.server.level.ServerPlayer entityhuman = world.players().get(random.nextInt(j)); ++ net.minecraft.server.level.ServerPlayer entityhuman = world.players().get(randomsource.nextInt(j)); + if (entityhuman.isSpectator()) { + return 0; + } @@ -80,7 +80,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + --entityhuman.patrolSpawnDelay; + patrolSpawnDelay = entityhuman.patrolSpawnDelay; } else { -- this.nextTick += 12000 + random.nextInt(1200); +- this.nextTick += 12000 + randomsource.nextInt(1200); - long i = world.getDayTime() / 24000L; + this.nextTick--; + patrolSpawnDelay = this.nextTick; @@ -96,15 +96,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + days = world.getDayTime() / 24000L; + } + if (world.paperConfig.patrolPerPlayerDelay) { -+ entityhuman.patrolSpawnDelay += world.paperConfig.patrolDelay + random.nextInt(1200); ++ entityhuman.patrolSpawnDelay += world.paperConfig.patrolDelay + randomsource.nextInt(1200); + } else { -+ this.nextTick += world.paperConfig.patrolDelay + random.nextInt(1200); ++ this.nextTick += world.paperConfig.patrolDelay + randomsource.nextInt(1200); + } - if (i >= 5L && world.isDay()) { -- if (random.nextInt(5) != 0) { +- if (randomsource.nextInt(5) != 0) { + if (days >= world.paperConfig.patrolStartDay && world.isDay()) { -+ if (random.nextDouble() >= world.paperConfig.patrolSpawnChance) { ++ if (randomsource.nextDouble() >= world.paperConfig.patrolSpawnChance) { + // Paper end return 0; } else { @@ -113,7 +113,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 if (j < 1) { return 0; } else { -- Player entityhuman = (Player) world.players().get(random.nextInt(j)); +- Player entityhuman = (Player) world.players().get(randomsource.nextInt(j)); if (entityhuman.isSpectator()) { return 0; diff --git a/patches/unapplied/server/Prevent-Double-PlayerChunkMap-adds-crashing-server.patch b/patches/server/Prevent-Double-PlayerChunkMap-adds-crashing-server.patch similarity index 97% rename from patches/unapplied/server/Prevent-Double-PlayerChunkMap-adds-crashing-server.patch rename to patches/server/Prevent-Double-PlayerChunkMap-adds-crashing-server.patch index f27aa015b4..640d874e37 100644 --- a/patches/unapplied/server/Prevent-Double-PlayerChunkMap-adds-crashing-server.patch +++ b/patches/server/Prevent-Double-PlayerChunkMap-adds-crashing-server.patch @@ -39,8 +39,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 ServerPlayer entityplayer = (ServerPlayer) entity; @@ -0,0 +0,0 @@ public class ServerLevel extends Level implements WorldGenLevel { - } + entity.updateDynamicGameEventListener(DynamicGameEventListener::add); entity.valid = true; // CraftBukkit + ServerLevel.this.getChunkSource().addEntity(entity); // Paper start - Set origin location when the entity is being added to the world diff --git a/patches/unapplied/server/Reduce-Either-Optional-allocation.patch b/patches/server/Reduce-Either-Optional-allocation.patch similarity index 100% rename from patches/unapplied/server/Reduce-Either-Optional-allocation.patch rename to patches/server/Reduce-Either-Optional-allocation.patch diff --git a/patches/unapplied/server/Remote-Connections-shouldn-t-hold-up-shutdown.patch b/patches/server/Remote-Connections-shouldn-t-hold-up-shutdown.patch similarity index 100% rename from patches/unapplied/server/Remote-Connections-shouldn-t-hold-up-shutdown.patch rename to patches/server/Remote-Connections-shouldn-t-hold-up-shutdown.patch