mirror of
https://github.com/boy0001/FastAsyncWorldedit.git
synced 2024-11-25 03:55:35 +01:00
Adjacent mask range parameter
This commit is contained in:
parent
c676d89aa6
commit
479c6c5172
@ -7,11 +7,12 @@ import com.sk89q.worldedit.function.mask.BlockMask;
|
||||
import java.util.Collection;
|
||||
|
||||
public class AdjacentMask extends BlockMask {
|
||||
private final int required;
|
||||
private final int min, max;
|
||||
|
||||
public AdjacentMask(Extent extent, Collection<BaseBlock> blocks, int required) {
|
||||
public AdjacentMask(Extent extent, Collection<BaseBlock> blocks, int requiredMin, int requiredMax) {
|
||||
super(extent, blocks);
|
||||
this.required = required;
|
||||
this.min = requiredMin;
|
||||
this.max = requiredMax;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -21,20 +22,20 @@ public class AdjacentMask extends BlockMask {
|
||||
double y = v.y;
|
||||
double z = v.z;
|
||||
v.x = x + 1;
|
||||
if (super.test(v) && ++count == required) { v.x = x; return true; }
|
||||
if (super.test(v) && ++count == min && max >= 8) { v.x = x; return true; }
|
||||
v.x = x - 1;
|
||||
if (super.test(v) && ++count == required) { v.x = x; return true; }
|
||||
if (super.test(v) && ++count == min && max >= 8) { v.x = x; return true; }
|
||||
v.x = x;
|
||||
v.y = y + 1;
|
||||
if (super.test(v) && ++count == required) { v.y = y; return true; }
|
||||
if (super.test(v) && ++count == min && max >= 8) { v.y = y; return true; }
|
||||
v.y = y - 1;
|
||||
if (super.test(v) && ++count == required) { v.y = y; return true; }
|
||||
if (super.test(v) && ++count == min && max >= 8) { v.y = y; return true; }
|
||||
v.y = y;
|
||||
v.z = z + 1;
|
||||
if (super.test(v) && ++count == required) { v.z = z; return true; }
|
||||
if (super.test(v) && ++count == min && max >= 8) { v.z = z; return true; }
|
||||
v.z = z - 1;
|
||||
if (super.test(v) && ++count == required) { v.z = z; return true; }
|
||||
if (super.test(v) && ++count == min && max >= 8) { v.z = z; return true; }
|
||||
v.z = z;
|
||||
return false;
|
||||
return count >= min && count <= max;
|
||||
}
|
||||
}
|
||||
|
@ -167,11 +167,16 @@ public class DefaultMaskParser extends InputParser<Mask> {
|
||||
tempContext.setRestricted(false);
|
||||
tempContext.setPreferringWildcard(true);
|
||||
try {
|
||||
int requiredCount = 1;
|
||||
int requiredMin = 1;
|
||||
int requiredMax = 8;
|
||||
if (split.length == 2) {
|
||||
requiredCount = Integer.parseInt(split[1]);
|
||||
String[] split2 = split[1].split(",");
|
||||
requiredMin = Integer.parseInt(split2[0]);
|
||||
if (split2.length == 2) {
|
||||
requiredMax = Integer.parseInt(split2[1]);
|
||||
}
|
||||
}
|
||||
return new AdjacentMask(extent, worldEdit.getBlockFactory().parseFromListInput(component.substring(1), tempContext), requiredCount);
|
||||
return new AdjacentMask(extent, worldEdit.getBlockFactory().parseFromListInput(component.substring(1), tempContext), requiredMin, requiredMax);
|
||||
} catch (NumberFormatException e) {
|
||||
throw new InputParseException("Unknown adjacent mask '" + component + "' (not in form `~<ids>[=count]`)");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user