Search in sources :

Example 1 with BiomeReplace

use of com.sk89q.worldedit.function.biome.BiomeReplace 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 BiomeReplace

use of com.sk89q.worldedit.function.biome.BiomeReplace in project FastAsyncWorldEdit by IntellectualSites.

the class BiomeCommands method setBiome.

@Command(name = "/setbiome", desc = "Sets the biome of your current block or region.", descFooter = "By default, uses all the blocks in your selection")
@Logging(REGION)
@Preload(Preload.PreloadCheck.PRELOAD)
@Confirm(Confirm.Processor.REGION)
@CommandPermissions("worldedit.biome.set")
public void setBiome(Actor actor, World world, LocalSession session, EditSession editSession, @Arg(desc = "Biome type.") BiomeType target, @Switch(name = 'p', desc = "Use your current position") boolean atPosition) throws WorldEditException {
    Region region;
    Mask mask = editSession.getMask();
    if (atPosition) {
        if (actor instanceof Locatable) {
            final BlockVector3 pos = ((Locatable) actor).getLocation().toVector().toBlockPoint();
            region = new CuboidRegion(pos, pos);
        } else {
            actor.print(Caption.of("worldedit.setbiome.not-locatable"));
            return;
        }
    } else {
        region = session.getSelection(world);
    }
    RegionFunction replace = new BiomeReplace(editSession, target);
    if (mask != null) {
        replace = new RegionMaskingFilter(editSession, mask, replace);
    }
    RegionVisitor visitor = new RegionVisitor(region, replace);
    Operations.completeLegacy(visitor);
    actor.print(Caption.of("worldedit.setbiome.changed", TextComponent.of(visitor.getAffected() / (editSession.getMaxY() - editSession.getMinY()))));
}
Also used : RegionFunction(com.sk89q.worldedit.function.RegionFunction) RegionVisitor(com.sk89q.worldedit.function.visitor.RegionVisitor) BiomeReplace(com.sk89q.worldedit.function.biome.BiomeReplace) Mask(com.sk89q.worldedit.function.mask.Mask) CuboidRegion(com.sk89q.worldedit.regions.CuboidRegion) Region(com.sk89q.worldedit.regions.Region) CuboidRegion(com.sk89q.worldedit.regions.CuboidRegion) BlockVector3(com.sk89q.worldedit.math.BlockVector3) RegionMaskingFilter(com.sk89q.worldedit.function.RegionMaskingFilter) Locatable(com.sk89q.worldedit.extension.platform.Locatable) Logging(com.sk89q.worldedit.command.util.Logging) Preload(com.sk89q.worldedit.command.util.annotation.Preload) Command(org.enginehub.piston.annotation.Command) Confirm(com.sk89q.worldedit.command.util.annotation.Confirm) CommandPermissions(com.sk89q.worldedit.command.util.CommandPermissions)

Aggregations

BiomeReplace (com.sk89q.worldedit.function.biome.BiomeReplace)2 EditSession (com.sk89q.worldedit.EditSession)1 MaxChangedBlocksException (com.sk89q.worldedit.MaxChangedBlocksException)1 CommandPermissions (com.sk89q.worldedit.command.util.CommandPermissions)1 Logging (com.sk89q.worldedit.command.util.Logging)1 Confirm (com.sk89q.worldedit.command.util.annotation.Confirm)1 Preload (com.sk89q.worldedit.command.util.annotation.Preload)1 Locatable (com.sk89q.worldedit.extension.platform.Locatable)1 FlatRegionFunction (com.sk89q.worldedit.function.FlatRegionFunction)1 RegionFunction (com.sk89q.worldedit.function.RegionFunction)1 RegionMaskingFilter (com.sk89q.worldedit.function.RegionMaskingFilter)1 Mask (com.sk89q.worldedit.function.mask.Mask)1 FlatRegionVisitor (com.sk89q.worldedit.function.visitor.FlatRegionVisitor)1 RegionVisitor (com.sk89q.worldedit.function.visitor.RegionVisitor)1 BlockVector3 (com.sk89q.worldedit.math.BlockVector3)1 CuboidRegion (com.sk89q.worldedit.regions.CuboidRegion)1 Region (com.sk89q.worldedit.regions.Region)1 Command (org.enginehub.piston.annotation.Command)1