Flush packets before computing mspt

Signed-off-by: TheMode <themode@outlook.fr>
This commit is contained in:
TheMode 2021-10-11 03:33:16 +02:00
parent b94d196021
commit eca9b5e32d

View File

@ -182,6 +182,11 @@ public final class UpdateManager {
// Server tick (chunks/entities) // Server tick (chunks/entities)
serverTick(tickStart); serverTick(tickStart);
// Flush all waiting packets
PacketUtils.flush();
connectionManager.getOnlinePlayers().parallelStream().forEach(player ->
player.getPlayerConnection().flush());
// the time that the tick took in nanoseconds // the time that the tick took in nanoseconds
final long tickTime = System.nanoTime() - currentTime; final long tickTime = System.nanoTime() - currentTime;
@ -199,11 +204,6 @@ public final class UpdateManager {
Acquirable.resetAcquiringTime(); Acquirable.resetAcquiringTime();
} }
// Flush all waiting packets
PacketUtils.flush();
connectionManager.getOnlinePlayers().parallelStream().forEach(player ->
player.getPlayerConnection().flush());
// Disable thread until next tick // Disable thread until next tick
LockSupport.parkNanos((long) ((MinecraftServer.TICK_MS * 1e6) - tickTime)); LockSupport.parkNanos((long) ((MinecraftServer.TICK_MS * 1e6) - tickTime));
} catch (Exception e) { } catch (Exception e) {