Search in sources :

Example 1 with MutableBlockVector3

use of com.fastasyncworldedit.core.math.MutableBlockVector3 in project FastAsyncWorldEdit by IntellectualSites.

the class AngleMask method test.

@Override
public boolean test(BlockVector3 vector) {
    if (!mask.test(vector)) {
        return false;
    }
    int y = vector.getBlockY();
    if (overlay) {
        MutableBlockVector3 mutable = new MutableBlockVector3(vector);
        if (y < maxY && !adjacentAir(null, mutable)) {
            return false;
        }
    }
    int x = vector.getBlockX();
    int z = vector.getBlockZ();
    return testSlope(getExtent(), x, y, z);
}
Also used : MutableBlockVector3(com.fastasyncworldedit.core.math.MutableBlockVector3)

Example 2 with MutableBlockVector3

use of com.fastasyncworldedit.core.math.MutableBlockVector3 in project FastAsyncWorldEdit by IntellectualSites.

the class AngleMask method test.

@Override
public boolean test(final Extent extent, final BlockVector3 vector) {
    int x = vector.getBlockX();
    int y = vector.getBlockY();
    int z = vector.getBlockZ();
    if ((lastX == (lastX = x) & lastZ == (lastZ = z))) {
        int height = getHeight(extent, x, y, z);
        if (y <= height) {
            return overlay ? (lastValue && y == height) : lastValue;
        }
    }
    MutableBlockVector3 mutable = new MutableBlockVector3(x, y, z);
    if (!mask.test(extent, mutable)) {
        return false;
    }
    if (overlay) {
        if (y < maxY && !adjacentAir(extent, mutable)) {
            return lastValue = false;
        }
    }
    return testSlope(extent, x, y, z);
}
Also used : MutableBlockVector3(com.fastasyncworldedit.core.math.MutableBlockVector3)

Example 3 with MutableBlockVector3

use of com.fastasyncworldedit.core.math.MutableBlockVector3 in project FastAsyncWorldEdit by IntellectualSites.

the class SurfaceRandomOffsetPattern method travel.

private BlockVector3 travel(BlockVector3 pos) {
    cur.setComponents(pos);
    MutableBlockVector3 next;
    for (int move = 0; move < moves; move++) {
        int index = 0;
        for (int i = 0; i < allowed.length; i++) {
            next = buffer[i];
            BlockVector3 dir = BreadthFirstSearch.DIAGONAL_DIRECTIONS[i];
            next.setComponents(cur.getBlockX() + dir.getBlockX(), cur.getBlockY() + dir.getBlockY(), cur.getBlockZ() + dir.getBlockZ());
            if (allowed(next)) {
                allowed[index++] = next;
            }
        }
        if (index == 0) {
            return cur;
        }
        next = allowed[ThreadLocalRandom.current().nextInt(index)];
        cur.setComponents(next.getBlockX(), next.getBlockY(), next.getBlockZ());
    }
    return cur;
}
Also used : MutableBlockVector3(com.fastasyncworldedit.core.math.MutableBlockVector3) BlockVector3(com.sk89q.worldedit.math.BlockVector3) MutableBlockVector3(com.fastasyncworldedit.core.math.MutableBlockVector3)

Example 4 with MutableBlockVector3

use of com.fastasyncworldedit.core.math.MutableBlockVector3 in project FastAsyncWorldEdit by IntellectualSites.

the class ScaleTransform method setBlock.

@Override
public <B extends BlockStateHolder<B>> boolean setBlock(int x1, int y1, int z1, B block) throws WorldEditException {
    boolean result = false;
    MutableVector3 vector3 = getPos(x1, y1, z1);
    MutableBlockVector3 pos = new MutableBlockVector3();
    double sx = vector3.getX();
    double sy = vector3.getY();
    double sz = vector3.getZ();
    double ex = vector3.getX() + dx;
    double ey = Math.min(maxy, sy + dy);
    double ez = vector3.getZ() + dz;
    for (pos.mutY(sy); pos.getY() < ey; pos.mutY(pos.getY() + 1)) {
        for (pos.mutZ(sz); pos.getZ() < ez; pos.mutZ(pos.getZ() + 1)) {
            for (pos.mutX(sx); pos.getX() < ex; pos.mutX(pos.getX() + 1)) {
                if (!getExtent().contains(pos)) {
                    continue;
                }
                result |= super.setBlock(pos, block);
            }
        }
    }
    return result;
}
Also used : MutableVector3(com.fastasyncworldedit.core.math.MutableVector3) MutableBlockVector3(com.fastasyncworldedit.core.math.MutableBlockVector3)

Example 5 with MutableBlockVector3

use of com.fastasyncworldedit.core.math.MutableBlockVector3 in project FastAsyncWorldEdit by IntellectualSites.

the class ScaleTransform method setBlock.

@Override
public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 location, B block) throws WorldEditException {
    boolean result = false;
    MutableVector3 vector3 = getPos(location);
    MutableBlockVector3 pos = new MutableBlockVector3();
    double sx = vector3.getX();
    double sy = vector3.getY();
    double sz = vector3.getZ();
    double ex = sx + dx;
    double ey = Math.max(minY, Math.min(maxy, sy + dy));
    double ez = sz + dz;
    for (pos.mutY(sy); pos.getY() < ey; pos.mutY(pos.getY() + 1)) {
        for (pos.mutZ(sz); pos.getZ() < ez; pos.mutZ(pos.getZ() + 1)) {
            for (pos.mutX(sx); pos.getX() < ex; pos.mutX(pos.getX() + 1)) {
                if (!getExtent().contains(pos)) {
                    continue;
                }
                result |= super.setBlock(pos, block);
            }
        }
    }
    return result;
}
Also used : MutableVector3(com.fastasyncworldedit.core.math.MutableVector3) MutableBlockVector3(com.fastasyncworldedit.core.math.MutableBlockVector3)

Aggregations

MutableBlockVector3 (com.fastasyncworldedit.core.math.MutableBlockVector3)34 BlockVector3 (com.sk89q.worldedit.math.BlockVector3)12 Location (com.sk89q.worldedit.util.Location)7 Extent (com.sk89q.worldedit.extent.Extent)5 MutableVector3 (com.fastasyncworldedit.core.math.MutableVector3)4 World (com.sk89q.worldedit.world.World)4 BlockState (com.sk89q.worldedit.world.block.BlockState)4 LocalBlockVectorSet (com.fastasyncworldedit.core.math.LocalBlockVectorSet)2 BaseBlock (com.sk89q.worldedit.world.block.BaseBlock)2 BlockType (com.sk89q.worldedit.world.block.BlockType)2 ArrayList (java.util.ArrayList)2 Iterator (java.util.Iterator)2 NoSuchElementException (java.util.NoSuchElementException)2 FaweRegionExtent (com.fastasyncworldedit.core.extent.FaweRegionExtent)1 AbstractChangeSet (com.fastasyncworldedit.core.history.changeset.AbstractChangeSet)1 IntValueReader (com.fastasyncworldedit.core.jnbt.streamer.IntValueReader)1 BlockVectorSet (com.fastasyncworldedit.core.math.BlockVectorSet)1 IntTriple (com.fastasyncworldedit.core.math.IntTriple)1 MutableBlockVector2 (com.fastasyncworldedit.core.math.MutableBlockVector2)1 BlockVector2 (com.sk89q.worldedit.math.BlockVector2)1