Search in sources :

Example 16 with Confirm

use of com.sk89q.worldedit.command.util.annotation.Confirm in project FastAsyncWorldEdit by IntellectualSites.

the class RegionCommands method lay.

@Command(name = "/lay", desc = "Set the top block in the region")
@CommandPermissions("worldedit.region.overlay")
@Logging(REGION)
@Preload(Preload.PreloadCheck.PRELOAD)
@Confirm(Confirm.Processor.REGION)
public void lay(Actor actor, EditSession editSession, @Selection Region region, @Arg(name = "pattern", desc = "The pattern of blocks to lay") Pattern patternArg) throws WorldEditException {
    // FAWE start - world min/maxY
    int maxY = region.getMaximumY();
    int minY = region.getMinimumY();
    // FAWE end
    Iterable<BlockVector2> flat = Regions.asFlatRegion(region).asFlatRegion();
    Iterator<BlockVector2> iter = flat.iterator();
    // FAWE start - world min/maxY
    int y = minY;
    // FAWE end
    int affected = 0;
    while (iter.hasNext()) {
        BlockVector2 pos = iter.next();
        int x = pos.getBlockX();
        int z = pos.getBlockZ();
        // FAWE start - world min/maxY
        y = editSession.getNearestSurfaceTerrainBlock(x, z, y, minY, maxY);
        // FAWE end
        editSession.setBlock(x, y, z, patternArg);
        affected++;
    }
    actor.print(Caption.of("fawe.worldedit.visitor.visitor.block", affected));
}
Also used : BlockVector2(com.sk89q.worldedit.math.BlockVector2) 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)

Example 17 with Confirm

use of com.sk89q.worldedit.command.util.annotation.Confirm in project FastAsyncWorldEdit by IntellectualSites.

the class RegionCommands method flora.

@Command(name = "/flora", desc = "Make flora within the region")
@CommandPermissions("worldedit.region.flora")
@Logging(REGION)
@Preload(Preload.PreloadCheck.PRELOAD)
@Confirm(Confirm.Processor.REGION)
public int flora(Actor actor, EditSession editSession, @Selection Region region, @Arg(desc = "The density of the forest", def = "5") double density) throws WorldEditException {
    checkCommandArgument(0 <= density && density <= 100, "Density must be in [0, 100]");
    density = density / 100;
    FloraGenerator generator = new FloraGenerator(editSession);
    GroundFunction ground = new GroundFunction(new ExistingBlockMask(editSession), generator);
    // FAWE start - provide extent for preloading
    LayerVisitor visitor = new LayerVisitor(asFlatRegion(region), minimumBlockY(region), maximumBlockY(region), ground);
    // FAWE end
    visitor.setMask(new NoiseFilter2D(new RandomNoise(), density));
    Operations.completeLegacy(visitor);
    int affected = ground.getAffected();
    actor.print(Caption.of("worldedit.flora.created", TextComponent.of(affected)));
    return affected;
}
Also used : FloraGenerator(com.sk89q.worldedit.function.generator.FloraGenerator) RandomNoise(com.sk89q.worldedit.math.noise.RandomNoise) GroundFunction(com.sk89q.worldedit.function.GroundFunction) LayerVisitor(com.sk89q.worldedit.function.visitor.LayerVisitor) ExistingBlockMask(com.sk89q.worldedit.function.mask.ExistingBlockMask) NoiseFilter2D(com.sk89q.worldedit.function.mask.NoiseFilter2D) 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)

Example 18 with Confirm

use of com.sk89q.worldedit.command.util.annotation.Confirm in project FastAsyncWorldEdit by IntellectualSites.

the class RegionCommands method snowSmooth.

@Command(name = "/snowsmooth", desc = "Smooth the elevation in the selection with snow layers", descFooter = "Example: '//snowsmooth 1 -m snow_block,snow' would only smooth snow terrain.")
@CommandPermissions("worldedit.region.snowsmooth")
@Logging(REGION)
@Preload(Preload.PreloadCheck.PRELOAD)
@Confirm(Confirm.Processor.REGION)
public int snowSmooth(Actor actor, EditSession editSession, @Selection Region region, @Arg(desc = "# of iterations to perform", def = "1") int iterations, @ArgFlag(name = 'l', desc = "Set the amount of snow blocks under the snow", def = "1") int snowBlockCount, @ArgFlag(name = 'm', desc = "The mask of blocks to use as the height map") Mask mask) throws WorldEditException {
    SnowHeightMap heightMap = new SnowHeightMap(editSession, region, mask);
    HeightMapFilter filter = new HeightMapFilter(new GaussianKernel(5, 1.0));
    float[] changed = heightMap.applyFilter(filter, iterations);
    int affected = heightMap.applyChanges(changed, snowBlockCount);
    actor.print(Caption.of("worldedit.snowsmooth.changed", TextComponent.of(affected)));
    return affected;
}
Also used : HeightMapFilter(com.sk89q.worldedit.math.convolution.HeightMapFilter) SnowHeightMap(com.sk89q.worldedit.math.convolution.SnowHeightMap) GaussianKernel(com.sk89q.worldedit.math.convolution.GaussianKernel) 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)

Example 19 with Confirm

use of com.sk89q.worldedit.command.util.annotation.Confirm in project FastAsyncWorldEdit by IntellectualSites.

the class RegionCommands method regenerate.

