Fix entity motion (arrows now rotate correctly) (#3307)

This commit is contained in:
Kevin Ludwig 2022-09-30 18:12:27 +02:00 committed by GitHub
parent 47d14e12eb
commit c31bd456f6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -216,19 +216,41 @@ public class Entity {
} }
public void moveRelative(double relX, double relY, double relZ, float yaw, float pitch, float headYaw, boolean isOnGround) { public void moveRelative(double relX, double relY, double relZ, float yaw, float pitch, float headYaw, boolean isOnGround) {
setYaw(yaw); position = Vector3f.from(position.getX() + relX, position.getY() + relY, position.getZ() + relZ);
setPitch(pitch);
setHeadYaw(headYaw);
setOnGround(isOnGround);
this.position = Vector3f.from(position.getX() + relX, position.getY() + relY, position.getZ() + relZ);
MoveEntityAbsolutePacket moveEntityPacket = new MoveEntityAbsolutePacket(); MoveEntityDeltaPacket moveEntityPacket = new MoveEntityDeltaPacket();
moveEntityPacket.setRuntimeEntityId(geyserId); moveEntityPacket.setRuntimeEntityId(geyserId);
moveEntityPacket.setPosition(position); if (relX != 0.0) {
moveEntityPacket.setRotation(getBedrockRotation()); moveEntityPacket.setX(position.getX());
moveEntityPacket.setOnGround(isOnGround); moveEntityPacket.getFlags().add(MoveEntityDeltaPacket.Flag.HAS_X);
moveEntityPacket.setTeleported(false); }
if (relY != 0.0) {
moveEntityPacket.setY(position.getY());
moveEntityPacket.getFlags().add(MoveEntityDeltaPacket.Flag.HAS_Y);
}
if (relZ != 0.0) {
moveEntityPacket.setZ(position.getZ());
moveEntityPacket.getFlags().add(MoveEntityDeltaPacket.Flag.HAS_Z);
}
if (pitch != this.pitch) {
this.pitch = pitch;
moveEntityPacket.setPitch(pitch);
moveEntityPacket.getFlags().add(MoveEntityDeltaPacket.Flag.HAS_PITCH);
}
if (yaw != this.yaw) {
this.yaw = yaw;
moveEntityPacket.setYaw(yaw);
moveEntityPacket.getFlags().add(MoveEntityDeltaPacket.Flag.HAS_YAW);
}
if (headYaw != this.headYaw) {
this.headYaw = headYaw;
moveEntityPacket.setHeadYaw(headYaw);
moveEntityPacket.getFlags().add(MoveEntityDeltaPacket.Flag.HAS_HEAD_YAW);
}
setOnGround(isOnGround);
if (isOnGround) {
moveEntityPacket.getFlags().add(MoveEntityDeltaPacket.Flag.ON_GROUND);
}
session.sendUpstreamPacket(moveEntityPacket); session.sendUpstreamPacket(moveEntityPacket);
} }