Search in sources :

Example 1 with MaskTraverser

use of com.fastasyncworldedit.core.util.MaskTraverser in project FastAsyncWorldEdit by IntellectualSites.

the class GenerationCommands method ore.

@Command(name = "/ore", desc = "Generates ores")
@CommandPermissions("worldedit.generation.ore")
@Logging(PLACEMENT)
@Preload(Preload.PreloadCheck.PRELOAD)
@Confirm(Confirm.Processor.REGION)
public void ore(Actor actor, LocalSession session, EditSession editSession, @Selection Region region, @Arg(desc = "Mask") Mask mask, @Arg(desc = "Pattern") Pattern material, @Arg(desc = "Ore vein size") @Range(from = 0, to = Integer.MAX_VALUE) int size, @Arg(desc = "Ore vein frequency (number of times to attempt to place ore)", def = "10") @Range(from = 0, to = Integer.MAX_VALUE) int freq, @Arg(desc = "Ore vein rarity (% chance each attempt is placed)", def = "100") @Range(from = 0, to = 100) int rarity, @Arg(desc = "Ore vein min y", def = "0") int minY, @Arg(desc = "Ore vein max y", def = "63") int maxY) throws WorldEditException {
    new MaskTraverser(mask).setNewExtent(editSession);
    checkCommandArgument(minY >= editSession.getMinY(), Caption.of("fawe.error.outside-range-lower", "miny", editSession.getMinY()));
    checkCommandArgument(maxY <= editSession.getMaxY(), Caption.of("fawe.error.outside-range-upper", "maxy", editSession.getMaxY()));
    checkCommandArgument(minY < maxY, Caption.of("fawe.error.argument-size-mismatch", "miny", "maxy"));
    editSession.addOre(region, mask, material, size, freq, rarity, minY, maxY);
    actor.print(Caption.of("fawe.worldedit.visitor.visitor.block", editSession.getBlockChangeCount()));
}
Also used : MaskTraverser(com.fastasyncworldedit.core.util.MaskTraverser) 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 2 with MaskTraverser

use of com.fastasyncworldedit.core.util.MaskTraverser in project FastAsyncWorldEdit by IntellectualSites.

the class GenerationCommands method ores.

@Command(name = "/ores", desc = "Generates ores")
@CommandPermissions("worldedit.generation.ore")
@Logging(PLACEMENT)
@Preload(Preload.PreloadCheck.PRELOAD)
@Confirm(Confirm.Processor.REGION)
public void ores(Actor actor, LocalSession session, EditSession editSession, @Selection Region region, @Arg(desc = "Mask") Mask mask) throws WorldEditException {
    new MaskTraverser(mask).setNewExtent(editSession);
    editSession.addOres(region, mask);
    actor.print(Caption.of("fawe.worldedit.visitor.visitor.block", editSession.getBlockChangeCount()));
}
Also used : MaskTraverser(com.fastasyncworldedit.core.util.MaskTraverser) 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 3 with MaskTraverser

use of com.fastasyncworldedit.core.util.MaskTraverser in project FastAsyncWorldEdit by IntellectualSites.

the class UtilityCommands method replaceNear.

@Command(name = "replacenear", aliases = { "/replacenear" }, desc = "Replace nearby blocks")
@CommandPermissions("worldedit.replacenear")
@Logging(PLACEMENT)
public int replaceNear(Actor actor, World world, LocalSession session, EditSession editSession, @Arg(desc = "The radius of the square to remove in") int radius, @Arg(desc = "The mask matching blocks to remove", def = "") Mask from, @Arg(desc = "The pattern of blocks to replace with") Pattern to) throws WorldEditException {
    // FAWE start > the mask will have been initialised with a WorldWrapper extent (very bad/slow)
    new MaskTraverser(from).setNewExtent(editSession);
    // FAWE end
    radius = Math.max(1, radius);
    we.checkMaxRadius(radius);
    BlockVector3 base = session.getPlacementPosition(actor);
    BlockVector3 min = base.subtract(radius, radius, radius);
    BlockVector3 max = base.add(radius, radius, radius);
    Region region = new CuboidRegion(world, min, max);
    if (from == null) {
        from = new ExistingBlockMask(editSession);
    }
    int affected = editSession.replaceBlocks(region, from, to);
    actor.print(Caption.of("worldedit.replacenear.replaced", TextComponent.of(affected)));
    return affected;
}
Also used : CuboidRegion(com.sk89q.worldedit.regions.CuboidRegion) CylinderRegion(com.sk89q.worldedit.regions.CylinderRegion) Region(com.sk89q.worldedit.regions.Region) MaskTraverser(com.fastasyncworldedit.core.util.MaskTraverser) CuboidRegion(com.sk89q.worldedit.regions.CuboidRegion) ExistingBlockMask(com.sk89q.worldedit.function.mask.ExistingBlockMask) BlockVector3(com.sk89q.worldedit.math.BlockVector3) Logging(com.sk89q.worldedit.command.util.Logging) Command(org.enginehub.piston.annotation.Command) CommandPermissions(com.sk89q.worldedit.command.util.CommandPermissions)

Example 4 with MaskTraverser

use of com.fastasyncworldedit.core.util.MaskTraverser in project FastAsyncWorldEdit by IntellectualSites.

the class RegionCommands method replace.

