From 8778e3270096493e0f86de144094a39763973ca1 Mon Sep 17 00:00:00 2001 From: themode Date: Fri, 21 Jan 2022 10:10:24 +0100 Subject: [PATCH] Extract constant tick time --- .../java/net/minestom/server/thread/TickSchedulerThread.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/minestom/server/thread/TickSchedulerThread.java b/src/main/java/net/minestom/server/thread/TickSchedulerThread.java index 2fe2c8f08..6f28f56a5 100644 --- a/src/main/java/net/minestom/server/thread/TickSchedulerThread.java +++ b/src/main/java/net/minestom/server/thread/TickSchedulerThread.java @@ -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); } } }