Merge branch 'master' into 1.17
This commit is contained in:
commit
407c117c29
5 files changed
+43
-5
No files matched your search
@@ -80,7 +80,7 @@ public class Operators {
|
||||
expression.addFunctionalEquivalence("/", "quotient");
|
||||
|
||||
expression.addBinaryOperator("%", precedence.get("multiplication*/%"), true, (v1, v2) ->
|
||||
new NumericValue(NumericValue.asNumber(v1).getDouble() % NumericValue.asNumber(v2).getDouble()));
|
||||
NumericValue.asNumber(v1).mod(NumericValue.asNumber(v2)));
|
||||
expression.addBinaryOperator("^", precedence.get("exponent^"), false, (v1, v2) ->
|
||||
new NumericValue(java.lang.Math.pow(NumericValue.asNumber(v1).getDouble(), NumericValue.asNumber(v2).getDouble())));
|
||||
|
||||
|
||||
@@ -1050,7 +1050,22 @@ public class EntityValue extends Value
|
||||
updatePosition(e, e.getX(), e.getY(), e.getZ(), e.getYaw(), MathHelper.clamp((float)NumericValue.asNumber(v).getDouble(), -90, 90));
|
||||
});
|
||||
|
||||
//"look"
|
||||
put("look", (e, v) -> {
|
||||
if (!(v instanceof ListValue)) throw new InternalExpressionException("Expected a list of 3 parameters as a second argument");
|
||||
List<Value> vec = ((ListValue)v).getItems();
|
||||
float x = NumericValue.asNumber(vec.get(0)).getFloat();
|
||||
float y = NumericValue.asNumber(vec.get(1)).getFloat();
|
||||
float z = NumericValue.asNumber(vec.get(2)).getFloat();
|
||||
float l = MathHelper.sqrt(x*x + y*y + z*z);
|
||||
if(l==0) return;
|
||||
x /= l;
|
||||
y /= l;
|
||||
z /= l;
|
||||
float pitch = (float) -Math.asin(y) / 0.017453292F;
|
||||
float yaw = (float) (x==0 && z==0 ? e.yaw : MathHelper.atan2(-x,z) / 0.017453292F);
|
||||
updatePosition(e, e.getX(), e.getY(), e.getZ(), yaw, pitch);
|
||||
});
|
||||
|
||||
//"turn"
|
||||
//"nod"
|
||||
|
||||
|
||||
@@ -313,4 +313,14 @@ public class NumericValue extends Value
|
||||
{
|
||||
return longValue!= null || getDouble() == (double)getLong();
|
||||
}
|
||||
|
||||
public Value mod(NumericValue n2)
|
||||
{
|
||||
if (this.longValue != null && n2.longValue != null)
|
||||
return new NumericValue(Math.floorMod(longValue, n2.longValue));
|
||||
double x = value;
|
||||
double y = n2.value;
|
||||
if (y == 0) throw new ArithmeticException("Division by zero");
|
||||
return new NumericValue( x - Math.floor(x / y) * y);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user