use of com.sk89q.worldedit.function.pattern.RandomPattern 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));
}
}
use of com.sk89q.worldedit.function.pattern.RandomPattern in project FastAsyncWorldEdit by IntellectualSites.
the class FloraGenerator method getDesertPattern.
/**
* Get a pattern for plants to place inside a desert environment.
*
* @return a pattern that places flora
*/
public static Pattern getDesertPattern() {
RandomPattern pattern = new RandomPattern();
pattern.add(BlockTypes.DEAD_BUSH.getDefaultState(), 30);
pattern.add(BlockTypes.CACTUS.getDefaultState(), 20);
pattern.add(BlockTypes.AIR.getDefaultState(), 300);
return pattern;
}
use of com.sk89q.worldedit.function.pattern.RandomPattern in project FastAsyncWorldEdit by IntellectualSites.
the class FloraGenerator method getTemperatePattern.
/**
* Get a pattern for plants to place inside a temperate environment.
*
* @return a pattern that places flora
*/
public static Pattern getTemperatePattern() {
RandomPattern pattern = new RandomPattern();
pattern.add(BlockTypes.GRASS.getDefaultState(), 300);
pattern.add(BlockTypes.POPPY.getDefaultState(), 5);
pattern.add(BlockTypes.DANDELION.getDefaultState(), 5);
return pattern;
}
use of com.sk89q.worldedit.function.pattern.RandomPattern in project PrivateMines by UntouchedOdin0.
the class Mine method expand.
public void expand() {
final World world = privateMines.getMineWorldManager().getMinesWorld();
boolean canExpand = canExpand(1);
if (!canExpand) {
privateMines.getLogger().info("Failed to expand the mine due to the mine being too large");
} else {
final var fillType = BlockTypes.DIAMOND_BLOCK;
final var wallType = BlockTypes.BEDROCK;
final var min = getMineData().getMinimumMining();
final var max = getMineData().getMaximumMining();
final Region mine = new CuboidRegion(BukkitAdapter.asBlockVector(min), BukkitAdapter.asBlockVector(max));
final Region fillAir = new CuboidRegion(BukkitAdapter.asBlockVector(min), BukkitAdapter.asBlockVector(max));
final Region walls = new CuboidRegion(BukkitAdapter.asBlockVector(min), BukkitAdapter.asBlockVector(max));
if (fillType == null || wallType == null)
return;
mine.expand(ExpansionUtils.expansionVectors(1));
walls.expand(ExpansionUtils.expansionVectors(1));
walls.expand(BlockVector3.UNIT_X, BlockVector3.UNIT_Y, BlockVector3.UNIT_Z, BlockVector3.UNIT_MINUS_X, BlockVector3.UNIT_MINUS_Y, BlockVector3.UNIT_MINUS_Z);
fillAir.expand(BlockVector3.UNIT_X, BlockVector3.UNIT_Y, BlockVector3.UNIT_Z, BlockVector3.UNIT_MINUS_X, BlockVector3.UNIT_MINUS_Z);
Map<Material, Double> materials = mineData.getMineType().getMaterials();
final RandomPattern randomPattern = new RandomPattern();
if (materials != null) {
materials.forEach((material, chance) -> {
Pattern pattern = BukkitAdapter.adapt(material.createBlockData());
randomPattern.add(pattern, chance);
});
}
try (EditSession editSession = WorldEdit.getInstance().newEditSessionBuilder().world(BukkitAdapter.adapt(world)).fastMode(true).build()) {
editSession.setBlocks(walls, BukkitAdapter.adapt(Material.BEDROCK.createBlockData()));
editSession.setBlocks(fillAir, BukkitAdapter.adapt(Material.AIR.createBlockData()));
}
mineData.setMinimumMining(BukkitAdapter.adapt(world, mine.getMinimumPoint()));
mineData.setMaximumMining(BukkitAdapter.adapt(world, mine.getMaximumPoint()));
mineData.setMinimumFullRegion(mineData.getMinimumFullRegion().subtract(1, 1, 1));
mineData.setMaximumFullRegion(mineData.getMaximumFullRegion().add(1, 1, 1));
setMineData(mineData);
privateMines.getMineStorage().replaceMine(mineData.getMineOwner(), this);
reset();
}
}
use of com.sk89q.worldedit.function.pattern.RandomPattern in project Nexus by ProjectEdenGG.
the class WorldEditUtils method toRandomPattern.
public RandomPattern toRandomPattern(Set<BlockType> baseBlocks) {
RandomPattern pattern = new RandomPattern();
baseBlocks.forEach(baseBlock -> pattern.add(baseBlock, (float) 100 / baseBlocks.size()));
return pattern;
}
Aggregations