Reimplement Masks + Fixes

Masks Reimplemented:
    - Adjacent (~): Adjacent to a specific number of other blocks.
        - Example: ~[oak_log][1][4]
    - Extrema (#extrema): Restrict to near specific terrain extrema. The "-o" flag will only overlay existing terrain.
        - Example: #extrema[0d][45d][-o]
    - ROC Angle (#roc): Restrict to near specific terrain slope rate of change. The "-o" flag will only overlay existing terrain.
        - Example: #roc[0d][45d][-o]
    - Surface (#surface): Restrict to surfaces (any solid block touching air).
        - Example: #surface
    - Wall (#wall): Restrict to walls (any block n,e,s,w of air).
        - Example: #wall

Other Changes:
    - Minor logic change to angle mask's overlay.
    - Fixed negating air mask.
    - Added overlay flag to angle (/) mask.
This commit is contained in:
IronApollo
2020-09-06 18:42:43 -04:00
parent ee49627e51
commit 6807ccd960
12 changed files with 307 additions and 207 deletions

View File

@ -65,18 +65,6 @@
// public MaskCommands(WorldEdit worldEdit) {
// this.worldEdit = worldEdit;
// }
//
// @Command(
// name = "#simplex",
// desc = "Use simplex noise as the mask"
// )
// public Mask simplex(@Arg(desc = "double scale") double scale, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) {
// scale = 1d / Math.max(1, scale);
// minInt = (minInt - 50) / 50;
// maxInt = (maxInt - 50) / 50;
// return new SimplexMask(scale, minInt, maxInt);
// }
//
// @Command(
// name = "#light",
// desc = "Restrict to specific light levels"
@ -133,40 +121,7 @@
// public Mask nolight(Extent extent) {
// return new LightMask(extent, 0, 0);
// }
//
// @Command(
// name = "#region",
// aliases = {"#selection", "#sel"},
// desc = "inside the provided selection"
// )
// public Mask selection(Player player, LocalSession session) throws IncompleteRegionException {
// return new RegionMask(session.getSelection(player.getWorld()).clone());
// }
//
// @Command(
// name = "#xaxis",
// desc = "Restrict to initial x axis"
// )
// public Mask xaxis() {
// return new XAxisMask();
// }
//
// @Command(
// name = "#yaxis",
// desc = "Restrict to initial y axis"
// )
// public Mask yaxis() {
// return new YAxisMask();
// }
//
// @Command(
// name = "#zaxis",
// desc = "Restrict to initial z axis"
// )
// public Mask zaxis() {
// return new ZAxisMask();
// }
//
// @Command(
// name = "#iddata",
// desc = "Restrict to initial block id and data"
@ -174,132 +129,4 @@
// public Mask iddata(Extent extent) {
// return new IdDataMask(extent);
// }
//
// @Command(
// name = "#wall",
// desc = "Restrict to walls (any block n,e,s,w of air)"
// )
// public Mask wall(Extent extent) {
// Mask blockMask = air(extent);
// return new MaskUnion(new ExistingBlockMask(extent), new WallMask(blockMask, 1, 8));
// }
//
// @Command(
// name = "#surface",
// desc = "Restrict to surfaces (any solid block touching air)"
// )
// public Mask surface(Extent extent) {
// return new SurfaceMask(extent);
// }
//
// @Command(
// name = "\\",
// aliases = {"/", "#angle", "#\\", "#/"},
// desc = "Restrict to specific terrain angle",
// descFooter = "Restrict to specific terrain angle\n" +
// "The -o flag will only overlay\n" +
// "Example: /[0d][45d]\n" +
// "Explanation: Allows any block where the adjacent block is between 0 and 45 degrees.\n" +
// "Example: /[3][20]\n" +
// "Explanation: Allows any block where the adjacent block is between 3 and 20 blocks below"
//)
// public Mask angle(Extent extent, @Arg(name="min", desc = "min angle") String minStr, @Arg(name="max", desc = "max angle") String maxStr, @Switch(name = 'o', desc = "TODO") boolean overlay, @Arg(name = "distance", desc = "int", def = "1") int distanceOpt) throws ExpressionException {
// double y1, y2;
// boolean override;
// if (maxStr.endsWith("d")) {
// double y1d = Expression.compile(minStr.substring(0, minStr.length() - 1)).evaluate();
// double y2d = Expression.compile(maxStr.substring(0, maxStr.length() - 1)).evaluate();
// y1 = Math.tan(y1d * (Math.PI / 180));
// y2 = Math.tan(y2d * (Math.PI / 180));
// } else {
// y1 = Expression.compile(minStr).evaluate();
// y2 = Expression.compile(maxStr).evaluate();
// }
// return new AngleMask(extent, y1, y2, overlay, distanceOpt);
// }
//
// @Command(
// name = "(",
// aliases = {")", "#roc", "#(", "#)"},
// desc = "Restrict to near specific terrain slope rate of change",
// descFooter = "Restrict to near specific terrain slope rate of change\n" +
// "The -o flag will only overlay\n" +
// "Example: ([0d][45d][5]\n" +
// "Explanation: Restrict near where the angle changes between 0-45 degrees within 5 blocks\n" +
// "Note: Use negatives for decreasing slope"
//)
// public Mask roc(Extent extent, @Arg(name="min", desc = "min angle") String minStr, @Arg(name="max", desc = "max angle") String maxStr, @Switch(name = 'o', desc = "TODO") boolean overlay, @Arg(name = "distance", desc = "int", def = "4") int distanceOpt) throws ExpressionException {
// double y1, y2;
// boolean override;
// if (maxStr.endsWith("d")) {
// double y1d = Expression.compile(minStr.substring(0, minStr.length() - 1)).evaluate();
// double y2d = Expression.compile(maxStr.substring(0, maxStr.length() - 1)).evaluate();
// y1 = Math.tan(y1d * (Math.PI / 180));
// y2 = Math.tan(y2d * (Math.PI / 180));
// } else {
// y1 = Expression.compile(minStr).evaluate();
// y2 = Expression.compile(maxStr).evaluate();
// }
// return new ROCAngleMask(extent, y1, y2, overlay, distanceOpt);
// }
//
// @Command(
// name = "^",
// aliases = {"#extrema", "#^"},
// desc = "Restrict to near specific terrain extrema",
// descFooter = "Restrict to near specific terrain extrema\n" +
// "The -o flag will only overlay\n" +
// "Example: ([0d][45d][5]\n" +
// "Explanation: Restrict to near 45 degrees of local maxima\n" +
// "Note: Use negatives for local minima"
//)
// public Mask extrema(Extent extent, @Arg(name="min", desc = "min angle") String minStr, @Arg(name="max", desc = "max angle") String maxStr, @Switch(name = 'o', desc = "TODO") boolean overlay, @Arg(name = "distance", desc = "int", def = "4") int distanceOpt) throws ExpressionException {
// double y1, y2;
// boolean override;
// if (maxStr.endsWith("d")) {
// double y1d = Expression.compile(minStr.substring(0, minStr.length() - 1)).evaluate();
// double y2d = Expression.compile(maxStr.substring(0, maxStr.length() - 1)).evaluate();
// y1 = Math.tan(y1d * (Math.PI / 180));
// y2 = Math.tan(y2d * (Math.PI / 180));
// } else {
// y1 = Expression.compile(minStr).evaluate();
// y2 = Expression.compile(maxStr).evaluate();
// }
// return new ExtremaMask(extent, y1, y2, overlay, distanceOpt);
// }
//
// @Command(
// name = "{",
// aliases = {"#{"},
// desc = "Restricts blocks to within a specific radius range of the initial block"
//)
// public Mask radius(@Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) throws ExpressionException {
// return new RadiusMask((int) minInt, (int) maxInt);
// }
//
// @Command(
// name = "|",
// aliases = {"#|", "#side"},
// desc = "sides with a specific number of other blocks"
//)
// public Mask wall(@Arg(desc = "Mask") Mask mask, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) throws ExpressionException {
// return new WallMask(mask, (int) minInt, (int) maxInt);
// }
//
// @Command(
// name = "~",
// aliases = {"#~", "#adjacent"},
// desc = "Adjacent to a specific number of other blocks"
//)
// public Mask adjacent(@Arg(desc = "Mask") Mask mask, @Arg(name = "min", desc = "double", def = "-1") double min, @Arg(name = "max", desc = "double", def = "-1") double max) throws ExpressionException {
// if (min == -1 && max == -1) {
// min = 1;
// max = 8;
// } else if (max == -1) max = min;
// if (max >= 8 && min == 1) {
// return new AdjacentAnyMask(mask);
// }
// return new AdjacentMask(mask, (int) min, (int) max);
// }
//
//}