Use new ClientboundPlayerRotationPacket for setting player rotation

This commit is contained in:
Owen1212055 2024-10-28 12:14:00 -04:00
parent 5364f9e7a0
commit 303d82e48c

View file

@ -121,15 +121,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
public void setRotation(float yaw, float pitch) {
- throw new UnsupportedOperationException("Cannot set rotation of players. Consider teleporting instead.");
+ // Paper start - Teleport API
+ Location targetLocation = this.getEyeLocation();
+ targetLocation.setYaw(yaw);
+ targetLocation.setPitch(pitch);
+
+ org.bukkit.util.Vector direction = targetLocation.getDirection();
+ direction.multiply(9999999); // We need to move the target block.. FAR out
+ targetLocation.add(direction);
+ this.lookAt(targetLocation, io.papermc.paper.entity.LookAnchor.EYES);
+ // Paper end
+ if (this.getHandle().connection == null) return;
+ this.getHandle().forceSetRotation(yaw, pitch);
+ // Paper end - Teleportation API
}
@Override