@Override public void update(Location location) { location.setYaw(yaw); location.setPitch(pitch); }
/** * Read a Location from the "Pos" and "Rotation" children of a tag. * * <p>If "Pos" is absent or invalid, null is returned. * * <p>If "Rotation" is absent or invalid, it is skipped and a location without rotation is * returned. * * @param world The world of the location (see readWorld). * @param tag The tag to read from. * @return The location, or null. */ public static Location listTagsToLocation(World world, CompoundTag tag) { // check for position list final Location[] out = {null}; tag.readDoubleList("Pos", pos -> { if (pos.size() == 3) { Location location = new Location(world, pos.get(0), pos.get(1), pos.get(2)); // check for rotation tag.readFloatList("Rotation", rot -> { if (rot.size() == 2) { location.setYaw(rot.get(0)); location.setPitch(rot.get(1)); } }); out[0] = location; } }); return out[0]; }
@Override public void update(Location location) { location.setX(x); location.setY(y); location.setZ(z); location.setYaw(yaw); location.setPitch(pitch); }
@Override public void end(GlowLivingEntity entity) { Location location = entity.getLocation(); location.setPitch(0); location.setYaw(entity.getHeadYaw()); entity.teleport(location); target = null; }
@Override public void end(GlowLivingEntity entity) { Location location = entity.getLocation(); location.setPitch(0); location.setYaw(entity.getHeadYaw()); entity.teleport(location); target = null; }
/** * Copies this message's position and orientation to a {@link Location}. * * @param location the location to update */ public void update(Location location) { location.setX(x); location.setY(y); location.setZ(z); location.setYaw(yaw); location.setPitch(pitch); } }
location.setYaw(random.nextFloat() * 360 - 180); if (location.getBlock().getRelative(BlockFace.DOWN).getType() == Material.AIR) { location.subtract(0, 1, 0);
/** * Copy the contents of one Location to another. * * @param source The Location to read from. * @param dest The Location to modify. May be null. * @return The dest parameter, modified if not null. */ public static Location copyLocation(Location source, Location dest) { if (dest == null) { return null; } dest.setWorld(source.getWorld()); dest.setX(source.getX()); dest.setY(source.getY()); dest.setZ(source.getZ()); dest.setPitch(source.getPitch()); dest.setYaw(source.getYaw()); return dest; }
location.setYaw(0);
location = CommandUtils.getLocation(location, args[1], args[2], args[3]); location.setYaw(0.0f); location.setPitch(0.0f);
private void placeBoat(GlowPlayer player, ItemStack holding) { Block targetBlock = player.getTargetBlock((Set<Material>) null, 5); if (targetBlock != null && !targetBlock.isEmpty() && targetBlock.getRelative(BlockFace.UP).isEmpty()) { Location location = targetBlock.getRelative(BlockFace.UP).getLocation(); // center boat on cursor location location.add(0.6875f, 0, 0.6875f); location.setYaw(player.getLocation().getYaw()); Boat boat = targetBlock.getWorld().spawn(location, Boat.class); boat.setWoodType(woodType); if (player.getGameMode() != GameMode.CREATIVE) { player.getInventory().removeItem(holding); } } }
@Override public void rightClickBlock(GlowPlayer player, GlowBlock target, BlockFace face, ItemStack holding, Vector clickedLoc, EquipmentSlot hand) { if (target == null || target.getType() != Material.RAILS) { return; } if (minecartType.getMinecartClass() == null) { player.sendMessage( ChatColor.RED + "Minecart type '" + minecartType.getEntityType().getName() + "' is not implemented."); return; } Rails rails = (Rails) target.getState().getData(); Location location = target.getLocation().clone() .add(Math.abs(rails.getDirection().getModX()) * 0.5, 0.1, Math.abs(rails.getDirection().getModZ()) * 0.5); location.setYaw(getYaw(rails.getDirection())); target.getWorld().spawn(location, minecartType.getEntityClass()); if (player.getGameMode() != GameMode.CREATIVE) { player.getInventory().remove(holding); } super.rightClickBlock(player, target, face, holding, clickedLoc, hand); }
/** * Open the sign editor interface at the specified location. * * @param loc The location to open the editor at */ public void openSignEditor(Location loc) { signLocation = loc.clone(); signLocation.setX(loc.getBlockX()); signLocation.setY(loc.getBlockY()); signLocation.setZ(loc.getBlockZ()); signLocation.setYaw(0); signLocation.setPitch(0); // Client closes inventory when sign editor is opened if (!GlowInventoryView.isDefault(getOpenInventory())) { closeInventory(); } session.send(new SignEditorMessage(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ())); }
float yaw = player.getLocation().getYaw(); float finalYaw = Math.round(yaw / 22.5f / 2) * 45; loc.setYaw(finalYaw - 180); ((GlowWorld) loc.getWorld()) .spawn(loc, GlowArmorStand.class, CreatureSpawnEvent.SpawnReason.DEFAULT);
destination.setYaw(entityLocation.getYaw());
private void recalculateLocation() { BlockFace rightFace = getRightFace(); double modX = rightFace.getModX() * art.getBlockWidth() / 2.0; double modY = art.getBlockHeight() / 2.0; double modZ = rightFace.getModZ() * art.getBlockWidth() / 2.0; BlockFace facing = getFacing(); if (modX == 0.0) { modX = 0.5 - facing.getModX() * 0.5 - PAINTING_DEPTH / 2; } else if (modZ == 0.0) { modZ = 0.5 - facing.getModZ() * 0.5 - PAINTING_DEPTH / 2; } Location add = getTopLeftCorner().add(modX, -modY, modZ); location.setX(add.getX()); location.setY(add.getY()); location.setZ(add.getZ()); location.setPitch(0); location.setYaw(getYaw()); }
targetLocation = CommandUtils.getRotation(target.getLocation(), yaw, pitch); } else { targetLocation.setYaw(target.getLocation().getYaw()); targetLocation.setPitch(target.getLocation().getPitch());
default Location faceLocation(Location from, Location at) { Vector direction = from.toVector().subtract(at.toVector()).normalize(); Location newLocation = from.clone(); newLocation.setYaw(180 - (float) Math.toDegrees(Math.atan2(direction.getX(), direction.getZ()))); newLocation.setPitch(90 - (float) Math.toDegrees(Math.acos(direction.getY()))); return newLocation; }
public Location getLocation() { Location loc = world.getSpawnLocation(); loc.setPitch(getPitch()); loc.setYaw(getYaw()); return loc; }
@Override public void execute(Arena arena, MABoss boss) { LivingEntity target = AbilityUtils.getTarget(arena, boss.getEntity(), false); if (target == null) return; for (Player p : AbilityUtils.getNearbyPlayers(arena, boss.getEntity(), RADIUS)) { Location loc = p.getLocation(); loc.setYaw(loc.getYaw() + 45 + AbilityUtils.random.nextInt(270)); p.teleport(loc); } } }