Extract constant tick time

This commit is contained in:
themode 2022-01-21 10:10:24 +01:00
parent 284bf24308
commit 8778e32700

View File

@ -17,6 +17,7 @@ public final class TickSchedulerThread extends MinestomThread {
@Override
public void run() {
final long tickNs = (long) (MinecraftServer.TICK_MS * 1e6);
while (serverProcess.isAlive()) {
final long tickStart = System.nanoTime();
try {
@ -25,7 +26,7 @@ public final class TickSchedulerThread extends MinestomThread {
serverProcess.exception().handleException(e);
}
final long tickTime = System.nanoTime() - tickStart;
LockSupport.parkNanos((long) ((MinecraftServer.TICK_MS * 1e6) - tickTime));
LockSupport.parkNanos(tickNs - tickTime);
}
}
}