Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions paper-api/src/main/java/org/bukkit/entity/Entity.java
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,16 @@ public interface Entity extends Metadatable, CommandSender, Nameable, Persistent
*/
public void setRotation(float yaw, float pitch);

/**
* Sets the entity's rotation.
*
* @param yaw the yaw
* @param relativeYaw whether the yaw is relative to the current yaw
* @param pitch the pitch
* @param relativePitch whether the pitch is relative to the current pitch
*/
void setRotation(float yaw, boolean relativeYaw, float pitch, boolean relativePitch);

// Paper start - Teleport API
/**
* Teleports this entity to the given location.
Expand Down
14 changes: 14 additions & 0 deletions paper-api/src/main/java/org/bukkit/entity/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -3795,6 +3795,20 @@ public int getPing() {
*/
void setRotation(float yaw, float pitch);

/**
* Set the player's rotation.
* <p>
* Note: When relative parameters are set, client will do interpolations to
* make the rotation smooth, it's different from just send a new rotation with
* yaw or pitch addition.
*
* @param yaw the yaw
* @param relativeYaw whether the yaw is relative to the current yaw
* @param pitch the pitch
* @param relativePitch whether the pitch is relative to the current pitch
*/
void setRotation(float yaw, boolean relativeYaw, float pitch, boolean relativePitch);

/**
* Causes the player to look towards the given entity.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,14 @@ public void setRotation(float yaw, float pitch) {
this.getHandle().forceSetRotation(yaw, false, pitch, false);
}

@Override
public void setRotation(float yaw, final boolean relativeYaw, float pitch, final boolean relativePitch) {
NumberConversions.checkFinite(pitch, "pitch not finite");
NumberConversions.checkFinite(yaw, "yaw not finite");

this.getHandle().forceSetRotation(yaw, relativeYaw, pitch, relativePitch);
}

@Override
public boolean teleport(Location location) {
return this.teleport(location, TeleportCause.PLUGIN);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1299,6 +1299,13 @@ public void setRotation(float yaw, float pitch) {
super.setRotation(yaw, pitch);
}

@Override
public void setRotation(final float yaw, final boolean relativeYaw, final float pitch, final boolean relativePitch) {
if (this.getHandle().connection == null) return;

super.setRotation(yaw, relativeYaw, pitch, relativePitch);
}

@Override
public void lookAt(org.bukkit.entity.@NonNull Entity entity, @NonNull LookAnchor playerAnchor, @NonNull LookAnchor entityAnchor) {
this.getHandle().lookAt(toNmsAnchor(playerAnchor), ((CraftEntity) entity).getHandle(), toNmsAnchor(entityAnchor));
Expand Down
Loading