protected SpoutColumn getColumn(int x, int z, LoadOption loadopt, boolean sync) { long key = IntPairHashed.key(x, z); SpoutColumn column = columns.get(key); if (column != null || !loadopt.loadIfNeeded()) { return column; } column = loadColumn(x, z); if (column != null || !loadopt.generateIfNeeded()) { return column; } int[][] height = this.getGenerator().getSurfaceHeight(this, x, z); int h = (height[7][7] >> Chunk.BLOCKS.BITS); SpoutRegion r = getRegionFromChunk(x, h, z, loadopt); if (r == null) { throw new IllegalStateException( "Unable to generate region for new column and load option " + loadopt); } r.getRegionGenerator().generateColumn(x, z, sync, true); column = getColumn(x, z, LoadOption.LOAD_ONLY); if (column == null) { throw new IllegalStateException("Unable to generate column " + x + ", " + z); } return column; }
/** * Removes a column corresponding to the given Column coordinates * * @param x the x coordinate * @param z the z coordinate */ public void removeColumn(int x, int z, SpoutColumn column) { long key = IntPairHashed.key(x, z); if (columns.remove(key, column)) { synchronized (columnSet) { columnSet.remove(column); } } }
public SpoutColumn setColumn(int x, int z, SpoutColumn col) { long key = IntPairHashed.key(x, z); SpoutColumn old = columns.putIfAbsent(key, col); if (old != null) { return old; } synchronized (columnSet) { columnSet.add(col); } return col; }
public SpoutColumn[] getColumns() { return columns.values(new SpoutColumn[0]); }