Search in sources :

Example 1 with NoiseRandom

use of com.fastasyncworldedit.core.math.random.NoiseRandom in project FastAsyncWorldEdit by IntellectualSites.

the class NoisePatternParser method parseFromInput.

@Override
protected Pattern parseFromInput(@Nonnull String[] arguments, ParserContext context) {
    if (arguments.length != 2) {
        throw new InputParseException(Caption.of("fawe.error.command.syntax", TextComponent.of(getPrefix() + "[scale][pattern] (e.g. " + getPrefix() + "[5][dirt,stone])")));
    }
    double scale = parseScale(arguments[0]);
    Pattern inner = worldEdit.getPatternFactory().parseFromInput(arguments[1], context);
    if (inner instanceof RandomPattern) {
        return new RandomPattern(new NoiseRandom(this.generatorSupplier.get(), scale), (RandomPattern) inner);
    } else if (inner instanceof BlockStateHolder) {
        // single blocks won't have any impact on how a noise behaves
        return inner;
    } else {
        throw new InputParseException(TextComponent.of("Pattern " + inner.getClass().getSimpleName() + " cannot be used with #" + this.name));
    }
}
Also used : RandomPattern(com.sk89q.worldedit.function.pattern.RandomPattern) Pattern(com.sk89q.worldedit.function.pattern.Pattern) NoiseRandom(com.fastasyncworldedit.core.math.random.NoiseRandom) InputParseException(com.sk89q.worldedit.extension.input.InputParseException) BlockStateHolder(com.sk89q.worldedit.world.block.BlockStateHolder) RandomPattern(com.sk89q.worldedit.function.pattern.RandomPattern)

Aggregations

NoiseRandom (com.fastasyncworldedit.core.math.random.NoiseRandom)1 InputParseException (com.sk89q.worldedit.extension.input.InputParseException)1 Pattern (com.sk89q.worldedit.function.pattern.Pattern)1 RandomPattern (com.sk89q.worldedit.function.pattern.RandomPattern)1 BlockStateHolder (com.sk89q.worldedit.world.block.BlockStateHolder)1