Search in sources :

Example 6 with FaweLimit

use of com.fastasyncworldedit.core.limit.FaweLimit in project FastAsyncWorldEdit by IntellectualSites.

the class BrushCommands method snowSmoothBrush.

@Command(name = "snowsmooth", desc = "Choose the snow terrain softener brush", descFooter = "Example: '/brush snowsmooth 5 1 -l 3'")
@CommandPermissions("worldedit.brush.snowsmooth")
public void snowSmoothBrush(Player player, LocalSession session, // FAWE start - Expression > double, default iteration number 1 is much better.
@Arg(desc = "The radius to sample for softening", def = "2") Expression radius, @Arg(desc = "The number of iterations to perform", def = "1") int iterations, // FAWE end
@ArgFlag(name = 'l', desc = "The number of snow blocks under snow", def = "1") int snowBlockCount, @ArgFlag(name = 'm', desc = "The mask of blocks to use for the heightmap") Mask mask, InjectedValueAccess context) throws WorldEditException {
    worldEdit.checkMaxBrushRadius(radius);
    // FAWE start
    FaweLimit limit = Settings.settings().getLimit(player);
    iterations = Math.min(limit.MAX_ITERATIONS, iterations);
    // FAWE end
    set(context, new SnowSmoothBrush(iterations, mask), "worldedit.brush.snowsmooth").setSize(radius);
    player.print(Caption.of("worldedit.brush.smooth.equip", radius, iterations, Caption.of("worldedit.brush.smooth." + (mask == null ? "no" : "") + "filter")));
}
Also used : FaweLimit(com.fastasyncworldedit.core.limit.FaweLimit) SnowSmoothBrush(com.sk89q.worldedit.command.tool.brush.SnowSmoothBrush) ScatterCommand(com.fastasyncworldedit.core.command.tool.brush.ScatterCommand) Command(org.enginehub.piston.annotation.Command) CommandPermissions(com.sk89q.worldedit.command.util.CommandPermissions)

Example 7 with FaweLimit

use of com.fastasyncworldedit.core.limit.FaweLimit in project FastAsyncWorldEdit by IntellectualSites.

the class BrushCommands method smoothBrush.

@Command(name = "smooth", desc = "Choose the terrain softener brush", descFooter = "Example: '/brush smooth 2 4 grass_block,dirt,stone'")
@CommandPermissions("worldedit.brush.smooth")
public void smoothBrush(Player player, LocalSession session, // FAWE start - Expression > double
@Arg(desc = "The radius to sample for softening", def = "2") Expression radius, // FAWE end
@Arg(desc = "The number of iterations to perform", def = "4") int iterations, @Arg(desc = "The mask of blocks to use for the heightmap", def = "") Mask mask, InjectedValueAccess context) throws WorldEditException {
    worldEdit.checkMaxBrushRadius(radius);
    // FAWE start
    FaweLimit limit = Settings.settings().getLimit(player);
    iterations = Math.min(limit.MAX_ITERATIONS, iterations);
    // FAWE end
    set(context, new SmoothBrush(iterations, mask), "worldedit.brush.smooth").setSize(radius);
    player.print(Caption.of("worldedit.brush.smooth.equip", radius, iterations, Caption.of("worldedit.brush.smooth." + (mask == null ? "no" : "") + "filter")));
}
Also used : SnowSmoothBrush(com.sk89q.worldedit.command.tool.brush.SnowSmoothBrush) SmoothBrush(com.sk89q.worldedit.command.tool.brush.SmoothBrush) FaweLimit(com.fastasyncworldedit.core.limit.FaweLimit) ScatterCommand(com.fastasyncworldedit.core.command.tool.brush.ScatterCommand) Command(org.enginehub.piston.annotation.Command) CommandPermissions(com.sk89q.worldedit.command.util.CommandPermissions)

Example 8 with FaweLimit

use of com.fastasyncworldedit.core.limit.FaweLimit in project FastAsyncWorldEdit by IntellectualSites.

the class ClipboardCommands method cut.