@Command(name = "/regen", desc = "Regenerates the contents of the selection", descFooter = "This command might affect things outside the selection,\n" + "if they are within the same chunk.")
@CommandPermissions("worldedit.regen")
@Logging(REGION)
@Confirm(Confirm.Processor.REGION)
void regenerate(Actor actor, World world, LocalSession session, EditSession editSession, @Selection Region region, @Arg(desc = "The seed to regenerate with, otherwise uses world seed", def = "") Long seed, @Switch(name = 'b', desc = "Regenerate biomes as well") boolean regenBiomes, @Arg(desc = "Biome to apply for this regeneration (only works in overworld)", def = "") BiomeType biomeType) throws WorldEditException {
    Mask mask = session.getMask();
    boolean success;
    try {
        session.setMask(null);
        // FAWE start
        session.setSourceMask(null);
        actor.print(Caption.of("fawe.regen.time"));
        // FAWE end
        RegenOptions options = RegenOptions.builder().seed(seed).regenBiomes(regenBiomes).biomeType(biomeType).build();
        success = world.regenerate(region, editSession, options);
    } finally {
        session.setMask(mask);
        // FAWE start
        session.setSourceMask(mask);
    // FAWE end
    }
    if (success) {
        actor.print(Caption.of("worldedit.regen.regenerated"));
    } else {
        actor.print(Caption.of("worldedit.regen.failed"));
    }
}
Also used : SolidBlockMask(com.sk89q.worldedit.function.mask.SolidBlockMask) ExistingBlockMask(com.sk89q.worldedit.function.mask.ExistingBlockMask) Mask(com.sk89q.worldedit.function.mask.Mask) RegenOptions(com.sk89q.worldedit.world.RegenOptions) Logging(com.sk89q.worldedit.command.util.Logging) Command(org.enginehub.piston.annotation.Command) Confirm(com.sk89q.worldedit.command.util.annotation.Confirm) CommandPermissions(com.sk89q.worldedit.command.util.CommandPermissions)

Example 20 with Confirm

use of com.sk89q.worldedit.command.util.annotation.Confirm in project FastAsyncWorldEdit by IntellectualSites.

the class RegionCommands method smooth.

@Command(name = "/smooth", desc = "Smooth the elevation in the selection", descFooter = "Example: '//smooth 1 grass_block,dirt,stone' would only smooth natural surface terrain.")
@CommandPermissions("worldedit.region.smooth")
@Logging(REGION)
@Preload(Preload.PreloadCheck.PRELOAD)
@Confirm(Confirm.Processor.REGION)
public int smooth(Actor actor, EditSession editSession, @Selection Region region, @Arg(desc = "# of iterations to perform", def = "1") int iterations, @Arg(desc = "The mask of blocks to use as the height map", def = "") Mask mask) throws WorldEditException {
    // FAWE start > the mask will have been initialised with a WorldWrapper extent (very bad/slow)
    new MaskTraverser(mask).setNewExtent(editSession);
    // FAWE end
    BlockVector3 min = region.getMinimumPoint();
    BlockVector3 max = region.getMaximumPoint();
    long volume = (((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min.getZ() + 1));
    FaweLimit limit = actor.getLimit();
    if (volume >= limit.MAX_CHECKS) {
        throw FaweCache.MAX_CHECKS;
    }
    int affected;
    try {
        HeightMap heightMap = new HeightMap(editSession, region, mask);
        HeightMapFilter filter = new HeightMapFilter(new GaussianKernel(5, 1.0));
        affected = heightMap.applyFilter(filter, iterations);
        actor.print(Caption.of("worldedit.smooth.changed", TextComponent.of(affected)));
    } catch (Throwable e) {
        throw new RuntimeException(e);
    }
    return affected;
}
Also used : HeightMapFilter(com.sk89q.worldedit.math.convolution.HeightMapFilter) HeightMap(com.sk89q.worldedit.math.convolution.HeightMap) SnowHeightMap(com.sk89q.worldedit.math.convolution.SnowHeightMap) FaweLimit(com.fastasyncworldedit.core.limit.FaweLimit) MaskTraverser(com.fastasyncworldedit.core.util.MaskTraverser) BlockVector3(com.sk89q.worldedit.math.BlockVector3) GaussianKernel(com.sk89q.worldedit.math.convolution.GaussianKernel) 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

Confirm (com.sk89q.worldedit.command.util.annotation.Confirm)22 CommandPermissions (com.sk89q.worldedit.command.util.CommandPermissions)20 Command (org.enginehub.piston.annotation.Command)20 Logging (com.sk89q.worldedit.command.util.Logging)17 Preload (com.sk89q.worldedit.command.util.annotation.Preload)15 BlockVector3 (com.sk89q.worldedit.math.BlockVector3)10 MaskTraverser (com.fastasyncworldedit.core.util.MaskTraverser)8 Mask (com.sk89q.worldedit.function.mask.Mask)6 ExistingBlockMask (com.sk89q.worldedit.function.mask.ExistingBlockMask)5 FaweLimit (com.fastasyncworldedit.core.limit.FaweLimit)3 SolidBlockMask (com.sk89q.worldedit.function.mask.SolidBlockMask)3 ExpressionException (com.sk89q.worldedit.internal.expression.ExpressionException)3 Vector3 (com.sk89q.worldedit.math.Vector3)3 Region (com.sk89q.worldedit.regions.Region)3 MultiClipboardHolder (com.fastasyncworldedit.core.extent.clipboard.MultiClipboardHolder)2 URIClipboardHolder (com.fastasyncworldedit.core.extent.clipboard.URIClipboardHolder)2 RollbackOptimizedHistory (com.fastasyncworldedit.core.history.RollbackOptimizedHistory)2 Player (com.sk89q.worldedit.entity.Player)2 BlockArrayClipboard (com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard)2 RegionMask (com.sk89q.worldedit.function.mask.RegionMask)2