Search in sources :

Example 1 with FlatRegionFunction

use of com.sk89q.worldedit.function.FlatRegionFunction 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)

Aggregations

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 FlatRegionVisitor (com.sk89q.worldedit.function.visitor.FlatRegionVisitor)1