Search in sources :

Example 1 with FlatRegionVisitor

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);
            }
        }
    });
}
Also used : BiomeReplace(com.sk89q.worldedit.function.biome.BiomeReplace) FlatRegionVisitor(com.sk89q.worldedit.function.visitor.FlatRegionVisitor) EditSession(com.sk89q.worldedit.EditSession) FlatRegionFunction(com.sk89q.worldedit.function.FlatRegionFunction) MaxChangedBlocksException(com.sk89q.worldedit.MaxChangedBlocksException)

Example 2 with FlatRegionVisitor

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();
}
Also used : SurfaceRegionFunction(com.fastasyncworldedit.core.function.SurfaceRegionFunction) FlatRegionVisitor(com.sk89q.worldedit.function.visitor.FlatRegionVisitor) RegionOffset(com.sk89q.worldedit.function.util.RegionOffset) BlockReplace(com.sk89q.worldedit.function.block.BlockReplace)

Aggregations

FlatRegionVisitor (com.sk89q.worldedit.function.visitor.FlatRegionVisitor)2 SurfaceRegionFunction (com.fastasyncworldedit.core.function.SurfaceRegionFunction)1 EditSession (com.sk89q.worldedit.EditSession)1 MaxChangedBlocksException (com.sk89q.worldedit.MaxChangedBlocksException)1 FlatRegionFunction (com.sk89q.worldedit.function.FlatRegionFunction)1 BiomeReplace (com.sk89q.worldedit.function.biome.BiomeReplace)1 BlockReplace (com.sk89q.worldedit.function.block.BlockReplace)1 RegionOffset (com.sk89q.worldedit.function.util.RegionOffset)1