@Override
 public Vector getMaximumPoint() {
   return new Vector(
       Math.max(pos1.getX(), pos2.getX()),
       Math.max(pos1.getY(), pos2.getY()),
       Math.max(pos1.getZ(), pos2.getZ()));
 }
  /**
   * Get a region that contains the walls (all faces but the ones parallel to the X-Z plane) of this
   * cuboid.
   *
   * @return a new complex region
   */
  public Region getWalls() {
    Vector min = getMinimumPoint();
    Vector max = getMaximumPoint();

    return new RegionIntersection(
        // Project to Z-Y plane
        new CuboidRegion(pos1.setX(min.getX()), pos2.setX(min.getX())),
        new CuboidRegion(pos1.setX(max.getX()), pos2.setX(max.getX())),

        // Project to X-Y plane
        new CuboidRegion(pos1.setZ(min.getZ()), pos2.setZ(min.getZ())),
        new CuboidRegion(pos1.setZ(max.getZ()), pos2.setZ(max.getZ())));
  }
 @Override
 public Vector apply(Vector vector) {
   // vector.getX() * m00 + vector.getY() * m01 + vector.getZ() * m02 + m03
   // vector.getX() * m10 + vector.getY() * m11 + vector.getZ() * m12 + m13
   // vector.getX() * m20 + vector.getY() * m21 + vector.getZ() * m22 + m23
   mutable.x = vector.getX() * m00 + vector.getY() * m01 + vector.getZ() * m02 + m03;
   mutable.y = vector.getX() * m10 + vector.getY() * m11 + vector.getZ() * m12 + m13;
   mutable.z = vector.getX() * m20 + vector.getY() * m21 + vector.getZ() * m22 + m23;
   return new Vector(
       vector.getX() * m00 + vector.getY() * m01 + vector.getZ() * m02 + m03,
       vector.getX() * m10 + vector.getY() * m11 + vector.getZ() * m12 + m13,
       vector.getX() * m20 + vector.getY() * m21 + vector.getZ() * m22 + m23);
 }
  @Command(
      aliases = {"/deform"},
      usage = "<expression>",
      desc = "Deforms a selected region with an expression",
      help =
          "Deforms a selected region with an expression\n"
              + "The expression is executed for each block and is expected\n"
              + "to modify the variables x, y and z to point to a new block\n"
              + "to fetch. See also tinyurl.com/wesyntax.",
      flags = "ro",
      min = 1,
      max = -1)
  @CommandPermissions("worldedit.region.deform")
  @Logging(ALL)
  public void deform(
      Player player,
      LocalSession session,
      EditSession editSession,
      @Selection Region region,
      @Text String expression,
      @Switch('r') boolean useRawCoords,
      @Switch('o') boolean offset)
      throws WorldEditException {
    final Vector zero;
    Vector unit;

    if (useRawCoords) {
      zero = Vector.ZERO;
      unit = Vector.ONE;
    } else if (offset) {
      zero = session.getPlacementPosition(player);
      unit = Vector.ONE;
    } else {
      final Vector min = region.getMinimumPoint();
      final Vector max = region.getMaximumPoint();

      zero = max.add(min).multiply(0.5);
      unit = max.subtract(zero);

      if (unit.getX() == 0) unit = unit.setX(1.0);
      if (unit.getY() == 0) unit = unit.setY(1.0);
      if (unit.getZ() == 0) unit = unit.setZ(1.0);
    }

    try {
      final int affected = editSession.deformRegion(region, zero, unit, expression);
      player.findFreePosition();
      BBC.VISITOR_BLOCK.send(player, affected);
    } catch (ExpressionException e) {
      player.printError(e.getMessage());
    }
  }
  @Override
  public boolean contains(Vector position) {
    double x = position.getX();
    double y = position.getY();
    double z = position.getZ();

    Vector min = getMinimumPoint();
    Vector max = getMaximumPoint();

    return x >= min.getBlockX()
        && x <= max.getBlockX()
        && y >= min.getBlockY()
        && y <= max.getBlockY()
        && z >= min.getBlockZ()
        && z <= max.getBlockZ();
  }
  @Override
  public void contract(Vector... changes) {
    checkNotNull(changes);

    for (Vector change : changes) {
      if (change.getX() < 0) {
        if (Math.max(pos1.getX(), pos2.getX()) == pos1.getX()) {
          pos1 = pos1.add(new Vector(change.getX(), 0, 0));
        } else {
          pos2 = pos2.add(new Vector(change.getX(), 0, 0));
        }
      } else {
        if (Math.min(pos1.getX(), pos2.getX()) == pos1.getX()) {
          pos1 = pos1.add(new Vector(change.getX(), 0, 0));
        } else {
          pos2 = pos2.add(new Vector(change.getX(), 0, 0));
        }
      }

      if (change.getY() < 0) {
        if (Math.max(pos1.getY(), pos2.getY()) == pos1.getY()) {
          pos1 = pos1.add(new Vector(0, change.getY(), 0));
        } else {
          pos2 = pos2.add(new Vector(0, change.getY(), 0));
        }
      } else {
        if (Math.min(pos1.getY(), pos2.getY()) == pos1.getY()) {
          pos1 = pos1.add(new Vector(0, change.getY(), 0));
        } else {
          pos2 = pos2.add(new Vector(0, change.getY(), 0));
        }
      }

      if (change.getZ() < 0) {
        if (Math.max(pos1.getZ(), pos2.getZ()) == pos1.getZ()) {
          pos1 = pos1.add(new Vector(0, 0, change.getZ()));
        } else {
          pos2 = pos2.add(new Vector(0, 0, change.getZ()));
        }
      } else {
        if (Math.min(pos1.getZ(), pos2.getZ()) == pos1.getZ()) {
          pos1 = pos1.add(new Vector(0, 0, change.getZ()));
        } else {
          pos2 = pos2.add(new Vector(0, 0, change.getZ()));
        }
      }
    }

    recalculate();
  }
 @Override
 public double getZ() {
   return m_parent.getZ();
 }
 /**
  * Converts a WorldEdit vector to a Bukkit location.
  *
  * @param world The World to create the new Location with
  * @param vec The vector to use for coordinates
  * @return The Vector as a location with a World of world
  */
 public static Location toLocation(World world, Vector vec) {
   return new Location(world, vec.getX(), vec.getY(), vec.getZ());
 }
Beispiel #9
0
 public static Point toPoint(World world, Vector pt) {
   return new Point(world, (float) pt.getX(), (float) pt.getY(), (float) pt.getZ());
 }
 public AffineTransform scale(Vector vec) {
   return scale(vec.getX(), vec.getY(), vec.getZ());
 }
 public AffineTransform translate(Vector vec) {
   return translate(vec.getX(), vec.getY(), vec.getZ());
 }