Fix player head yaw for moveAbsolute teleport

Fixes SkullPlayerEntity rotation
Remove redundant? overrides
This commit is contained in:
davchoo 2022-05-27 19:03:12 -04:00
parent 7b9a98aa09
commit 87320f0a78
No known key found for this signature in database
GPG key ID: A0168C8E45799B7D

View file

@ -168,6 +168,12 @@ public class PlayerEntity extends LivingEntity {
} }
session.sendUpstreamPacket(movePlayerPacket); session.sendUpstreamPacket(movePlayerPacket);
if (teleported) {
// As of 1.19.0, head yaw seems to be ignored during teleports.
updateHeadLookRotation(headYaw);
}
if (leftParrot != null) { if (leftParrot != null) {
leftParrot.moveAbsolute(position, yaw, pitch, headYaw, true, teleported); 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) { public void updateRotation(float yaw, float pitch, float headYaw, boolean isOnGround) {
// the method below is called by super.updateRotation(yaw, pitch, isOnGround). moveRelative(0, 0, 0, yaw, pitch, headYaw, 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);
} }
@Override @Override