this.t() -> this.u() - make the server actually tick!

This commit is contained in:
md_5 2014-03-23 11:34:50 +11:00
parent c9605032d0
commit 09d6e4d9e1

View File

@ -1,11 +1,11 @@
From fe0feeb70937b2f8d2cf5c34da2de99c9e99ec02 Mon Sep 17 00:00:00 2001
From 3cf7361b54a335fa6e80a35f433df2fae4308793 Mon Sep 17 00:00:00 2001
From: md_5 <git@md-5.net>
Date: Sat, 25 Jan 2014 14:08:35 +1100
Subject: [PATCH] Highly Optimized Tick Loop
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 1b7f65e..6d7d52f 100644
index 1b7f65e..8ce9dd7 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -102,6 +102,12 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
@ -35,7 +35,7 @@ index 1b7f65e..6d7d52f 100644
public void run() {
try {
if (this.init()) {
@@ -432,38 +445,35 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
@@ -432,38 +445,34 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
this.p.setServerInfo(new ServerPingServerData("1.7.5", 4));
this.a(this.p);
@ -50,7 +50,12 @@ index 1b7f65e..6d7d52f 100644
- if (this.server.getWarnOnOverload()) // CraftBukkit - Added option to suppress warning messages
- h.warn("Can\'t keep up! Did the system time change, or is the server overloaded? Running {}ms behind, skipping {} tick(s)", new Object[] { Long.valueOf(l), Long.valueOf(l / 50L)});
- l = 2000L;
this.O = i;
- this.O = i;
- }
-
- if (l < 0L) {
- h.warn("Time ran backwards! Did the system time change?");
- l = 0L;
+ curTime = System.nanoTime();
+ wait = TICK_TIME - (curTime - lastTick) - catchupTime;
+ if (wait > 0) {
@ -61,11 +66,6 @@ index 1b7f65e..6d7d52f 100644
+ catchupTime = Math.min(1000000000, Math.abs(wait));
}
- if (l < 0L) {
- h.warn("Time ran backwards! Did the system time change?");
- l = 0L;
- }
-
- j += l;
- i = k;
- if (this.worlds.get(0).everyoneDeeplySleeping()) { // CraftBukkit
@ -88,7 +88,7 @@ index 1b7f65e..6d7d52f 100644
+ lastTick = curTime;
- Thread.sleep(Math.max(1L, 50L - j));
+ this.t();
+ this.u();
this.N = true;
}
+ // Spigot end
@ -161,5 +161,5 @@ index 0000000..2b8343d
+ }
+}
--
1.8.5.2.msysgit.0
1.8.3.2