Merge branch 'master' into 1.16
This commit is contained in:
commit
e5aea149cf
2 files changed
+52
-18
No files matched your search
@@ -91,4 +91,51 @@ public class Vector3Argument extends Argument
|
||||
throw new InternalExpressionException("Position argument should be defined either by three coordinates (a triple or by three arguments), or a positioned block value");
|
||||
}
|
||||
}
|
||||
|
||||
public static Vector3Argument findIn(List<Value> params, int offset, boolean optionalDirection)
|
||||
{
|
||||
try
|
||||
{
|
||||
Value v1 = params.get(0 + offset);
|
||||
if (v1 instanceof BlockValue)
|
||||
{
|
||||
return (new Vector3Argument(new Vec3d(((BlockValue) v1).getPos()).add(0.5,0.5,0.5), 1+offset)).fromBlock();
|
||||
}
|
||||
if (v1 instanceof ListValue)
|
||||
{
|
||||
List<Value> args = ((ListValue) v1).getItems();
|
||||
Vec3d pos = new Vec3d(
|
||||
NumericValue.asNumber(args.get(0)).getDouble(),
|
||||
NumericValue.asNumber(args.get(1)).getDouble(),
|
||||
NumericValue.asNumber(args.get(2)).getDouble());
|
||||
double yaw = 0.0D;
|
||||
double pitch = 0.0D;
|
||||
if (args.size()>3 && optionalDirection)
|
||||
{
|
||||
yaw = NumericValue.asNumber(args.get(3)).getDouble();
|
||||
pitch = NumericValue.asNumber(args.get(4)).getDouble();
|
||||
}
|
||||
return new Vector3Argument(pos,offset+1, yaw, pitch);
|
||||
}
|
||||
Vec3d pos = new Vec3d(
|
||||
NumericValue.asNumber(v1).getDouble(),
|
||||
NumericValue.asNumber(params.get(1 + offset)).getDouble(),
|
||||
NumericValue.asNumber(params.get(2 + offset)).getDouble());
|
||||
double yaw = 0.0D;
|
||||
double pitch = 0.0D;
|
||||
int eatenLength = 3;
|
||||
if (params.size()>3+offset && optionalDirection)
|
||||
{
|
||||
yaw = NumericValue.asNumber(params.get(3 + offset)).getDouble();
|
||||
pitch = NumericValue.asNumber(params.get(4 + offset)).getDouble();
|
||||
eatenLength = 5;
|
||||
}
|
||||
|
||||
return new Vector3Argument(pos,offset+eatenLength, yaw, pitch);
|
||||
}
|
||||
catch (IndexOutOfBoundsException e)
|
||||
{
|
||||
throw new InternalExpressionException("Position argument should be defined either by three coordinates (a triple or by three arguments), or a positioned block value");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import carpet.helpers.Tracer;
|
||||
import carpet.patches.EntityPlayerMPFake;
|
||||
import carpet.script.CarpetContext;
|
||||
import carpet.script.EntityEventsGroup;
|
||||
import carpet.script.argument.Vector3Argument;
|
||||
import carpet.script.exception.InternalExpressionException;
|
||||
import com.mojang.brigadier.StringReader;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
@@ -789,26 +790,12 @@ public class EntityValue extends Value
|
||||
else if (v instanceof ListValue)
|
||||
{
|
||||
List<Value> lv = ((ListValue) v).getItems();
|
||||
if (lv.get(0) instanceof BlockValue)
|
||||
Vector3Argument locator = Vector3Argument.findIn(lv, 0, false);
|
||||
pos = new BlockPos(locator.vec.x, locator.vec.y, locator.vec.z);
|
||||
if (lv.size() > locator.offset)
|
||||
{
|
||||
pos = ((BlockValue) lv.get(0)).getPos();
|
||||
if (lv.size()>1)
|
||||
{
|
||||
distance = (int) NumericValue.asNumber(lv.get(1)).getLong();
|
||||
}
|
||||
distance = (int) NumericValue.asNumber(lv.get(locator.offset)).getLong();
|
||||
}
|
||||
else if (lv.size()>=3)
|
||||
{
|
||||
pos = new BlockPos(NumericValue.asNumber(lv.get(0)).getLong(),
|
||||
NumericValue.asNumber(lv.get(1)).getLong(),
|
||||
NumericValue.asNumber(lv.get(2)).getLong());
|
||||
if (lv.size()>3)
|
||||
{
|
||||
distance = (int) NumericValue.asNumber(lv.get(4)).getLong();
|
||||
}
|
||||
}
|
||||
else throw new InternalExpressionException("'home' requires at least one position argument, and optional distance");
|
||||
|
||||
}
|
||||
else throw new InternalExpressionException("'home' requires at least one position argument, and optional distance");
|
||||
|
||||
|
||||
Reference in new issue
Block a user