@Command(name = "/replace", aliases = { "/re", "/rep" }, desc = "Replace all blocks in the selection with another")
@CommandPermissions("worldedit.region.replace")
@Logging(REGION)
@Preload(Preload.PreloadCheck.PRELOAD)
@Confirm(Confirm.Processor.REGION)
public int replace(Actor actor, EditSession editSession, @Selection Region region, @Arg(desc = "The mask representing blocks to replace", def = "") Mask from, @Arg(desc = "The pattern of blocks to replace with") Pattern to) throws WorldEditException {
    if (from == null) {
        from = new ExistingBlockMask(editSession);
    // FAWE start > the mask will have been initialised with a WorldWrapper extent (very bad/slow
    } else {
        new MaskTraverser(from).setNewExtent(editSession);
    }
    int affected = editSession.replaceBlocks(region, from, to);
    actor.print(Caption.of("worldedit.replace.replaced", TextComponent.of(affected)));
    return affected;
}
Also used : MaskTraverser(com.fastasyncworldedit.core.util.MaskTraverser) ExistingBlockMask(com.sk89q.worldedit.function.mask.ExistingBlockMask) 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 5 with MaskTraverser

use of com.fastasyncworldedit.core.util.MaskTraverser in project FastAsyncWorldEdit by IntellectualSites.

the class RegionCommands method stack.

@Command(name = "/stack", desc = "Repeat the contents of the selection")
@CommandPermissions("worldedit.region.stack")
@Preload(Preload.PreloadCheck.PRELOAD)
@Logging(ORIENTATION_REGION)
public int stack(Actor actor, World world, EditSession editSession, LocalSession session, @Selection Region region, @Arg(desc = "# of copies to stack", def = "1") @Confirm(Confirm.Processor.REGION) int count, @Arg(desc = "The direction to stack", def = Direction.AIM) @Direction(includeDiagonals = true) BlockVector3 direction, @Switch(name = 's', desc = "Shift the selection to the last stacked copy") boolean moveSelection, @Switch(name = 'a', desc = "Ignore air blocks") boolean ignoreAirBlocks, @Switch(name = 'e', desc = "Also copy entities") boolean copyEntities, @Switch(name = 'b', desc = "Also copy biomes") boolean copyBiomes, @ArgFlag(name = 'm', desc = "Set the include mask, non-matching blocks become air") 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
    Mask combinedMask;
    if (ignoreAirBlocks) {
        if (mask == null) {
            combinedMask = new ExistingBlockMask(editSession);
        } else {
            combinedMask = new MaskIntersection(mask, new ExistingBlockMask(editSession));
        }
    } else {
        combinedMask = mask;
    }
    int affected = editSession.stackCuboidRegion(region, direction, count, copyEntities, copyBiomes, combinedMask);
    if (moveSelection) {
        try {
            final BlockVector3 size = region.getMaximumPoint().subtract(region.getMinimumPoint()).add(1, 1, 1);
            final BlockVector3 shiftVector = direction.multiply(size).multiply(count);
            region.shift(shiftVector);
            session.getRegionSelector(world).learnChanges();
            session.getRegionSelector(world).explainRegionAdjust(actor, session);
        } catch (RegionOperationException e) {
            actor.printError(TextComponent.of(e.getMessage()));
        }
    }
    actor.print(Caption.of("worldedit.stack.changed", TextComponent.of(affected)));
    return affected;
}
Also used : MaskIntersection(com.sk89q.worldedit.function.mask.MaskIntersection) SolidBlockMask(com.sk89q.worldedit.function.mask.SolidBlockMask) ExistingBlockMask(com.sk89q.worldedit.function.mask.ExistingBlockMask) Mask(com.sk89q.worldedit.function.mask.Mask) RegionOperationException(com.sk89q.worldedit.regions.RegionOperationException) MaskTraverser(com.fastasyncworldedit.core.util.MaskTraverser) ExistingBlockMask(com.sk89q.worldedit.function.mask.ExistingBlockMask) BlockVector3(com.sk89q.worldedit.math.BlockVector3) Logging(com.sk89q.worldedit.command.util.Logging) Preload(com.sk89q.worldedit.command.util.annotation.Preload) Command(org.enginehub.piston.annotation.Command) CommandPermissions(com.sk89q.worldedit.command.util.CommandPermissions)

Aggregations

MaskTraverser (com.fastasyncworldedit.core.util.MaskTraverser)20 CommandPermissions (com.sk89q.worldedit.command.util.CommandPermissions)12 Command (org.enginehub.piston.annotation.Command)12 Logging (com.sk89q.worldedit.command.util.Logging)10 Preload (com.sk89q.worldedit.command.util.annotation.Preload)9 Mask (com.sk89q.worldedit.function.mask.Mask)9 Confirm (com.sk89q.worldedit.command.util.annotation.Confirm)8 ExistingBlockMask (com.sk89q.worldedit.function.mask.ExistingBlockMask)8 BlockVector3 (com.sk89q.worldedit.math.BlockVector3)6 RegionMask (com.sk89q.worldedit.function.mask.RegionMask)4 SolidBlockMask (com.sk89q.worldedit.function.mask.SolidBlockMask)4 FaweLimit (com.fastasyncworldedit.core.limit.FaweLimit)3 ForwardExtentCopy (com.sk89q.worldedit.function.operation.ForwardExtentCopy)3 Region (com.sk89q.worldedit.regions.Region)3 MultiClipboardHolder (com.fastasyncworldedit.core.extent.clipboard.MultiClipboardHolder)2 URIClipboardHolder (com.fastasyncworldedit.core.extent.clipboard.URIClipboardHolder)2 ResettableMask (com.fastasyncworldedit.core.function.mask.ResettableMask)2 SingleBlockTypeMask (com.fastasyncworldedit.core.function.mask.SingleBlockTypeMask)2 WallMakeMask (com.fastasyncworldedit.core.function.mask.WallMakeMask)2 ExtentTraverser (com.fastasyncworldedit.core.util.ExtentTraverser)2