本文整理汇总了Java中org.bukkit.Location.setPitch方法的典型用法代码示例。如果您正苦于以下问题:Java Location.setPitch方法的具体用法?Java Location.setPitch怎么用?Java Location.setPitch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.Location
的用法示例。
在下文中一共展示了Location.setPitch方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setDirection
import org.bukkit.Location; //导入方法依赖的package包/类
public static Location setDirection(Location location, Vector vector) {
final double _2PI = 2 * Math.PI;
final double x = vector.getX();
final double z = vector.getZ();
if (x == 0 && z == 0) {
location.setPitch(vector.getY() > 0 ? -90 : 90);
return location;
}
double theta = Math.atan2(-x, z);
location.setYaw((float) Math.toDegrees((theta + _2PI) % _2PI));
double x2 = Numbers.square(x);
double z2 = Numbers.square(z);
double xz = Math.sqrt(x2 + z2);
location.setPitch((float) Math.toDegrees(Math.atan(-vector.getY() / xz)));
return location;
}
示例2: resetPosition
import org.bukkit.Location; //导入方法依赖的package包/类
/**
* Modify the to location of the given event to prevent the movement and
* move the player so they are standing on the center of the block at the
* from location.
*/
private static void resetPosition(final PlayerMoveEvent event) {
Location newLoc;
double yValue = event.getFrom().getY();
if(yValue <= 0 || event instanceof PlayerTeleportEvent) {
newLoc = event.getFrom();
} else {
newLoc = BlockUtils.center(event.getFrom()).subtract(new Vector(0, 0.5, 0));
if(newLoc.getBlock() != null) {
switch(newLoc.getBlock().getType()) {
case STEP:
case WOOD_STEP:
newLoc.add(new Vector(0, 0.5, 0));
break;
default: break;
}
}
}
newLoc.setPitch(event.getTo().getPitch());
newLoc.setYaw(event.getTo().getYaw());
event.setCancelled(false);
event.setTo(newLoc);
}
示例3: onPlayerDamage
import org.bukkit.Location; //导入方法依赖的package包/类
@EventHandler
public void onPlayerDamage(EntityDamageEvent event) {
if (!(event.getEntity() instanceof Player))
return;
event.setCancelled(true);
if (event.getCause()==DamageCause.VOID) {
Location l = event.getEntity().getWorld().getSpawnLocation();
l.setX(14.5);
l.setY(10.5);
l.setZ(-795.5);
l.setPitch(0.5F);
l.setYaw(90 * RandomUtil.between(1, 4));
event.getEntity().teleport(l);
}
}
示例4: onPlayerMove
import org.bukkit.Location; //导入方法依赖的package包/类
@EventHandler
public void onPlayerMove(PlayerMoveEvent event) {
Gamer g = Gamer.get(event.getPlayer().getName());
if (Scheduler.getState() == State.WAITING && !g.getBoolean("moveable")) {
Location to = g.getLocation("spawn-block");
if (to == null)
return;
if (Map.getCurrent().getWorld() != g.getPlayer().getWorld()) {
event.getPlayer().teleport(to);
return;
}
to.setYaw(event.getPlayer().getLocation().getYaw());
to.setPitch(event.getPlayer().getLocation().getPitch());
if (to.getBlock().getX() != event.getTo().getBlock().getX())
event.getPlayer().teleport(to);
else if (to.getBlock().getZ() != event.getTo().getBlock().getZ())
event.getPlayer().teleport(to);
}
}
示例5: clientMoved
import org.bukkit.Location; //导入方法依赖的package包/类
public void clientMoved(final Channel channel, final double x, final double y, final double z, final double rx, final double ry) {
if (this.entityClass == null) {
// No bukkit entity, no web-bsaed entity for other players either TODO: synthesize a placeholder entity id for web-to-web only?
return;
}
final Entity entity = this.channelId2Entity.get(channel.id());
Location location = webSocketServerThread.blockBridge.toBukkitPlayerLocation(x, y, z);
if (constrainToSandbox && !webSocketServerThread.blockBridge.withinSandboxRange(location)) {
webSocketServerThread.log(Level.FINEST, "client tried to move outside of sandbox: "+location);
return;
}
// Opposite of PlayerBridge encodeLocation - given negated radians, convert to degrees
location.setYaw((float)(-rx * 180 / Math.PI));
location.setPitch((float)(-ry * 180 / Math.PI));
// Move the surrogate entity to represent where the web player is
entity.teleport(location);
// Notify other web clients (except this one) they moved
webSocketServerThread.broadcastLineExcept(channel.id(), "P,"+entity.getEntityId()+","+webSocketServerThread.playersBridge.encodeLocation(location));
}
示例6: onPlayerMoveWhenNotLoaded
import org.bukkit.Location; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOW)
public void onPlayerMoveWhenNotLoaded(PlayerMoveEvent event) {
Player player = event.getPlayer();
if (!InventoryManager.isAllowedWorld(player.getWorld()) || InventoryManager.playerIsLoaded(player)) {
return;
}
if (PlayerLoader.isPreparedPlayer(player)) {
PlayerLoader.removePlayer(player);
player.kickPlayer(RPGInventory.getLanguage().getMessage("error.rp.denied"));
event.setCancelled(true);
} else {
Location toLocation = event.getTo();
Location newLocation = event.getFrom().clone();
//noinspection deprecation
if (!player.isOnGround()) {
newLocation.setY(toLocation.getY());
}
newLocation.setPitch(toLocation.getPitch());
newLocation.setYaw(toLocation.getYaw());
event.setTo(newLocation);
}
}
示例7: handleLogin
import org.bukkit.Location; //导入方法依赖的package包/类
@Override
public void handleLogin(Player p)
{
super.handleLogin(p);
p.setGameMode(GameMode.ADVENTURE);
p.setLevel(0);
p.setExp(0);
p.setFoodLevel(20);
p.setSaturation(20);
Location spec = new Location(AgarMC.get().getWorld(), origin.getX() + dimensions / 2, origin.getY() + 20, origin.getZ() + dimensions / 2);
spec.setPitch(90);
p.teleport(spec);
p.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 1));
if (gamePlayers.size() >= SamaGamesAPI.get().getGameManager().getGameProperties().getMaxSlots())
this.status = Status.IN_GAME;
Titles.sendTabTitle(p, ChatColor.GREEN + "Bienvenue sur " + ChatColor.AQUA + "SamaGames" + ChatColor.GREEN + " !\n",
ChatColor.AQUA + "\nTeamSpeak : " + ChatColor.GREEN + "ts.samagames.net");
}
示例8: getLocation
import org.bukkit.Location; //导入方法依赖的package包/类
public Location getLocation(Location loc) {
if (loc != null) {
loc.setWorld(getWorld());
loc.setX(x);
loc.setY(y);
loc.setZ(z);
loc.setYaw(0);
loc.setPitch(0);
}
return loc;
}
示例9: getLocation
import org.bukkit.Location; //导入方法依赖的package包/类
public Location getLocation(Location loc) {
if (loc != null) {
loc.setWorld(world);
loc.setX(x);
loc.setY(y);
loc.setZ(z);
loc.setYaw(0);
loc.setPitch(0);
}
return loc;
}
示例10: onPlayerMove
import org.bukkit.Location; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onPlayerMove(final PlayerMoveEvent event) {
if(freeze.isFrozen(event.getPlayer())) {
Location old = event.getFrom();
old.setPitch(event.getTo().getPitch());
old.setYaw(event.getTo().getYaw());
event.setTo(old);
}
}
示例11: lookAt
import org.bukkit.Location; //导入方法依赖的package包/类
public static Location lookAt(Location loc, Location lookat)
{
//Clone the loc to prevent applied changes to the input loc
loc = loc.clone();
// Values of change in distance (make it relative)
double dx = lookat.getX() - loc.getX();
double dy = lookat.getY() - loc.getY();
double dz = lookat.getZ() - loc.getZ();
// Set yaw
if (dx != 0)
{
// Set yaw start value based on dx
if (dx < 0)
loc.setYaw((float) (1.5 * Math.PI));
else
loc.setYaw((float) (0.5 * Math.PI));
loc.setYaw((float) loc.getYaw() - (float) Math.atan(dz / dx));
}
else if (dz < 0)
loc.setYaw((float) Math.PI);
// Get the distance from dx/dz
double dxz = Math.sqrt(Math.pow(dx, 2) + Math.pow(dz, 2));
// Set pitch
loc.setPitch((float) -Math.atan(dy / dxz));
// Set values, convert to degrees (invert the yaw since Bukkit uses a different yaw dimension format)
loc.setYaw(-loc.getYaw() * 180f / (float) Math.PI);
loc.setPitch(loc.getPitch() * 180f / (float) Math.PI);
return loc;
}
示例12: run
import org.bukkit.Location; //导入方法依赖的package包/类
@Override
public void run()
{
Location location = new Location(this.center.getWorld(), this.center.getX() + Math.cos(this.i) * RADIUS, this.center.getY() + 1D, this.center.getZ() + Math.sin(this.i) * RADIUS);
location.setDirection(this.center.clone().subtract(location).toVector().setY(location.getY()));
location.setPitch(0.0F);
this.camera.move(location);
this.i += 0.025D;
if (this.i > Math.PI * 2.0D)
this.i = 0.0D;
}
示例13: lookAt
import org.bukkit.Location; //导入方法依赖的package包/类
/**
* Change the yaw & pitch of a {@link Location} to make it look at another {@link Location}
*
* @param loc the {@link Location} which yaw & pitch should be modified
* @param lookat the {@link Location} to look at
* @return the new modified {@link Location}
*/
public static Location lookAt(Location loc, Location lookat) {
loc = loc.clone();
double dx = lookat.getX() - loc.getX();
double dy = lookat.getY() - loc.getY();
double dz = lookat.getZ() - loc.getZ();
if (dx != 0) {
if (dx < 0) {
loc.setYaw((float) (1.5 * Math.PI));
} else {
loc.setYaw((float) (0.5 * Math.PI));
}
loc.setYaw(loc.getYaw() - (float) Math.atan(dz / dx));
} else if (dz < 0) {
loc.setYaw((float) Math.PI);
}
double dxz = Math.sqrt(Math.pow(dx, 2) + Math.pow(dz, 2));
loc.setPitch((float) -Math.atan(dy / dxz));
loc.setYaw(-loc.getYaw() * 180f / (float) Math.PI);
loc.setPitch(loc.getPitch() * 180f / (float) Math.PI);
return loc;
}
示例14: onPlayerJoin
import org.bukkit.Location; //导入方法依赖的package包/类
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
Player p = event.getPlayer();
joinTimes.put(event.getPlayer().getName(), new Date());
event.setJoinMessage(null);
p.setHealth(20);
p.setFoodLevel(20);
p.getInventory().clear();
Location l = event.getPlayer().getWorld().getSpawnLocation();
l.setX(14.5);
l.setY(10.5);
l.setZ(-795.5);
l.setPitch(0.5F);
l.setYaw(90 * RandomUtil.between(1, 4));
p.teleport(l);
p.setGameMode(GameMode.SURVIVAL);
p.getInventory().addItem(Lobby.book);
p.getInventory().addItem(Lobby.compass);
Lobby.addPotionEffect(event.getPlayer(), new PotionEffect(PotionEffectType.SPEED, 2147483647, 2));
if (Gamer.get(p.getName()).getRank().getLevel() >= RankType.ADMIN.getLevel())
event.getPlayer().addAttachment(Lobby.getInstance(), "bukkit.command.gamemode", true);
}
示例15: getCameraPosition
import org.bukkit.Location; //导入方法依赖的package包/类
private Location getCameraPosition() {
Location camera = gate.clone();
camera.add(face.getModX() * -4, 2, face.getModZ() * -4);
camera.setPitch(10);
camera.setYaw(face.getOppositeFace().ordinal() * 90);
return camera;
}