@Override public void update(Location location) { location.setX(x); location.setY(y); location.setZ(z); location.setYaw(yaw); location.setPitch(pitch); }
@Override public void update(Location location) { location.setX(x); location.setY(y); location.setZ(z); }
@Override public Location getLocation(Location loc) { if (loc == null) { return null; } loc.setWorld(getWorld()); loc.setX(x); loc.setY(y); loc.setZ(z); return loc; }
/** * 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); } }
/** * Copy the position contents (x,y,z) of one Location to another. * * @param source The Location to read the x, y and z values from. * @param dest The Location to modify the x, y and z values. May be null. * @return The dest parameter, modified if not null. */ public static Location copyPosition(Location source, Location dest) { if (dest == null) { return null; } dest.setX(source.getX()); dest.setY(source.getY()); dest.setZ(source.getZ()); return dest; }
/** * 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; }
private void throwEnderPearl(GlowPlayer player) { Location throwLoc = player.getLocation(); throwLoc.setY(throwLoc.getY() + 1.5); player.launchProjectile(EnderPearl.class); player.playSound(player.getLocation(), Sound.ENTITY_ENDERPEARL_THROW, 3, 1); player.setEnderPearlCooldown(ENDER_PEARL_COOLDOWN_TICKS); } }
/** * 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())); }
@Override public boolean eat(GlowPlayer player, ItemStack item) { if (!super.eat(player, item)) { return false; } for (int i = 0; i < 16; i++) { //16 attempts: +/- 8 blocks in every direction Location attempt = player.getLocation(); double deltaX = ThreadLocalRandom.current().nextDouble() * 16 - 8; double deltaY = ThreadLocalRandom.current().nextDouble() * 16 - 8; double deltaZ = ThreadLocalRandom.current().nextDouble() * 16 - 8; attempt.setX(attempt.getX() + deltaX); attempt.setY(Math.min(Math.max(attempt.getY() + deltaY, 0), player.getWorld().getMaxHeight() - 1)); attempt.setZ(attempt.getZ() + deltaZ); attempt = getSafeLocation(attempt); if (attempt != null) { player.getWorld().playSound(player.getLocation(), Sound.ITEM_CHORUS_FRUIT_TELEPORT, SoundCategory.PLAYERS, 1, 1); player.teleport(attempt); break; } } return true; }
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()); }
loc.setY(blockY); loc.setX(loc.getBlockX() + 0.5);
playerLocation.setY(y); playerLocation.setZ(z);
@Override public void activate(final Location location, final String material) { String materialKey = splitMaterialKey(material)[0]; if ((materialKey.equals(CLONE_MATERIAL_KEY) || materialKey.equals(REPLICATE_MATERIAL_KEY)) && location != null) { Location cloneFrom = location.clone(); cloneFrom.setY(cloneFrom.getY() - 1); setCloneLocation(cloneFrom); } else if (materialKey.equals(MAP_MATERIAL_KEY) || materialKey.equals(SCHEMATIC_MATERIAL_KEY)) { clearCloneTarget(); } }
/** * {@inheritDoc} */ @Override public boolean isBlockAboveAir(Location l) { Location downOne = l.clone(); downOne.setY(downOne.getY() - 1); return (downOne.getBlock().getType() == Material.AIR); }
/** * {@inheritDoc} */ @Override public Location getBlockLocation(Location l) { l.setX(l.getBlockX()); l.setY(l.getBlockY()); l.setZ(l.getBlockZ()); return l; }
/** * This method simply does some rounding, rather than forcing a call to the server to get the blockdata. * * @param l The location to round to the block location * @return A rounded location. */ public static Location getBlockLocation(Location l) { l.setX(l.getBlockX()); l.setY(l.getBlockY()); l.setZ(l.getBlockZ()); return l; }
Location loc = player.getLocation(); loc.setX(event.getBlockClicked().getX()); loc.setZ(event.getBlockClicked().getZ()); loc.setY(event.getBlockClicked().getY()); World world = loc.getWorld(); Sign sign = (Sign)world.getTileEntity(world.getBlockAt(loc));
@Override public void updated(@Nullable ItemStack itemStack) { if (!CompatibilityUtils.isEmpty(itemStack)) { location.setX(location.getX() + 0.5); location.setY(location.getY() + 0.5); location.setZ(location.getZ() + 0.5); location.getWorld().dropItemNaturally(location, itemStack); } } });
public static void fireworkParticleShower(Player player, Color color) { Location location = player.getLocation(); location.setY(location.getY() + (player.isInsideVehicle() ? 1.0 : -1.0)); location.setPitch(-90); Firework firework = (Firework) player.getWorld().spawnEntity(location, EntityType.FIREWORK); firework.setMetadata(mcMMO.funfettiMetadataKey, new FixedMetadataValue(mcMMO.p, null)); FireworkMeta fireworkMeta = firework.getFireworkMeta(); FireworkEffect effect = FireworkEffect.builder().flicker(false).withColor(color).with((Config.getInstance().getLargeFireworks() ? Type.BALL_LARGE : Type.BALL)).trail(true).build(); fireworkMeta.addEffect(effect); fireworkMeta.addEffect(effect); fireworkMeta.setPower(0); firework.setFireworkMeta(fireworkMeta); }