@Override public void update(Location location) { location.setX(x); location.setY(y); location.setZ(z); }
@Override public void update(Location location) { location.setX(x); location.setY(y); location.setZ(z); location.setYaw(yaw); location.setPitch(pitch); }
@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; }
loc2.setZ(loc2.getZ() / j); double d7 = Math.sqrt(loc1.getX() * loc1.getX() + loc1.getZ() * loc1.getZ()); double z = zRangeMin >= zRangeMax ? zRangeMin : random.nextDouble() * (zRangeMax - zRangeMin) + zRangeMin; loc2.setX(x); loc2.setZ(z); loc2.setZ(zRangeMin); swap = true; } else if (loc2.getZ() > zRangeMax) { loc2.setZ(zRangeMax); swap = true; locations[i] = (new Location(world, x, 0, z)); loc1.setX(x); loc1.setZ(z); flag = true;
@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; }
/** * 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; }
/** * 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())); }
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.setX(loc.getBlockX() + 0.5); loc.setZ(loc.getBlockZ() + 0.5); return loc; } else {
playerLocation.setZ(z);
private void incrementSide(){ xSideNeg1.setZ(xSideNeg1.getZ() + 1); xSideNeg2.setZ(xSideNeg2.getZ() + 1); xSidePos1.setZ(xSidePos1.getZ() - 1); xSidePos2.setZ(xSidePos2.getZ() - 1); zSideNeg1.setX(zSideNeg1.getX() + 1); zSideNeg2.setX(zSideNeg2.getX() + 1); zSidePos1.setX(zSidePos1.getX() - 1); zSidePos2.setX(zSidePos2.getX() - 1); }
/** * {@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; }
private void fix(Location loc) { loc.setX(loc.getBlockX() + 0.5D); loc.setY(loc.getBlockY() + 1); loc.setZ(loc.getBlockZ() + 0.5D); }
@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); } } });
@Override public void show() { temp.setWorld(world); temp.setX(position.getX()); temp.setY(position.getY()); temp.setZ(position.getZ()); send(Material.SKELETON_SKULL, (byte)0); super.show(); }
@NotNull public static Location getRandLoc(Location loc, int xRadius, int yRadius, int zRadius) { Location newLoc = loc.clone(); newLoc.setX(ACFUtil.rand(loc.getX()-xRadius, loc.getX()+xRadius)); newLoc.setY(ACFUtil.rand(loc.getY()-yRadius, loc.getY()+yRadius)); newLoc.setZ(ACFUtil.rand(loc.getZ()-zRadius, loc.getZ()+zRadius)); return newLoc; }
public static Location lerp(Location loc1, Location loc2, double stage) { Location newloc = new Location(loc1.getWorld(), 0, 0, 0); newloc.setX(lerp(loc1.getX(), loc2.getX(), stage)); newloc.setY(lerp(loc1.getY(), loc2.getY(), stage)); newloc.setZ(lerp(loc1.getZ(), loc2.getZ(), stage)); newloc.setYaw((float) lerp(loc1.getYaw(), loc2.getYaw(), stage)); newloc.setPitch((float) lerp(loc1.getPitch(), loc2.getPitch(), stage)); return newloc; }