mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-22 10:35:38 +01:00
Added Entity#setRotation.
Unlike Entity#teleport this can also be used while the entity is inside a vehicle.
This commit is contained in:
parent
0bf75bbde2
commit
0e1cea5a4a
@ -29,6 +29,7 @@ import org.bukkit.permissions.PermissionAttachmentInfo;
|
|||||||
import org.bukkit.permissions.ServerOperator;
|
import org.bukkit.permissions.ServerOperator;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.bukkit.util.BoundingBox;
|
import org.bukkit.util.BoundingBox;
|
||||||
|
import org.bukkit.util.NumberConversions;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
||||||
@ -291,6 +292,21 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
|||||||
return entity.world.getWorld();
|
return entity.world.getWorld();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setRotation(float yaw, float pitch) {
|
||||||
|
NumberConversions.checkFinite(pitch, "pitch not finite");
|
||||||
|
NumberConversions.checkFinite(yaw, "yaw not finite");
|
||||||
|
|
||||||
|
yaw = Location.normalizeYaw(yaw);
|
||||||
|
pitch = Location.normalizePitch(pitch);
|
||||||
|
|
||||||
|
entity.yaw = yaw;
|
||||||
|
entity.pitch = pitch;
|
||||||
|
entity.lastYaw = yaw;
|
||||||
|
entity.lastPitch = pitch;
|
||||||
|
entity.setHeadRotation(yaw);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean teleport(Location location) {
|
public boolean teleport(Location location) {
|
||||||
return teleport(location, TeleportCause.PLUGIN);
|
return teleport(location, TeleportCause.PLUGIN);
|
||||||
}
|
}
|
||||||
|
@ -566,6 +566,11 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|||||||
getHandle().playerConnection.sendPacket(packet);
|
getHandle().playerConnection.sendPacket(packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setRotation(float yaw, float pitch) {
|
||||||
|
throw new UnsupportedOperationException("Cannot set rotation of players. Consider teleporting instead.");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean teleport(Location location, PlayerTeleportEvent.TeleportCause cause) {
|
public boolean teleport(Location location, PlayerTeleportEvent.TeleportCause cause) {
|
||||||
Preconditions.checkArgument(location != null, "location");
|
Preconditions.checkArgument(location != null, "location");
|
||||||
|
Loading…
Reference in New Issue
Block a user