use of com.sk89q.worldedit.function.visitor.FlatRegionVisitor in project FastAsyncWorldEdit by IntellectualSites.
the class FaweDelegateRegionManager method setBiome.
public void setBiome(CuboidRegion region, int extendBiome, BiomeType biome, String world, Runnable whenDone) {
region.expand(BlockVector3.at(extendBiome, 0, extendBiome));
region.expand(BlockVector3.at(-extendBiome, 0, -extendBiome));
TaskManager.taskManager().async(() -> {
synchronized (FaweDelegateRegionManager.class) {
EditSession editSession = WorldEdit.getInstance().newEditSessionBuilder().world(BukkitAdapter.adapt(getWorld(world))).checkMemory(false).fastMode(true).limitUnlimited().changeSetNull().build();
FlatRegionFunction replace = new BiomeReplace(editSession, biome);
FlatRegionVisitor visitor = new FlatRegionVisitor(region, replace, editSession);
try {
Operations.completeLegacy(visitor);
editSession.flushQueue();
} catch (MaxChangedBlocksException e) {
e.printStackTrace();
}
if (whenDone != null) {
TaskManager.taskManager().task(whenDone);
}
}
});
}
use of com.sk89q.worldedit.function.visitor.FlatRegionVisitor in project FastAsyncWorldEdit by IntellectualSites.
the class EditSession method overlayCuboidBlocks.
/**
* Places a layer of blocks on top of ground blocks in the given region
* (as if it were a cuboid).
*
* @param region the region
* @param pattern the placed block pattern
* @return number of blocks affected
* @throws MaxChangedBlocksException thrown if too many blocks are changed
*/
public int overlayCuboidBlocks(Region region, Pattern pattern) throws MaxChangedBlocksException {
checkNotNull(region);
checkNotNull(pattern);
BlockReplace replace = new BlockReplace(this, pattern);
RegionOffset offset = new RegionOffset(BlockVector3.UNIT_Y, replace);
// FAWE start
int minY = region.getMinimumPoint().getBlockY();
int maxY = Math.min(getMaximumPoint().getBlockY(), region.getMaximumPoint().getBlockY() + 1);
SurfaceRegionFunction surface = new SurfaceRegionFunction(this, offset, minY, maxY);
FlatRegionVisitor visitor = new FlatRegionVisitor(asFlatRegion(region), surface, this);
// FAWE end
Operations.completeBlindly(visitor);
return this.changes = visitor.getAffected();
}
Aggregations