Re-add smooth filtering via a mask.

Instead of trying to maintain a list of "natural terrain blocks", just
let the user specify a mask of blocks to use for the height map filter.

https://gfycat.com/severaljauntycondor
This commit is contained in:
wizjany
2019-02-26 18:15:35 -05:00
parent 9eeb0acffe
commit 243d6476ac
5 changed files with 47 additions and 17 deletions

View File

@ -240,17 +240,19 @@ public class RegionCommands {
@Command(
aliases = { "/smooth" },
usage = "[iterations]",
usage = "[iterations] [filter]",
desc = "Smooth the elevation in the selection",
help =
"Smooths the elevation in the selection.",
"Smooths the elevation in the selection.\n" +
"Optionally, restricts the height map to a set of blocks specified with mask syntax.\n" +
"For example, '//smooth 1 grass_block,dirt,stone' would only smooth natural surface terrain.",
min = 0,
max = 1
max = 2
)
@CommandPermissions("worldedit.region.smooth")
@Logging(REGION)
public void smooth(Player player, EditSession editSession, @Selection Region region, @Optional("1") int iterations) throws WorldEditException {
HeightMap heightMap = new HeightMap(editSession, region);
public void smooth(Player player, EditSession editSession, @Selection Region region, @Optional("1") int iterations, @Optional Mask mask) throws WorldEditException {
HeightMap heightMap = new HeightMap(editSession, region, mask);
HeightMapFilter filter = new HeightMapFilter(new GaussianKernel(5, 1.0));
int affected = heightMap.applyFilter(filter, iterations);
player.print("Terrain's height map smoothed. " + affected + " block(s) changed.");