diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java index ce5df4146b..2acd3f93ce 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -55,6 +55,7 @@ public class MinecraftServer implements Runnable, ICommandListener { public OptionSet options; public ColouredConsoleSender console; public ConsoleReader reader; + public static int currentTick; // Craftbukkit end public MinecraftServer(OptionSet options) { // CraftBukkit - adds argument OptionSet @@ -281,6 +282,7 @@ public class MinecraftServer implements Runnable, ICommandListener { j = 0L; } else { while (j > 50L) { + MinecraftServer.currentTick = (int) (System.currentTimeMillis() / 50); // CraftBukkit j -= 50L; this.h(); } diff --git a/src/main/java/net/minecraft/server/NetServerHandler.java b/src/main/java/net/minecraft/server/NetServerHandler.java index d314c7c085..84a04d0939 100644 --- a/src/main/java/net/minecraft/server/NetServerHandler.java +++ b/src/main/java/net/minecraft/server/NetServerHandler.java @@ -38,6 +38,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener { private double z; private boolean m = true; private Map n = new HashMap(); + private int lastTick = MinecraftServer.currentTick; // CraftBukkit public NetServerHandler(MinecraftServer minecraftserver, NetworkManager networkmanager, EntityPlayer entityplayer) { this.minecraftServer = minecraftserver; @@ -277,11 +278,15 @@ public class NetServerHandler extends NetHandler implements ICommandListener { double d7 = d3 - this.player.locZ; double d8 = d4 * d4 + d6 * d6 + d7 * d7; - if (d8 > 100.0D) { - a.warning(this.player.name + " moved too quickly!"); + // CraftBukkit start - make the movement speed check behave properly under tick degradation. + int elapsedTicks = MinecraftServer.currentTick - this.lastTick; + if (d8 > 100.0D * (elapsedTicks == 0 ? 1 : elapsedTicks)) { + a.warning(this.player.name + " moved too quickly! Elapsed ticks: " + (elapsedTicks == 0 ? 1 : elapsedTicks) + ", Distance change: " + d8); this.disconnect("You moved too quickly :( (Hacking?)"); return; } + this.lastTick = MinecraftServer.currentTick; + // CraftBukkit end float f4 = 0.0625F; // CraftBukkit