mirror of
https://github.com/Minestom/Minestom.git
synced 2024-12-25 18:47:40 +01:00
Extract constant tick time
This commit is contained in:
parent
284bf24308
commit
8778e32700
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user