Search in sources :

Example 1 with ResettableExtent

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

the class TransformFactory method parseFromParsers.

private void parseFromParsers(final ParserContext context, final List<ResettableExtent> transforms, final String component) {
    ResettableExtent match = null;
    for (InputParser<ResettableExtent> parser : getParsers()) {
        match = parser.parseFromInput(component, context);
        if (match != null) {
            break;
        }
    }
    if (match == null) {
        throw new NoMatchException(Caption.of("worldedit.error.no-match", TextComponent.of(component)));
    }
    transforms.add(match);
}
Also used : NoMatchException(com.sk89q.worldedit.extension.input.NoMatchException) ResettableExtent(com.fastasyncworldedit.core.extent.ResettableExtent)

Example 2 with ResettableExtent

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

the class OffsetTransformParser method parseFromInput.

@Override
protected ResettableExtent parseFromInput(@Nonnull String[] arguments, ParserContext context) throws InputParseException {
    if (arguments.length != 3 && arguments.length != 4) {
        throw new InputParseException(Caption.of("fawe.error.command.syntax", TextComponent.of("#offset[x][y][z]")));
    }
    int xOffset = Integer.parseInt(arguments[0]);
    int yOffset = Integer.parseInt(arguments[1]);
    int zOffset = Integer.parseInt(arguments[2]);
    Extent extent;
    extent = arguments.length == 4 ? worldEdit.getTransformFactory().parseFromInput(arguments[3], context) : context.requireExtent();
    return new OffsetTransform(extent, xOffset, yOffset, zOffset);
}
Also used : OffsetTransform(com.fastasyncworldedit.core.extent.transform.OffsetTransform) InputParseException(com.sk89q.worldedit.extension.input.InputParseException) ResettableExtent(com.fastasyncworldedit.core.extent.ResettableExtent) Extent(com.sk89q.worldedit.extent.Extent)

Example 3 with ResettableExtent

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

the class RotateTransformParser method parseFromInput.

@Override
protected ResettableExtent parseFromInput(@NotNull 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 4 with ResettableExtent

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

the class SpreadTransformParser method parseFromInput.

@Override
protected ResettableExtent parseFromInput(@NotNull String[] arguments, ParserContext context) throws InputParseException {
    if (arguments.length != 3 && arguments.length != 4) {
        return null;
    }
    int xOffset = Integer.parseInt(arguments[0]);
    int yOffset = Integer.parseInt(arguments[1]);
    int zOffset = Integer.parseInt(arguments[2]);
    Extent extent = arguments.length == 4 ? worldEdit.getTransformFactory().parseFromInput(arguments[3], context) : context.requireExtent();
    return new RandomOffsetTransform(extent, xOffset, yOffset, zOffset);
}
Also used : ResettableExtent(com.fastasyncworldedit.core.extent.ResettableExtent) Extent(com.sk89q.worldedit.extent.Extent) RandomOffsetTransform(com.fastasyncworldedit.core.extent.transform.RandomOffsetTransform)

Example 5 with ResettableExtent

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

the class RandomTransform method setExtent.

@Override
public ResettableExtent setExtent(Extent extent) {
    if (collection == null) {
        collection = RandomCollection.of(weights, random);
        extents = new LinkedHashSet<>(weights.keySet());
    }
    super.setExtent(extent);
    for (ResettableExtent current : extents) {
        current.setExtent(extent);
    }
    return this;
}
Also used : ResettableExtent(com.fastasyncworldedit.core.extent.ResettableExtent)

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