entity location
This commit is contained in:
1 parent
885f579d6c
commit
e3adc9e83f
2 files changed
+29
-7
No files matched your search
@@ -805,6 +805,8 @@ public class CarpetExpression
|
||||
* </pre>
|
||||
* <h3><code>query(e,'pos')</code></h3>
|
||||
* <p>Triple of entity position</p>
|
||||
* <h3><code>query(e,'location')</code></h3>
|
||||
* <p>Quin-tuple of entity position (x, y, and z coords), and rotation (yaw, pitch)</p>
|
||||
* <h3><code>query(e,'x'), query(e,'y'), query(e,'z')</code></h3>
|
||||
* <p>Respective entity coordinate</p>
|
||||
* <h3><code>query(e,'pitch'), query(e,'yaw')</code></h3>
|
||||
@@ -917,6 +919,8 @@ public class CarpetExpression
|
||||
* <p>Kills the entity.</p>
|
||||
* <h3><code>modify(e, 'pos', x, y, z), modify(e, 'pos', l(x,y,z) )</code></h3>
|
||||
* <p>Moves the entity to a specified coords.</p>
|
||||
* <h3><code>modify(e, 'location', x, y, z, yaw, pitch), modify(e, 'location', l(x, y, z, yaw, pitch) )</code></h3>
|
||||
* <p>Changes full location vector all at once.</p>
|
||||
* <h3><code>modify(e, 'x', x), modify(e, 'y', y), modify(e, 'z', z)</code></h3>
|
||||
* <p>Moves the entity in.... one direction.</p>
|
||||
* <h3><code>modify(e, 'pitch', pitch), modify(e, 'yaw', yaw)</code></h3>
|
||||
@@ -1846,7 +1850,6 @@ public class CarpetExpression
|
||||
this.expr.addLazyFunction("game_tick", -1, (c, t, lv) -> {
|
||||
ServerCommandSource s = ((CarpetContext)c).s;
|
||||
((MinecraftServerInterface)s.getMinecraftServer()).forceTick( () -> System.nanoTime()- CarpetServer.scriptServer.tickStart<50000000L);
|
||||
//s.getMinecraftServer().dontPanic(); // optional not to freak out the watchdog // forceTick handles it
|
||||
if (lv.size()>0)
|
||||
{
|
||||
long ms_total = NumericValue.asNumber(lv.get(0).evalValue(c)).getLong();
|
||||
|
||||
@@ -137,6 +137,7 @@ public class EntityValue extends Value
|
||||
put("uuid",(e, a) -> new StringValue(e.getUuidAsString()));
|
||||
put("id",(e, a) -> new NumericValue(e.getEntityId()));
|
||||
put("pos", (e, a) -> ListValue.of(new NumericValue(e.x), new NumericValue(e.y), new NumericValue(e.z)));
|
||||
put("location", (e, a) -> ListValue.of(new NumericValue(e.x), new NumericValue(e.y), new NumericValue(e.z), new NumericValue(e.yaw), new NumericValue(e.pitch)));
|
||||
put("x", (e, a) -> new NumericValue(e.x));
|
||||
put("y", (e, a) -> new NumericValue(e.y));
|
||||
put("z", (e, a) -> new NumericValue(e.z));
|
||||
@@ -333,6 +334,24 @@ public class EntityValue extends Value
|
||||
put("remove", (entity, value) -> entity.remove());
|
||||
put("health", (e, v) -> { if (e instanceof LivingEntity) ((LivingEntity) e).setHealth((float) NumericValue.asNumber(v).getDouble()); });
|
||||
put("kill", (e, v) -> e.kill());
|
||||
put("location", (e, v) ->
|
||||
{
|
||||
if (!(v instanceof ListValue))
|
||||
{
|
||||
throw new InternalExpressionException("expected a list of 5 parameters as second argument");
|
||||
}
|
||||
List<Value> coords = ((ListValue) v).getItems();
|
||||
e.x = NumericValue.asNumber(coords.get(0)).getDouble();
|
||||
e.y = NumericValue.asNumber(coords.get(1)).getDouble();
|
||||
e.z = NumericValue.asNumber(coords.get(2)).getDouble();
|
||||
e.pitch = (float) NumericValue.asNumber(coords.get(4)).getDouble();
|
||||
e.prevPitch = e.pitch;
|
||||
e.yaw = (float) NumericValue.asNumber(coords.get(3)).getDouble();
|
||||
e.prevYaw = e.yaw;
|
||||
e.setPosition(e.x, e.y, e.z);
|
||||
if (e instanceof ServerPlayerEntity)
|
||||
((ServerPlayerEntity)e).networkHandler.requestTeleport(e.x, e.y, e.z, e.yaw, e.pitch);
|
||||
});
|
||||
put("pos", (e, v) ->
|
||||
{
|
||||
if (!(v instanceof ListValue))
|
||||
@@ -345,42 +364,42 @@ public class EntityValue extends Value
|
||||
e.z = NumericValue.asNumber(coords.get(2)).getDouble();
|
||||
e.setPosition(e.x, e.y, e.z);
|
||||
if (e instanceof ServerPlayerEntity)
|
||||
((ServerPlayerEntity)e).networkHandler.requestTeleport(e.y, e.y, e.z, e.yaw, e.pitch);
|
||||
((ServerPlayerEntity)e).networkHandler.requestTeleport(e.x, e.y, e.z, e.yaw, e.pitch);
|
||||
});
|
||||
put("x", (e, v) ->
|
||||
{
|
||||
e.x = NumericValue.asNumber(v).getDouble();
|
||||
e.setPosition(e.x, e.y, e.z);
|
||||
if (e instanceof ServerPlayerEntity)
|
||||
((ServerPlayerEntity)e).networkHandler.requestTeleport(e.y, e.y, e.z, e.yaw, e.pitch);
|
||||
((ServerPlayerEntity)e).networkHandler.requestTeleport(e.x, e.y, e.z, e.yaw, e.pitch);
|
||||
});
|
||||
put("y", (e, v) ->
|
||||
{
|
||||
e.y = NumericValue.asNumber(v).getDouble();
|
||||
e.setPosition(e.x, e.y, e.z);
|
||||
if (e instanceof ServerPlayerEntity)
|
||||
((ServerPlayerEntity)e).networkHandler.requestTeleport(e.y, e.y, e.z, e.yaw, e.pitch);
|
||||
((ServerPlayerEntity)e).networkHandler.requestTeleport(e.x, e.y, e.z, e.yaw, e.pitch);
|
||||
});
|
||||
put("z", (e, v) ->
|
||||
{
|
||||
e.z = NumericValue.asNumber(v).getDouble();
|
||||
e.setPosition(e.x, e.y, e.z);
|
||||
if (e instanceof ServerPlayerEntity)
|
||||
((ServerPlayerEntity)e).networkHandler.requestTeleport(e.y, e.y, e.z, e.yaw, e.pitch);
|
||||
((ServerPlayerEntity)e).networkHandler.requestTeleport(e.x, e.y, e.z, e.yaw, e.pitch);
|
||||
});
|
||||
put("pitch", (e, v) ->
|
||||
{
|
||||
e.pitch = (float) NumericValue.asNumber(v).getDouble();
|
||||
e.prevPitch = e.pitch;
|
||||
if (e instanceof ServerPlayerEntity)
|
||||
((ServerPlayerEntity)e).networkHandler.requestTeleport(e.y, e.y, e.z, e.yaw, e.pitch);
|
||||
((ServerPlayerEntity)e).networkHandler.requestTeleport(e.x, e.y, e.z, e.yaw, e.pitch);
|
||||
});
|
||||
put("yaw", (e, v) ->
|
||||
{
|
||||
e.yaw = (float) NumericValue.asNumber(v).getDouble();
|
||||
e.prevYaw = e.yaw;
|
||||
if (e instanceof ServerPlayerEntity)
|
||||
((ServerPlayerEntity)e).networkHandler.requestTeleport(e.y, e.y, e.z, e.yaw, e.pitch);
|
||||
((ServerPlayerEntity)e).networkHandler.requestTeleport(e.x, e.y, e.z, e.yaw, e.pitch);
|
||||
});
|
||||
//"look"
|
||||
//"turn"
|
||||
|
||||
Reference in new issue
Block a user