/*
    @Command(
        name = "/lazycut",
        desc = "Lazily cut the selection to the clipboard"
    )
    @CommandPermissions("worldedit.clipboard.lazycut")
    public void lazyCut(Actor actor, LocalSession session, EditSession editSession,
                        @Selection final Region region,
                        @Switch(name = 'e', desc = "Skip copy entities")
                            boolean skipEntities,
                        @ArgFlag(name = 'm', desc = "Set the exclude mask, matching blocks become air", def = "")
                            Mask maskOpt,
                        @Switch(name = 'b', desc = "Also copy biomes")
                            boolean copyBiomes) throws WorldEditException {
        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;
        }
        if (volume >= limit.MAX_CHANGES) {
            throw FaweCache.MAX_CHANGES;
        }
        session.setClipboard(null);

        ReadOnlyClipboard lazyClipboard = new WorldCutClipboard(editSession, region, !skipEntities, copyBiomes);
        clipboard.setOrigin(session.getPlacementPosition(actor));
        session.setClipboard(new ClipboardHolder(lazyClipboard));
        actor.print(Caption.of("fawe.worldedit.cut.command.cut.lazy", region.getArea()));
    }*/
// FAWE end
@Command(name = "/cut", desc = "Cut the selection to the clipboard", descFooter = "WARNING: Cutting and pasting entities cannot be undone!")
@CommandPermissions("worldedit.clipboard.cut")
@Logging(REGION)
@Preload(Preload.PreloadCheck.PRELOAD)
@Confirm(Confirm.Processor.REGION)
public void cut(Actor actor, LocalSession session, EditSession editSession, @Selection Region region, @Arg(desc = "Pattern to leave in place of the selection", def = "air") Pattern leavePattern, @Switch(name = 'e', desc = "Also cut entities") boolean copyEntities, @Switch(name = 'b', desc = "Also copy biomes, source biomes are unaffected") boolean copyBiomes, @ArgFlag(name = 'm', desc = "Set the exclude mask, non-matching blocks become air") Mask mask) throws WorldEditException {
    // FAWE start - Inject limits & respect source mask
    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;
    }
    if (volume >= limit.MAX_CHANGES) {
        throw FaweCache.MAX_CHANGES;
    }
    session.setClipboard(null);
    BlockArrayClipboard clipboard = new BlockArrayClipboard(region, actor.getUniqueId());
    clipboard.setOrigin(session.getPlacementPosition(actor));
    ForwardExtentCopy copy = new ForwardExtentCopy(editSession, region, clipboard, region.getMinimumPoint());
    copy.setSourceFunction(new BlockReplace(editSession, leavePattern));
    copy.setCopyingEntities(copyEntities);
    copy.setRemovingEntities(true);
    copy.setCopyingBiomes(copyBiomes);
    Mask sourceMask = editSession.getSourceMask();
    Region[] regions = editSession.getAllowedRegions();
    Region allowedRegion;
    if (regions == null || regions.length == 0) {
        allowedRegion = new NullRegion();
    } else {
        allowedRegion = new RegionIntersection(regions);
    }
    final Mask firstSourceMask = mask != null ? mask : sourceMask;
    final Mask finalMask = MaskIntersection.of(firstSourceMask, new RegionMask(allowedRegion)).optimize();
    if (finalMask != Masks.alwaysTrue()) {
        copy.setSourceMask(finalMask);
    }
    if (sourceMask != null) {
        editSession.setSourceMask(null);
        new MaskTraverser(sourceMask).reset(editSession);
        editSession.setSourceMask(null);
    }
    try {
        Operations.completeLegacy(copy);
    } catch (Throwable e) {
        throw e;
    } finally {
        clipboard.flush();
    }
    session.setClipboard(new ClipboardHolder(clipboard));
    if (!actor.hasPermission("fawe.tips")) {
        actor.print(Caption.of("fawe.tips.tip.lazycut"));
    }
    copy.getStatusMessages().forEach(actor::print);
