Skip to content

Commit

Permalink
Fix entity movement on snow layers (#2149)
Browse files Browse the repository at this point in the history
  • Loading branch information
PetteriM1 committed Oct 24, 2023
1 parent 8c86550 commit 4f6c5ea
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
3 changes: 1 addition & 2 deletions src/main/java/cn/nukkit/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/cn/nukkit/block/BlockSnowLayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -186,4 +186,9 @@ public boolean onActivate(Item item, Player player) {
}
return false;
}

@Override
public boolean canPassThrough() {
return (this.getDamage() & 0x7) < 3;
}
}
12 changes: 6 additions & 6 deletions src/main/java/cn/nukkit/level/Level.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 4f6c5ea

Please sign in to comment.