From 3abef8c9a72b10d127d7d9598c3dfdadfd7b64d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=A9meth=20Noel?= Date: Sat, 1 May 2021 04:27:21 +0200 Subject: [PATCH] Fix position update --- src/main/java/net/minestom/server/entity/Entity.java | 7 ++----- .../minestom/server/listener/PlayerPositionListener.java | 1 + 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/main/java/net/minestom/server/entity/Entity.java b/src/main/java/net/minestom/server/entity/Entity.java index 421dd4b26..f822063c6 100644 --- a/src/main/java/net/minestom/server/entity/Entity.java +++ b/src/main/java/net/minestom/server/entity/Entity.java @@ -693,7 +693,8 @@ public class Entity implements Viewable, Tickable, EventHandler, DataContainer, * * @param notFromListener {@code true} if the client triggered this action */ - protected void sendPositionUpdate(final boolean notFromListener) { + @ApiStatus.Internal + public void sendPositionUpdate(final boolean notFromListener) { final boolean viewChange = !position.hasSimilarView(lastSyncedPosition); final double distanceX = Math.abs(position.getX()-lastSyncedPosition.getX()); final double distanceY = Math.abs(position.getY()-lastSyncedPosition.getY()); @@ -1357,8 +1358,6 @@ public class Entity implements Viewable, Tickable, EventHandler, DataContainer, position.setY(y); position.setZ(z); - sendPositionUpdate(false); - if (hasPassenger()) { for (Entity passenger : getPassengers()) { passenger.refreshPosition(x, y, z); @@ -1416,8 +1415,6 @@ public class Entity implements Viewable, Tickable, EventHandler, DataContainer, this.lastPosition.setPitch(position.getPitch()); position.setYaw(yaw); position.setPitch(pitch); - - sendPositionUpdate(false); } /** diff --git a/src/main/java/net/minestom/server/listener/PlayerPositionListener.java b/src/main/java/net/minestom/server/listener/PlayerPositionListener.java index f1c835604..7c4ba8e41 100644 --- a/src/main/java/net/minestom/server/listener/PlayerPositionListener.java +++ b/src/main/java/net/minestom/server/listener/PlayerPositionListener.java @@ -90,6 +90,7 @@ public class PlayerPositionListener { player.refreshPosition(newPosition.getX(), newPosition.getY(), newPosition.getZ()); player.refreshView(newPosition.getYaw(), newPosition.getPitch()); player.refreshOnGround(onGround); + player.sendPositionUpdate(false); } else { player.teleport(player.getPosition()); }