// FAWE end
}
Also used : BlockArrayClipboard(com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard) MultiClipboardHolder(com.fastasyncworldedit.core.extent.clipboard.MultiClipboardHolder) URIClipboardHolder(com.fastasyncworldedit.core.extent.clipboard.URIClipboardHolder) ClipboardHolder(com.sk89q.worldedit.session.ClipboardHolder) RegionMask(com.sk89q.worldedit.function.mask.RegionMask) ClipboardMask(com.sk89q.worldedit.internal.annotation.ClipboardMask) Mask(com.sk89q.worldedit.function.mask.Mask) RegionMask(com.sk89q.worldedit.function.mask.RegionMask) MaskTraverser(com.fastasyncworldedit.core.util.MaskTraverser) BlockVector3(com.sk89q.worldedit.math.BlockVector3) BlockReplace(com.sk89q.worldedit.function.block.BlockReplace) ForwardExtentCopy(com.sk89q.worldedit.function.operation.ForwardExtentCopy) NullRegion(com.sk89q.worldedit.regions.NullRegion) RegionIntersection(com.sk89q.worldedit.regions.RegionIntersection) FaweLimit(com.fastasyncworldedit.core.limit.FaweLimit) NullRegion(com.sk89q.worldedit.regions.NullRegion) Region(com.sk89q.worldedit.regions.Region) 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 9 with FaweLimit

use of com.fastasyncworldedit.core.limit.FaweLimit in project FastAsyncWorldEdit by IntellectualSites.

the class ClipboardCommands method lazyCopy.

// FAWE start
@Command(name = "/lazycopy", desc = "Lazily copy the selection to the clipboard")
@CommandPermissions("worldedit.clipboard.lazycopy")
public void lazyCopy(Actor actor, LocalSession session, EditSession editSession, @Selection Region region, @Switch(name = 'e', desc = "Skip copy entities") boolean skipEntities, @Switch(name = 'b', desc = "Also copy biomes") boolean copyBiomes) throws WorldEditException {
    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;
    }
    session.setClipboard(null);
    ReadOnlyClipboard lazyClipboard = ReadOnlyClipboard.of(region, !skipEntities, copyBiomes);
    lazyClipboard.setOrigin(session.getPlacementPosition(actor));
    session.setClipboard(new ClipboardHolder(lazyClipboard));
    actor.print(Caption.of("fawe.worldedit.copy.command.copy", region.getVolume()));
}
Also used : FaweLimit(com.fastasyncworldedit.core.limit.FaweLimit) MultiClipboardHolder(com.fastasyncworldedit.core.extent.clipboard.MultiClipboardHolder) URIClipboardHolder(com.fastasyncworldedit.core.extent.clipboard.URIClipboardHolder) ClipboardHolder(com.sk89q.worldedit.session.ClipboardHolder) ReadOnlyClipboard(com.fastasyncworldedit.core.extent.clipboard.ReadOnlyClipboard) BlockVector3(com.sk89q.worldedit.math.BlockVector3) Command(org.enginehub.piston.annotation.Command) CommandPermissions(com.sk89q.worldedit.command.util.CommandPermissions)

Example 10 with FaweLimit

use of com.fastasyncworldedit.core.limit.FaweLimit 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

FaweLimit (com.fastasyncworldedit.core.limit.FaweLimit)11 CommandPermissions (com.sk89q.worldedit.command.util.CommandPermissions)6 Command (org.enginehub.piston.annotation.Command)6 BlockVector3 (com.sk89q.worldedit.math.BlockVector3)5 MultiClipboardHolder (com.fastasyncworldedit.core.extent.clipboard.MultiClipboardHolder)3 URIClipboardHolder (com.fastasyncworldedit.core.extent.clipboard.URIClipboardHolder)3 MaskTraverser (com.fastasyncworldedit.core.util.MaskTraverser)3 Confirm (com.sk89q.worldedit.command.util.annotation.Confirm)3 Preload (com.sk89q.worldedit.command.util.annotation.Preload)3 ScatterCommand (com.fastasyncworldedit.core.command.tool.brush.ScatterCommand)2 ReadOnlyClipboard (com.fastasyncworldedit.core.extent.clipboard.ReadOnlyClipboard)2 SnowSmoothBrush (com.sk89q.worldedit.command.tool.brush.SnowSmoothBrush)2 Logging (com.sk89q.worldedit.command.util.Logging)2 Player (com.sk89q.worldedit.entity.Player)2 Actor (com.sk89q.worldedit.extension.platform.Actor)2 BlockArrayClipboard (com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard)2 Mask (com.sk89q.worldedit.function.mask.Mask)2 RegionMask (com.sk89q.worldedit.function.mask.RegionMask)2 ForwardExtentCopy (com.sk89q.worldedit.function.operation.ForwardExtentCopy)2 ClipboardMask (com.sk89q.worldedit.internal.annotation.ClipboardMask)2