From 4f6c5eac795981ee44ad2dcaccff8e1db0cd954f Mon Sep 17 00:00:00 2001 From: PetteriM1 <26197131+PetteriM1@users.noreply.github.com> Date: Tue, 24 Oct 2023 22:25:22 +0300 Subject: [PATCH] Fix entity movement on snow layers (#2149) --- src/main/java/cn/nukkit/Player.java | 3 +-- src/main/java/cn/nukkit/block/BlockSnowLayer.java | 5 +++++ src/main/java/cn/nukkit/level/Level.java | 12 ++++++------ 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/main/java/cn/nukkit/Player.java b/src/main/java/cn/nukkit/Player.java index 661cbdbbd4a..7492893aa5b 100644 --- a/src/main/java/cn/nukkit/Player.java +++ b/src/main/java/cn/nukkit/Player.java @@ -2576,8 +2576,7 @@ public void onCompletion(Server server) { } } - Vector3 clientPosition = authPacket.getPosition().asVector3() - .subtract(0, this.getEyeHeight(), 0); + Vector3 clientPosition = authPacket.getPosition().subtract(0, this.getEyeHeight(), 0).asVector3(); double distSqrt = clientPosition.distanceSquared(this); if (distSqrt == 0.0 && authPacket.getYaw() % 360 == this.yaw && authPacket.getPitch() % 360 == this.pitch) { diff --git a/src/main/java/cn/nukkit/block/BlockSnowLayer.java b/src/main/java/cn/nukkit/block/BlockSnowLayer.java index 60e9feec58a..6c9b959a492 100644 --- a/src/main/java/cn/nukkit/block/BlockSnowLayer.java +++ b/src/main/java/cn/nukkit/block/BlockSnowLayer.java @@ -186,4 +186,9 @@ public boolean onActivate(Item item, Player player) { } return false; } + + @Override + public boolean canPassThrough() { + return (this.getDamage() & 0x7) < 3; + } } diff --git a/src/main/java/cn/nukkit/level/Level.java b/src/main/java/cn/nukkit/level/Level.java index 4a3852c7409..aca3e1e94de 100644 --- a/src/main/java/cn/nukkit/level/Level.java +++ b/src/main/java/cn/nukkit/level/Level.java @@ -3275,12 +3275,12 @@ public void addPlayerMovement(Entity entity, double x, double y, double z, doubl public void addEntityMovement(Entity entity, double x, double y, double z, double yaw, double pitch, double headYaw) { MoveEntityAbsolutePacket pk = new MoveEntityAbsolutePacket(); pk.eid = entity.getId(); - pk.x = (float) x; - pk.y = (float) y; - pk.z = (float) z; - pk.yaw = (float) yaw; - pk.headYaw = (float) headYaw; - pk.pitch = (float) pitch; + pk.x = x; + pk.y = y; + pk.z = z; + pk.yaw = yaw; + pk.headYaw = headYaw; + pk.pitch = pitch; pk.onGround = entity.onGround; Server.broadcastPacket(entity.getViewers().values(), pk);