2020-05-06 09:48:49 +00:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2019-03-28 02:49:29 +00: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-03-16 07:19:45 +00:00
|
|
|
index 3ce1204184656d7500509f8600cec0a4b6089a3f..c864749646d26199e4c938f1fa6bbee4a3b942dd 100644
|
2019-03-28 02:49:29 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
2021-03-16 07:19:45 +00:00
|
|
|
@@ -1227,6 +1227,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
|
2020-04-16 01:48:07 +00: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 03:47:29 +00:00
|
|
|
isOversleep = false;MinecraftTimings.serverOversleep.stopTiming();
|
2019-09-29 20:49:38 +00:00
|
|
|
// Paper end
|
2019-03-28 02:49:29 +00:00
|
|
|
+ new com.destroystokyo.paper.event.server.ServerTickStartEvent(this.ticks+1).callEvent(); // Paper
|
|
|
|
|
|
|
|
++this.ticks;
|
2019-05-05 17:19:34 +00:00
|
|
|
this.b(booleansupplier);
|
2021-03-16 07:19:45 +00:00
|
|
|
@@ -1270,6 +1271,12 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
|
2019-07-24 03:20:14 +00:00
|
|
|
}
|
|
|
|
// Paper end
|
2020-04-16 01:48:07 +00:00
|
|
|
|
2019-03-28 02:49:29 +00:00
|
|
|
+ // Paper start
|
|
|
|
+ long endTime = System.nanoTime();
|
|
|
|
+ long remaining = (TICK_TIME - (endTime - lastTick)) - catchupTime;
|
2019-03-28 05:27:39 +00:00
|
|
|
+ new com.destroystokyo.paper.event.server.ServerTickEndEvent(this.ticks, ((double)(endTime - lastTick) / 1000000D), remaining).callEvent();
|
2019-03-28 02:49:29 +00:00
|
|
|
+ // Paper end
|
2020-04-16 01:48:07 +00:00
|
|
|
+
|
|
|
|
this.methodProfiler.enter("tallying");
|
2020-06-25 14:09:55 +00:00
|
|
|
long l = this.h[this.ticks % 100] = SystemUtils.getMonotonicNanos() - i;
|
2019-03-28 02:49:29 +00:00
|
|
|
|