moar patches

This commit is contained in:
Jake Potrebic
2022-06-07 21:22:42 -07:00
parent ac0e1997ee
commit 194d219e0a
14 changed files with 53 additions and 53 deletions

View File

@@ -43,10 +43,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
this.updateStatusIcon(this.status); this.updateStatusIcon(this.status);
// Spigot start // Spigot start
+ org.spigotmc.WatchdogThread.hasStarted = true; // Paper + org.spigotmc.WatchdogThread.hasStarted = true; // Paper
Arrays.fill( recentTps, 20 ); Arrays.fill( recentTps, 20 );
long start = System.nanoTime(), curTime, tickSection = start; // Paper - Further improve server tick loop long start = System.nanoTime(), curTime, tickSection = start; // Paper - Further improve server tick loop
lastTick = start - TICK_TIME; // Paper 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 diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java

View File

@@ -96,11 +96,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
// Spigot start // Spigot start
Arrays.fill( recentTps, 20 ); Arrays.fill( recentTps, 20 );
- long curTime, tickSection = Util.getMillis(), tickCount = 1; - long curTime, tickSection = Util.getMillis(), tickCount = 1;
+ long start = System.nanoTime(), curTime, tickSection = start; // Paper - Further improve server tick loop + long start = System.nanoTime(), curTime, tickSection = start; // Paper - Further improve server tick loop
+ lastTick = start - TICK_TIME; // Paper + lastTick = start - TICK_TIME; // Paper
while (this.running) { while (this.running) {
- long i = (curTime = Util.getMillis()) - this.nextTickTime; - 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 if (i > 5000L && this.nextTickTime - this.lastOverloadWarning >= 30000L) { // CraftBukkit
long j = i / 50L; long j = i / 50L;
@@ -114,22 +114,22 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
++MinecraftServer.currentTickLong; // Paper ++MinecraftServer.currentTickLong; // Paper
- if ( tickCount++ % MinecraftServer.SAMPLE_INTERVAL == 0 ) - 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; - 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)
+ final long diff = curTime - tickSection; + final long diff = curTime - tickSection;
+ java.math.BigDecimal currentTps = TPS_BASE.divide(new java.math.BigDecimal(diff), 30, java.math.RoundingMode.HALF_UP); + 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 + // Paper end
tickSection = curTime; tickSection = curTime;
} }
// Spigot end // Spigot end
@@ -138,8 +138,8 @@ 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 = curTime;
this.nextTickTime += 50L; this.nextTickTime += 50L;
this.startMetricsRecordingTick(); this.startMetricsRecordingTick();
this.profiler.push("tick"); this.profiler.push("tick");

View File

