private void place(EditSession editSession, int facing, Vector pos, boolean noAir, int x1, int x2, int y1, int y2, int z1, int z2) throws MaxChangedBlocksException { x1 = Math.max(x1, 0); x2 = Math.min(x2, sizeX); y1 = Math.max(y1, 0); y2 = Math.min(y2, sizeY); z1 = Math.max(z1, 0); z2 = Math.min(z2, sizeZ); for (int x = x1; x < x2; x++) for (int y = y1; y < y2; y++) for (int z = z1; z < z2; z++) { BaseBlock block = blocks[facing][x][y][z]; if (block != null) { if ((noAir) && (block.isAir())) { continue; } editSession.setBlock(new Vector(x, y, z).add(pos), block); } } } }
private void place(EditSession editSession, int facing, Vector pos, boolean noAir) throws MaxChangedBlocksException { for (int x = 0; x < sizeX; x++) for (int y = 0; y < sizeY; y++) for (int z = 0; z < sizeZ; z++) { BaseBlock block = blocks[facing][x][y][z]; if (block != null) { if ((noAir) && (block.isAir())) { continue; } editSession.setBlock(new Vector(x, y, z).add(pos), block); } } }
@Override public void clear() { try { CuboidRegion region = new CuboidRegion(origin, origin.add(size.getX() - 1, size.getY() - 1, size.getZ() - 1)); EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(SpongeWorldEdit.inst().getWorld(world), -1); editSession.enableQueue(); editSession.setBlocks(region, new BaseBlock(0)); editSession.flushQueue(); } catch (MaxChangedBlocksException e) { // is never thrown } }
Vector size = max.subtract(min).add(1, 1, 1);