mirror of
https://github.com/PaperMC/Paper.git
synced 2025-03-02 11:22:01 +01:00
Fix tick loop bug - Fixes #624
We were not calculating time after the sleep ,resulting in wrong calculations. This caused us to go 100ms, 0ms, 100ms, 0 ms repeatedly.
This commit is contained in:
parent
b7442eaf52
commit
0c8c9b087a
@ -12,7 +12,7 @@ Previous implementation did not calculate TPS correctly.
|
|||||||
Switch to a realistic rolling average and factor in std deviation as an extra reporting variable
|
Switch to a realistic rolling average and factor in std deviation as an extra reporting variable
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||||
index 7539bb215..91fb12128 100644
|
index 7539bb215..4476799d8 100644
|
||||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||||
@@ -0,0 +0,0 @@ public abstract class MinecraftServer implements Runnable, ICommandListener, IAs
|
@@ -0,0 +0,0 @@ public abstract class MinecraftServer implements Runnable, ICommandListener, IAs
|
||||||
@ -107,13 +107,12 @@ index 7539bb215..91fb12128 100644
|
|||||||
+ if (wait > 0) {
|
+ if (wait > 0) {
|
||||||
+ if (catchupTime < 2E6) {
|
+ if (catchupTime < 2E6) {
|
||||||
+ wait += Math.abs(catchupTime);
|
+ wait += Math.abs(catchupTime);
|
||||||
+ }
|
+ } else if (wait < catchupTime) {
|
||||||
+ if (wait < catchupTime) {
|
|
||||||
+ catchupTime -= wait;
|
+ catchupTime -= wait;
|
||||||
+ wait = 0;
|
+ wait = 0;
|
||||||
+ } else if (catchupTime > 2E6) {
|
+ } else {
|
||||||
+ wait -= catchupTime;
|
+ wait -= catchupTime;
|
||||||
+ catchupTime -= catchupTime;
|
+ catchupTime = 0;
|
||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
if (wait > 0) {
|
if (wait > 0) {
|
||||||
@ -122,6 +121,7 @@ index 7539bb215..91fb12128 100644
|
|||||||
- continue;
|
- continue;
|
||||||
- } else {
|
- } else {
|
||||||
- catchupTime = Math.min(1000000000, Math.abs(wait));
|
- catchupTime = Math.min(1000000000, Math.abs(wait));
|
||||||
|
+ curTime = System.nanoTime();
|
||||||
+ wait = TICK_TIME - (curTime - lastTick);
|
+ wait = TICK_TIME - (curTime - lastTick);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user