From 87320f0a78ec6c70b498fe899b87143f218c44d7 Mon Sep 17 00:00:00 2001 From: davchoo Date: Fri, 27 May 2022 19:03:12 -0400 Subject: [PATCH] Fix player head yaw for moveAbsolute teleport Fixes SkullPlayerEntity rotation Remove redundant? overrides --- .../entity/type/player/PlayerEntity.java | 52 +++---------------- 1 file changed, 7 insertions(+), 45 deletions(-) diff --git a/core/src/main/java/org/geysermc/geyser/entity/type/player/PlayerEntity.java b/core/src/main/java/org/geysermc/geyser/entity/type/player/PlayerEntity.java index 8bb47db81..6f2958ffd 100644 --- a/core/src/main/java/org/geysermc/geyser/entity/type/player/PlayerEntity.java +++ b/core/src/main/java/org/geysermc/geyser/entity/type/player/PlayerEntity.java @@ -168,6 +168,12 @@ public class PlayerEntity extends LivingEntity { } session.sendUpstreamPacket(movePlayerPacket); + + if (teleported) { + // As of 1.19.0, head yaw seems to be ignored during teleports. + updateHeadLookRotation(headYaw); + } + if (leftParrot != null) { leftParrot.moveAbsolute(position, yaw, pitch, headYaw, true, teleported); } @@ -210,52 +216,8 @@ public class PlayerEntity extends LivingEntity { } } - @Override - public void updateHeadLookRotation(float headYaw) { - moveRelative(0, 0, 0, getYaw(), getPitch(), headYaw, isOnGround()); - MovePlayerPacket movePlayerPacket = new MovePlayerPacket(); - movePlayerPacket.setRuntimeEntityId(geyserId); - movePlayerPacket.setPosition(position); - movePlayerPacket.setRotation(getBedrockRotation()); - movePlayerPacket.setMode(MovePlayerPacket.Mode.HEAD_ROTATION); - session.sendUpstreamPacket(movePlayerPacket); - } - - @Override - public void updatePositionAndRotation(double moveX, double moveY, double moveZ, float yaw, float pitch, boolean isOnGround) { - moveRelative(moveX, moveY, moveZ, yaw, pitch, isOnGround); - if (leftParrot != null) { - leftParrot.moveRelative(moveX, moveY, moveZ, yaw, pitch, isOnGround); - } - if (rightParrot != null) { - rightParrot.moveRelative(moveX, moveY, moveZ, yaw, pitch, isOnGround); - } - } - public void updateRotation(float yaw, float pitch, float headYaw, boolean isOnGround) { - // the method below is called by super.updateRotation(yaw, pitch, isOnGround). - // but we have to be able to set the headYaw, so we call the method below directly. - super.moveRelative(0, 0, 0, yaw, pitch, headYaw, isOnGround); - - // Both packets need to be sent or else player head rotation isn't correctly updated - MovePlayerPacket movePlayerPacket = new MovePlayerPacket(); - movePlayerPacket.setRuntimeEntityId(geyserId); - movePlayerPacket.setPosition(position); - movePlayerPacket.setRotation(getBedrockRotation()); - movePlayerPacket.setOnGround(isOnGround); - movePlayerPacket.setMode(MovePlayerPacket.Mode.HEAD_ROTATION); - session.sendUpstreamPacket(movePlayerPacket); - if (leftParrot != null) { - leftParrot.updateRotation(yaw, pitch, isOnGround); - } - if (rightParrot != null) { - rightParrot.updateRotation(yaw, pitch, isOnGround); - } - } - - @Override - public void updateRotation(float yaw, float pitch, boolean isOnGround) { - updateRotation(yaw, pitch, getHeadYaw(), isOnGround); + moveRelative(0, 0, 0, yaw, pitch, headYaw, isOnGround); } @Override