Search in sources :

Example 6 with ResettableExtent

use of com.fastasyncworldedit.core.extent.ResettableExtent in project FastAsyncWorldEdit by IntellectualSites.

the class RotateTransformParser method parseFromInput.

@Override
protected ResettableExtent parseFromInput(@Nonnull String[] arguments, ParserContext context) throws InputParseException {
    AffineTransform transform = new AffineTransform();
    Extent extent;
    if (arguments.length == 1) {
        transform = transform.rotateY(Double.parseDouble(arguments[0]));
        extent = context.requireExtent();
    } else if (arguments.length == 3 || arguments.length == 4) {
        transform = transform.rotateX(Double.parseDouble(arguments[0]));
        transform = transform.rotateY(Double.parseDouble(arguments[1]));
        transform = transform.rotateZ(Double.parseDouble(arguments[2]));
        extent = arguments.length == 4 ? worldEdit.getTransformFactory().parseFromInput(arguments[3], context) : context.requireExtent();
    } else {
        return null;
    }
    return new BlockTransformExtent(extent, transform);
}
Also used : BlockTransformExtent(com.sk89q.worldedit.extent.transform.BlockTransformExtent) ResettableExtent(com.fastasyncworldedit.core.extent.ResettableExtent) Extent(com.sk89q.worldedit.extent.Extent) BlockTransformExtent(com.sk89q.worldedit.extent.transform.BlockTransformExtent) AffineTransform(com.sk89q.worldedit.math.transform.AffineTransform)

Example 7 with ResettableExtent

use of com.fastasyncworldedit.core.extent.ResettableExtent in project FastAsyncWorldEdit by IntellectualSites.

the class TransformFactory method parseFromInput.

@Override
public ResettableExtent parseFromInput(String input, ParserContext context) throws InputParseException {
    List<ResettableExtent> transforms = new ArrayList<>();
    for (String component : input.split(" ")) {
        if (component.isEmpty()) {
            continue;
        }
        ResettableExtent match = richTransformParser.parseFromInput(component, context);
        if (match != null) {
            transforms.add(match);
            continue;
        }
        parseFromParsers(context, transforms, component);
    }
    return getResettableExtent(input, transforms);
}
Also used : ArrayList(java.util.ArrayList) ResettableExtent(com.fastasyncworldedit.core.extent.ResettableExtent)

Example 8 with ResettableExtent

use of com.fastasyncworldedit.core.extent.ResettableExtent in project FastAsyncWorldEdit by IntellectualSites.

the class PatternTransformParser method parseFromInput.

@Override
protected ResettableExtent parseFromInput(@Nonnull String[] arguments, ParserContext context) throws InputParseException {
    if (arguments.length > 2) {
        return null;
    }
    Pattern pattern = worldEdit.getPatternFactory().parseFromInput(arguments[0], context);
    Extent extent = arguments.length == 2 ? worldEdit.getTransformFactory().parseFromInput(arguments[1], context) : context.requireExtent();
    return new PatternTransform(extent, pattern);
}
Also used : Pattern(com.sk89q.worldedit.function.pattern.Pattern) ResettableExtent(com.fastasyncworldedit.core.extent.ResettableExtent) Extent(com.sk89q.worldedit.extent.Extent) PatternTransform(com.fastasyncworldedit.core.extent.transform.PatternTransform)

Example 9 with ResettableExtent

use of com.fastasyncworldedit.core.extent.ResettableExtent in project FastAsyncWorldEdit by IntellectualSites.

the class RandomTransformParser method parseFromInput.

@Override
public ResettableExtent parseFromInput(String input, ParserContext context) throws InputParseException {
    if (input.isEmpty()) {
        return null;
    }
    List<String> split = StringUtil.split(input, ',', '[', ']');
    if (split.size() == 1) {
        return null;
    }
    RandomTransform randomTransform = new RandomTransform();
    for (String s : split) {
        ResettableExtent transform = worldEdit.getTransformFactory().parseFromInput(s, context);
        randomTransform.add(transform, 1d);
    }
    return randomTransform;
}
Also used : RandomTransform(com.fastasyncworldedit.core.extent.transform.RandomTransform) ResettableExtent(com.fastasyncworldedit.core.extent.ResettableExtent)

Example 10 with ResettableExtent

use of com.fastasyncworldedit.core.extent.ResettableExtent in project FastAsyncWorldEdit by IntellectualSites.

the class ScaleTransformParser method parseFromInput.

@Override
protected ResettableExtent parseFromInput(@Nonnull String[] arguments, ParserContext context) throws InputParseException {
    double xScale;
    double yScale;
    double zScale;
    Extent extent;
    if (arguments.length == 1) {
        xScale = yScale = zScale = Double.parseDouble(arguments[0]);
        extent = context.requireExtent();
    } else if (arguments.length == 3 || arguments.length == 4) {
        xScale = Double.parseDouble(arguments[0]);
        yScale = Double.parseDouble(arguments[1]);
        zScale = Double.parseDouble(arguments[2]);
        extent = arguments.length == 4 ? worldEdit.getTransformFactory().parseFromInput(arguments[3], context) : context.requireExtent();
    } else {
        return null;
    }
    return new ScaleTransform(extent, xScale, yScale, zScale);
}
Also used : ResettableExtent(com.fastasyncworldedit.core.extent.ResettableExtent) Extent(com.sk89q.worldedit.extent.Extent) ScaleTransform(com.fastasyncworldedit.core.extent.transform.ScaleTransform)

Aggregations

ResettableExtent (com.fastasyncworldedit.core.extent.ResettableExtent)11 Extent (com.sk89q.worldedit.extent.Extent)5 RandomTransform (com.fastasyncworldedit.core.extent.transform.RandomTransform)2 InputParseException (com.sk89q.worldedit.extension.input.InputParseException)2 NoMatchException (com.sk89q.worldedit.extension.input.NoMatchException)2 ArrayList (java.util.ArrayList)2 SuggestInputParseException (com.fastasyncworldedit.core.command.SuggestInputParseException)1 BrushSettings (com.fastasyncworldedit.core.command.tool.brush.BrushSettings)1 MultiTransform (com.fastasyncworldedit.core.extent.transform.MultiTransform)1 OffsetTransform (com.fastasyncworldedit.core.extent.transform.OffsetTransform)1 PatternTransform (com.fastasyncworldedit.core.extent.transform.PatternTransform)1 RandomOffsetTransform (com.fastasyncworldedit.core.extent.transform.RandomOffsetTransform)1 ScaleTransform (com.fastasyncworldedit.core.extent.transform.ScaleTransform)1 PatternTraverser (com.fastasyncworldedit.core.function.pattern.PatternTraverser)1 TrueRandom (com.fastasyncworldedit.core.math.random.TrueRandom)1 CommandLocals (com.sk89q.minecraft.util.commands.CommandLocals)1 EditSession (com.sk89q.worldedit.EditSession)1 MaxChangedBlocksException (com.sk89q.worldedit.MaxChangedBlocksException)1 Brush (com.sk89q.worldedit.command.tool.brush.Brush)1 Actor (com.sk89q.worldedit.extension.platform.Actor)1