mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-01 02:46:41 +00:00
Use expression for brush radius
This commit is contained in:
@ -80,6 +80,11 @@ public class Expression {
|
||||
return new Expression(expression, variableNames);
|
||||
}
|
||||
|
||||
public Expression(double constant) {
|
||||
variableNames = null;
|
||||
root = new Constant(0, constant);
|
||||
}
|
||||
|
||||
private Expression(String expression, String... variableNames) throws ExpressionException {
|
||||
this(Lexer.tokenize(expression), variableNames);
|
||||
}
|
||||
@ -106,6 +111,9 @@ public class Expression {
|
||||
}
|
||||
|
||||
public double evaluate(double... values) throws EvaluationException {
|
||||
if (root instanceof Constant) {
|
||||
return root.getValue();
|
||||
}
|
||||
for (int i = 0; i < values.length; i++) {
|
||||
Variable var = variableArray[i];
|
||||
var.value = values[i];
|
||||
@ -124,6 +132,10 @@ public class Expression {
|
||||
root = root.optimize();
|
||||
}
|
||||
|
||||
public RValue getRoot() {
|
||||
return root;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return root.toString();
|
||||
|
Reference in New Issue
Block a user