2020-05-06 11:48:49 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2019-03-28 03:49:29 +01:00
|
|
|
From: Aikar <aikar@aikar.co>
|
|
|
|
Date: Wed, 27 Mar 2019 22:48:45 -0400
|
|
|
|
Subject: [PATCH] Server Tick Events
|
|
|
|
|
|
|
|
Fires event at start and end of a server tick
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
2021-05-11 05:47:51 +02:00
|
|
|
index 4d44604da7c65df6d8e87b6c6c56371ca307c11f..7ef01f2f80eea31fa76d22c3a0d5036883dee516 100644
|
2019-03-28 03:49:29 +01:00
|
|
|
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
2021-05-11 05:47:51 +02:00
|
|
|
@@ -1239,6 +1239,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
|
2020-04-16 03:48:07 +02:00
|
|
|
});
|
Improve mid tick chunk loading, Fix Oversleep, other improvements
Process loads outside of any canSleep check. Original intent was to
only apply those restrictions to generations but realized I had some
checks higher up the call chain.
Reworked the back off strategy to just run every 1 millisecond per world,
and to apply the per tick limit to generations only.
This guarantees that your chunk will load with at most around 1ms delay.
Additionally, fire midTick processing in a few more places, notably the
oversleep section so we can keep processing loads here too which has
a large up to 50ms window...
Speaking of oversleep, we had a bug in our implementation changes for
Timings that caused oversleep to not sleep the correct amount.
Because we now moved it into the NEXT tick instead of THIS tick, the
value of nextTick had already been increased to +50ms, resulting in
the risk of sleeping more than it should, but, more importantly, this
caused every task that was trying to NOT run during oversleep to actually
run during oversleep.
This is now fixed.
Another small tweak is to the /tps command, to no longer show the star when
TPS is right at 20.
Due to ineffeciencies in the sleep precision, TPS is commonly 20.02.
This causes the star to show up almost constantly, so now only show it if
we actually hit a real "catchup".
This commit also improves the changes to the CallbackExecutor, in that
it now is also recursion safe.
It was possible that the executor could run tasks out of desired order
if the executor task scheduled more executor tasks.
We solve this by ensuring new additions do not enter the currently iterated queue.
Each depth level will have its own queue.
Fixes #3220
2020-04-26 05:47:29 +02:00
|
|
|
isOversleep = false;MinecraftTimings.serverOversleep.stopTiming();
|
2019-09-29 22:49:38 +02:00
|
|
|
// Paper end
|
2019-03-28 03:49:29 +01:00
|
|
|
+ new com.destroystokyo.paper.event.server.ServerTickStartEvent(this.ticks+1).callEvent(); // Paper
|
|
|
|
|
|
|
|
++this.ticks;
|
2019-05-05 19:19:34 +02:00
|
|
|
this.b(booleansupplier);
|
2021-05-11 05:47:51 +02:00
|
|
|
@@ -1282,6 +1283,12 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
|
2019-07-24 05:20:14 +02:00
|
|
|
}
|
|
|
|
// Paper end
|
2020-04-16 03:48:07 +02:00
|
|
|
|
2019-03-28 03:49:29 +01:00
|
|
|
+ // Paper start
|
|
|
|
+ long endTime = System.nanoTime();
|
|
|
|
+ long remaining = (TICK_TIME - (endTime - lastTick)) - catchupTime;
|
2019-03-28 06:27:39 +01:00
|
|
|
+ new com.destroystokyo.paper.event.server.ServerTickEndEvent(this.ticks, ((double)(endTime - lastTick) / 1000000D), remaining).callEvent();
|
2019-03-28 03:49:29 +01:00
|
|
|
+ // Paper end
|
2020-04-16 03:48:07 +02:00
|
|
|
+
|
|
|
|
this.methodProfiler.enter("tallying");
|
2020-06-25 16:09:55 +02:00
|
|
|
long l = this.h[this.ticks % 100] = SystemUtils.getMonotonicNanos() - i;
|
2019-03-28 03:49:29 +01:00
|
|
|
|