Skip to content

Commit

Permalink
Spinning tick await
Browse files Browse the repository at this point in the history
  • Loading branch information
cakoyo committed May 14, 2019
1 parent 99be334 commit 6e5df77
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -219,4 +219,9 @@ private static void improvedMobSpawnMechanics() {
private static void enableModernUserCaches() {
userCacheExpireDays = getSeconds(getString("core.user-cache-expire-time", "30d"));
}

public static boolean spinningAwaitTicking = true;
private static void spinningAwaitTicking() {
spinningAwaitTicking = getBoolean("core.spinning-tick-await", spinningAwaitTicking);
}
}
1 change: 1 addition & 0 deletions src/main/java/net/minecraft/server/Entity.java
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,7 @@ private boolean b(AxisAlignedBB axisalignedbb) {
}

public void move(EnumMoveType enummovetype, double d0, double d1, double d2) {
System.out.print("move");
if (this.noclip) {
this.a(this.getBoundingBox().d(d0, d1, d2));
this.recalcPosition();
Expand Down
10 changes: 9 additions & 1 deletion src/main/java/net/minecraft/server/MinecraftServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService;
import com.mojang.datafixers.DataFixer;

import io.akarin.server.core.AkarinGlobalConfig;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufOutputStream;
import io.netty.buffer.Unpooled;
Expand Down Expand Up @@ -816,7 +817,14 @@ public void run() {
}
}
if (wait > 0) {
Thread.sleep(wait / 1000000);
// Akarin start
if (AkarinGlobalConfig.spinningAwaitTicking) {
long park = System.nanoTime();
while ((System.nanoTime() - park) < wait);
} else {
Thread.sleep(wait / 1000000);
}
// Akarin end
curTime = System.nanoTime();
wait = TICK_TIME - (curTime - lastTick);
}
Expand Down

0 comments on commit 6e5df77

Please sign in to comment.