Fast exit if the player didn't move

This commit is contained in:
TheMode 2021-08-22 08:13:28 +02:00
parent 18b0e21f21
commit 898252dad0
2 changed files with 3 additions and 1 deletions

View File

@ -465,6 +465,8 @@ public class Entity implements Viewable, Tickable, TagHandler, PermissionHandler
private void velocityTick() {
final boolean isSocketClient = PlayerUtils.isSocketClient(this);
if (isSocketClient) {
if (position.samePoint(previousPosition))
return; // Didn't move since last tick
// Calculate velocity from client
velocity = position.sub(previousPosition).asVec().mul(MinecraftServer.TICK_PER_SECOND);
previousPosition = position;

View File

@ -4,7 +4,7 @@ import net.minestom.server.MinecraftServer;
import net.minestom.server.event.trait.CancellableEvent;
import org.jetbrains.annotations.NotNull;
public class EventDispatcher {
public final class EventDispatcher {
public static void call(@NotNull Event event) {
MinecraftServer.getGlobalEventHandler().call(event);