@@ -119,8 +119,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ // Paper end + // Paper end
// CraftBukkit end // CraftBukkit end
MinecraftServer.LOGGER.info("Stopping server"); if (this.metricsRecorder.isRecording()) {
MinecraftTimings.stopServer(); // Paper this.cancelRecordingMetrics();
@@ -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(false); // Paper this.getProfileCache().save(false); // Paper
} }
@@ -145,30 +145,30 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
protected void runServer() { protected void runServer() {
try { try {
+ long serverStartTime = Util.getNanos(); // Paper + long serverStartTime = Util.getNanos(); // Paper
if (this.initServer()) { if (!this.initServer()) {
this.nextTickTime = Util.getMillis(); throw new IllegalStateException("Failed to initialize server");
this.status.setDescription(new TextComponent(this.motd)); }
@@ -0,0 +0,0 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa @@ -0,0 +0,0 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
this.updateStatusIcon(this.status); this.updateStatusIcon(this.status);
// Spigot start // Spigot start
+ // Paper start - move done tracking + // Paper start - move done tracking
+ LOGGER.info("Running delayed init tasks"); + LOGGER.info("Running delayed init tasks");
+ this.server.getScheduler().mainThreadHeartbeat(this.tickCount); // run all 1 tick delay tasks during init, + this.server.getScheduler().mainThreadHeartbeat(this.tickCount); // run all 1 tick delay tasks during init,
+ // this is going to be the first thing the tick process does anyways, so move done and run it after + // this is going to be the first thing the tick process does anyways, so move done and run it after
+ // everything is init before watchdog tick. + // everything is init before watchdog tick.
+ // anything at 3+ won't be caught here but also will trip watchdog.... + // anything at 3+ won't be caught here but also will trip watchdog....
+ // tasks are default scheduled at -1 + delay, and first tick will tick at 1 + // tasks are default scheduled at -1 + delay, and first tick will tick at 1
+ String doneTime = String.format(java.util.Locale.ROOT, "%.3fs", (double) (Util.getNanos() - serverStartTime) / 1.0E9D); + String doneTime = String.format(java.util.Locale.ROOT, "%.3fs", (double) (Util.getNanos() - serverStartTime) / 1.0E9D);
+ LOGGER.info("Done ({})! For help, type \"help\"", doneTime); + LOGGER.info("Done ({})! For help, type \"help\"", doneTime);
+ // Paper end + // Paper end
+ +
+ org.spigotmc.WatchdogThread.tick(); // Paper + org.spigotmc.WatchdogThread.tick(); // Paper
org.spigotmc.WatchdogThread.hasStarted = true; // Paper org.spigotmc.WatchdogThread.hasStarted = true; // Paper
Arrays.fill( recentTps, 20 ); Arrays.fill( recentTps, 20 );
long start = System.nanoTime(), curTime, tickSection = start; // Paper - Further improve server tick loop long start = System.nanoTime(), curTime, tickSection = start; // Paper - 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
this.onServerCrash((CrashReport) null); JvmProfiler.INSTANCE.onServerTick(this.averageTickTime);
} }
} catch (Throwable throwable) { } catch (Throwable throwable) {
+ // Paper start + // Paper start
@@ -181,7 +181,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
// Spigot Start // Spigot Start
if ( throwable.getCause() != null ) if ( throwable.getCause() != null )
@@ -0,0 +0,0 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa @@ -0,0 +0,0 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
this.profileCache.clearExecutor(); this.services.profileCache().clearExecutor();
} }
- org.spigotmc.WatchdogThread.doStop(); // Spigot - org.spigotmc.WatchdogThread.doStop(); // Spigot
@@ -228,7 +228,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ //this.getPlayerList().saveAll(); // Paper - we don't need to do this + //this.getPlayerList().saveAll(); // Paper - we don't need to do this
this.getPlayerList().reloadResources(); this.getPlayerList().reloadResources();
this.functionManager.replaceLibrary(this.resources.managers.getFunctionLibrary()); this.functionManager.replaceLibrary(this.resources.managers.getFunctionLibrary());
this.structureManager.onResourceManagerReload(this.resources.resourceManager); this.structureTemplateManager.onResourceManagerReload(this.resources.resourceManager);
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

@@ -30,7 +30,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/net/minecraft/world/entity/Entity.java --- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { @@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
// Paper end public org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason; // Paper
public com.destroystokyo.paper.loottable.PaperLootableInventoryData lootableData; // Paper public com.destroystokyo.paper.loottable.PaperLootableInventoryData lootableData; // Paper
+ public boolean collisionLoadChunks = false; // Paper + public boolean collisionLoadChunks = false; // Paper

View File

@@ -59,7 +59,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
} else if (!world.getGameRules().getBoolean(GameRules.RULE_DO_PATROL_SPAWNING)) { } else if (!world.getGameRules().getBoolean(GameRules.RULE_DO_PATROL_SPAWNING)) {
@@ -0,0 +0,0 @@ public class PatrolSpawner implements CustomSpawner { @@ -0,0 +0,0 @@ public class PatrolSpawner implements CustomSpawner {
} else { } else {
Random random = world.random; RandomSource randomsource = world.random;
- --this.nextTick; - --this.nextTick;
- if (this.nextTick > 0) { - if (this.nextTick > 0) {
@@ -70,7 +70,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
return 0; 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()) { + if (entityhuman.isSpectator()) {
+ return 0; + return 0;
+ } + }
@@ -80,7 +80,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ --entityhuman.patrolSpawnDelay; + --entityhuman.patrolSpawnDelay;
+ patrolSpawnDelay = entityhuman.patrolSpawnDelay; + patrolSpawnDelay = entityhuman.patrolSpawnDelay;
} else { } else {
- this.nextTick += 12000 + random.nextInt(1200); - this.nextTick += 12000 + randomsource.nextInt(1200);
- long i = world.getDayTime() / 24000L; - long i = world.getDayTime() / 24000L;
+ this.nextTick--; + this.nextTick--;
+ patrolSpawnDelay = this.nextTick; + patrolSpawnDelay = this.nextTick;
@@ -96,15 +96,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ days = world.getDayTime() / 24000L; + days = world.getDayTime() / 24000L;
+ } + }
+ if (world.paperConfig.patrolPerPlayerDelay) { + if (world.paperConfig.patrolPerPlayerDelay) {
+ entityhuman.patrolSpawnDelay += world.paperConfig.patrolDelay + random.nextInt(1200); + entityhuman.patrolSpawnDelay += world.paperConfig.patrolDelay + randomsource.nextInt(1200);
+ } else { + } else {
+ this.nextTick += world.paperConfig.patrolDelay + random.nextInt(1200); + this.nextTick += world.paperConfig.patrolDelay + randomsource.nextInt(1200);
+ } + }
- if (i >= 5L && world.isDay()) { - if (i >= 5L && world.isDay()) {
- if (random.nextInt(5) != 0) { - if (randomsource.nextInt(5) != 0) {
+ if (days >= world.paperConfig.patrolStartDay && world.isDay()) { + if (days >= world.paperConfig.patrolStartDay && world.isDay()) {
+ if (random.nextDouble() >= world.paperConfig.patrolSpawnChance) { + if (randomsource.nextDouble() >= world.paperConfig.patrolSpawnChance) {
+ // Paper end + // Paper end
return 0; return 0;
} else { } else {
@@ -113,7 +113,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
if (j < 1) { if (j < 1) {
return 0; return 0;
} else { } else {
- Player entityhuman = (Player) world.players().get(random.nextInt(j)); - Player entityhuman = (Player) world.players().get(randomsource.nextInt(j));
if (entityhuman.isSpectator()) { if (entityhuman.isSpectator()) {
return 0; return 0;

View File

@@ -39,8 +39,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
ServerPlayer entityplayer = (ServerPlayer) entity; ServerPlayer entityplayer = (ServerPlayer) entity;
@@ -0,0 +0,0 @@ public class ServerLevel extends Level implements WorldGenLevel { @@ -0,0 +0,0 @@ public class ServerLevel extends Level implements WorldGenLevel {
}
entity.updateDynamicGameEventListener(DynamicGameEventListener::add);
entity.valid = true; // CraftBukkit entity.valid = true; // CraftBukkit
+ ServerLevel.this.getChunkSource().addEntity(entity); + ServerLevel.this.getChunkSource().addEntity(entity);
// Paper start - Set origin location when the entity is being added to the world // Paper start - Set origin location when the entity is being added to the world