Archiviert
13
0

Added Entity#setRotation.

Unlike Entity#teleport this can also be used while the entity is inside a vehicle.
Dieser Commit ist enthalten in:
blablubbabc 2019-03-26 03:34:56 +01:00 committet von md_5
Ursprung 0bf75bbde2
Commit 0e1cea5a4a
2 geänderte Dateien mit 21 neuen und 0 gelöschten Zeilen

Datei anzeigen

@ -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);
} }

Datei anzeigen

@ -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");