Package com.sk89q.worldedit

Examples of com.sk89q.worldedit.Vector


     *
     * @return width
     */
    @Override
    public int getWidth() {
        Vector min = getMinimumPoint();
        Vector max = getMaximumPoint();

        return (int) (max.getX() - min.getX() + 1);
    }
View Full Code Here


     *
     * @return height
     */
    @Override
    public int getHeight() {
        Vector min = getMinimumPoint();
        Vector max = getMaximumPoint();

        return (int) (max.getY() - min.getY() + 1);
    }
View Full Code Here

     *
     * @return length
     */
    @Override
    public int getLength() {
        Vector min = getMinimumPoint();
        Vector max = getMaximumPoint();

        return (int) (max.getZ() - min.getZ() + 1);
    }
View Full Code Here

     */
    @Override
    public Set<Vector2D> getChunks() {
        final Set<Vector2D> chunks = new HashSet<Vector2D>();

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

        final int minY = min.getBlockY();

        for (int x = min.getBlockX(); x <= max.getBlockX(); ++x) {
            for (int z = min.getBlockZ(); z <= max.getBlockZ(); ++z) {
                if (!contains(new Vector(x, minY, z))) {
                    continue;
                }

                chunks.add(new BlockVector2D(
                    x >> ChunkStore.CHUNK_SHIFTS,
View Full Code Here

    @Override
    public Set<Vector> getChunkCubes() {
        final Set<Vector> chunks = new HashSet<Vector>();

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

        for (int x = min.getBlockX(); x <= max.getBlockX(); ++x) {
            for (int y = min.getBlockY(); y <= max.getBlockY(); ++y) {
                for (int z = min.getBlockZ(); z <= max.getBlockZ(); ++z) {
                    if (!contains(new Vector(x, y, z))) {
                        continue;
                    }

                    chunks.add(new BlockVector(
                        x >> ChunkStore.CHUNK_SHIFTS,
View Full Code Here

        this.baseY = baseY;

        Collection<Vector> directions = getDirections();
        directions.clear();
        directions.add(new Vector(1, 0, 0));
        directions.add(new Vector(-1, 0, 0));
        directions.add(new Vector(0, 0, 1));
        directions.add(new Vector(0, 0, -1));
        directions.add(new Vector(0, -1, 0));
    }
View Full Code Here

    /**
     * Add the directions along the axes as directions to visit.
     */
    protected void addAxes() {
        directions.add(new Vector(0, -1, 0));
        directions.add(new Vector(0, 1, 0));
        directions.add(new Vector(-1, 0, 0));
        directions.add(new Vector(1, 0, 0));
        directions.add(new Vector(0, 0, -1));
        directions.add(new Vector(0, 0, 1));
    }
View Full Code Here

    /**
     * Add the diagonal directions as directions to visit.
     */
    protected void addDiagonal() {
        directions.add(new Vector(1, 0, 1));
        directions.add(new Vector(-1, 0, -1));
        directions.add(new Vector(1, 0, -1));
        directions.add(new Vector(-1, 0, 1));
    }
View Full Code Here

        return affected;
    }

    @Override
    public Operation resume(RunContext run) throws WorldEditException {
        Vector position;
       
        while ((position = queue.poll()) != null) {
            if (function.apply(position)) {
                affected++;
            }

            for (Vector dir : directions) {
                visit(position, position.add(dir));
            }
        }

        return null;
    }
View Full Code Here

     *
     * @return the transformed region
     */
    public Region getTransformedRegion() {
        Region region = original.getRegion();
        Vector minimum = region.getMinimumPoint();
        Vector maximum = region.getMaximumPoint();

        Transform transformAround =
                new CombinedTransform(
                        new AffineTransform().translate(original.getOrigin().multiply(-1)),
                        transform,
                        new AffineTransform().translate(original.getOrigin()));

        Vector[] corners = new Vector[] {
                minimum,
                maximum,
                minimum.setX(maximum.getX()),
                minimum.setY(maximum.getY()),
                minimum.setZ(maximum.getZ()),
                maximum.setX(minimum.getX()),
                maximum.setY(minimum.getY()),
                maximum.setZ(minimum.getZ()) };

        for (int i = 0; i < corners.length; i++) {
            corners[i] = transformAround.apply(corners[i]);
        }

        Vector newMinimum = corners[0];
        Vector newMaximum = corners[0];

        for (int i = 1; i < corners.length; i++) {
            newMinimum = Vector.getMinimum(newMinimum, corners[i]);
            newMaximum = Vector.getMaximum(newMaximum, corners[i]);
        }

        // After transformation, the points may not really sit on a block,
        // so we should expand the region for edge cases
        newMinimum = newMinimum.setX(Math.floor(newMinimum.getX()));
        newMinimum = newMinimum.setY(Math.floor(newMinimum.getY()));
        newMinimum = newMinimum.setZ(Math.floor(newMinimum.getZ()));

        newMaximum = newMaximum.setX(Math.ceil(newMaximum.getX()));
        newMaximum = newMaximum.setY(Math.ceil(newMaximum.getY()));
        newMaximum = newMaximum.setZ(Math.ceil(newMaximum.getZ()));

        return new CuboidRegion(newMinimum, newMaximum);
    }
View Full Code Here

TOP

Related Classes of com.sk89q.worldedit.Vector

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.