Java Code Examples for com.sk89q.worldedit.regions.Region#getLength()

The following examples show how to use com.sk89q.worldedit.regions.Region#getLength() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RegionInfos.java    From WorldEditSelectionVisualizer with MIT License 5 votes vote down vote up
public RegionInfos(RegionAdapter regionAdapter) {
    Region region = regionAdapter.getRegion();

    minimum = regionAdapter.getMinimumPoint();
    maximum = regionAdapter.getMinimumPoint();

    width = region.getWidth();
    length = region.getLength();
    height = region.getHeight();
    area = region.getArea();
    points = region instanceof ConvexPolyhedralRegion ? ((ConvexPolyhedralRegion) region).getTriangles().size() : 0;
}
 
Example 2
Source File: HeightMap.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Deprecated
public HeightMap(EditSession session, Region region, int[] data, boolean layers) {
    this.session = session;
    this.region = region;

    this.width = region.getWidth();
    this.height = region.getLength();

    this.data = data;

    this.layers = layers;
}
 
Example 3
Source File: HeightMap.java    From FastAsyncWorldedit with GNU General Public License v3.0 4 votes vote down vote up
public HeightMap(EditSession session, Region region, boolean naturalOnly, boolean layers) {
    checkNotNull(session);
    checkNotNull(region);

    this.session = session;
    this.region = region;

    this.width = region.getWidth();
    this.height = region.getLength();

    this.layers = layers;

    int minX = region.getMinimumPoint().getBlockX();
    int minY = region.getMinimumPoint().getBlockY();
    int minZ = region.getMinimumPoint().getBlockZ();
    int maxY = region.getMaximumPoint().getBlockY();

    data = new int[width * height];
    invalid = new boolean[data.length];

    if (layers) {
        Vector min = region.getMinimumPoint();
        Vector max = region.getMaximumPoint();
        int bx = min.getBlockX();
        int bz = min.getBlockZ();
        Iterable<Vector2D> flat = Regions.asFlatRegion(region).asFlatRegion();
        Iterator<Vector2D> iter = new Fast2DIterator(flat, session).iterator();
        int layer = 0;
        MutableBlockVector mutable = new MutableBlockVector();
        while (iter.hasNext()) {
            Vector2D pos = iter.next();
            int x = pos.getBlockX();
            int z = pos.getBlockZ();
            layer = session.getNearestSurfaceLayer(x, z, (layer + 7) >> 3, 0, maxY);
            data[(z - bz) * width + (x - bx)] = layer;
        }
    } else {
        // Store current heightmap data
        int index = 0;
        if (naturalOnly) {
            for (int z = 0; z < height; ++z) {
                for (int x = 0; x < width; ++x, index++) {
                    data[index] = session.getHighestTerrainBlock(x + minX, z + minZ, minY, maxY, naturalOnly);
                }
            }
        } else {
            int yTmp = 255;
            for (int z = 0; z < height; ++z) {
                for (int x = 0; x < width; ++x, index++) {
                    yTmp = session.getNearestSurfaceTerrainBlock(x + minX, z + minZ, yTmp, minY, maxY, Integer.MIN_VALUE, Integer.MAX_VALUE);
                    switch (yTmp) {
                        case Integer.MIN_VALUE:
                            yTmp = minY;
                            invalid[index] = true;
                            break;
                        case Integer.MAX_VALUE:
                            yTmp = maxY;
                            invalid[index] = true;
                            break;
                    }
                    data[index] = yTmp;
                }
            }
        }
    }
}