mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 01:37:37 +00:00
Make mask parser create world-aware expression masks.
This allows things like //gmask =queryRel(...) to work. Also the query* functions now allow -1 as a wildcard for either id or data.
This commit is contained in:
parent
23d6fa7579
commit
2cd4412b5d
@ -37,9 +37,11 @@ import com.sk89q.worldedit.function.mask.NoiseFilter;
|
|||||||
import com.sk89q.worldedit.function.mask.OffsetMask;
|
import com.sk89q.worldedit.function.mask.OffsetMask;
|
||||||
import com.sk89q.worldedit.function.mask.RegionMask;
|
import com.sk89q.worldedit.function.mask.RegionMask;
|
||||||
import com.sk89q.worldedit.function.mask.SolidBlockMask;
|
import com.sk89q.worldedit.function.mask.SolidBlockMask;
|
||||||
|
import com.sk89q.worldedit.internal.expression.Expression;
|
||||||
import com.sk89q.worldedit.internal.expression.ExpressionException;
|
import com.sk89q.worldedit.internal.expression.ExpressionException;
|
||||||
import com.sk89q.worldedit.internal.registry.InputParser;
|
import com.sk89q.worldedit.internal.registry.InputParser;
|
||||||
import com.sk89q.worldedit.math.noise.RandomNoise;
|
import com.sk89q.worldedit.math.noise.RandomNoise;
|
||||||
|
import com.sk89q.worldedit.regions.shape.WorldEditExpressionEnvironment;
|
||||||
import com.sk89q.worldedit.session.request.Request;
|
import com.sk89q.worldedit.session.request.Request;
|
||||||
import com.sk89q.worldedit.session.request.RequestSelection;
|
import com.sk89q.worldedit.session.request.RequestSelection;
|
||||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||||
@ -144,7 +146,11 @@ class DefaultMaskParser extends InputParser<Mask> {
|
|||||||
|
|
||||||
case '=':
|
case '=':
|
||||||
try {
|
try {
|
||||||
return new ExpressionMask(component.substring(1));
|
Expression exp = Expression.compile(component.substring(1), "x", "y", "z");
|
||||||
|
WorldEditExpressionEnvironment env = new WorldEditExpressionEnvironment(
|
||||||
|
Request.request().getEditSession(), Vector.ONE, Vector.ZERO);
|
||||||
|
exp.setEnvironment(env);
|
||||||
|
return new ExpressionMask(exp);
|
||||||
} catch (ExpressionException e) {
|
} catch (ExpressionException e) {
|
||||||
throw new InputParseException("Invalid expression: " + e.getMessage());
|
throw new InputParseException("Invalid expression: " + e.getMessage());
|
||||||
}
|
}
|
||||||
|
@ -442,7 +442,9 @@ public final class Functions {
|
|||||||
|
|
||||||
private static double queryInternal(RValue type, RValue data, double typeId, double dataValue) throws EvaluationException {
|
private static double queryInternal(RValue type, RValue data, double typeId, double dataValue) throws EvaluationException {
|
||||||
// Compare to input values and determine return value
|
// Compare to input values and determine return value
|
||||||
final double ret = (typeId == type.getValue() && dataValue == data.getValue()) ? 1.0 : 0.0;
|
// -1 is a wildcard, always true
|
||||||
|
final double ret = ((type.getValue() == -1 || typeId == type.getValue())
|
||||||
|
&& (data.getValue() == -1 || dataValue == data.getValue())) ? 1.0 : 0.0;
|
||||||
|
|
||||||
if (type instanceof LValue) {
|
if (type instanceof LValue) {
|
||||||
((LValue) type).assign(typeId);
|
((LValue) type).assign(typeId);
|
||||||
|
Loading…
Reference in New Issue
Block a user