fixed #225 yet again, added display_name, command_name and team option for entities.
This commit is contained in:
1 parent
9a588cf19a
commit
022addf4e1
3 files changed
+37
-5
No files matched your search
+16
-2
@@ -2370,15 +2370,25 @@ Triple of entity motion vector, `l(motion_x, motion_y, motion_z)`
|
||||
|
||||
Respective component of the motion vector
|
||||
|
||||
### `query(e,'name'), query(e,'custom_name'), query(e,'type')`
|
||||
### `query(e,'name'), query(e,'display_name'), query(e,'custom_name'), query(e,'type')`
|
||||
|
||||
String of entity name
|
||||
|
||||
<pre>query(e,'name') => Leatherworker
|
||||
<pre>
|
||||
query(e,'name') => Leatherworker
|
||||
query(e,'custom_name') => null
|
||||
query(e,'type') => villager
|
||||
</pre>
|
||||
|
||||
## `query(e, 'command_name')`
|
||||
|
||||
Returns a valid string to be used in commands to address an entity. Its UUID for all entities except
|
||||
player, where its their name.
|
||||
|
||||
<pre>
|
||||
run('/kill ' + e~'command_name');
|
||||
</pre>
|
||||
|
||||
### `query(e,'is_riding')`
|
||||
|
||||
Boolean. True if riding another entity.
|
||||
@@ -2522,6 +2532,10 @@ Returns `null` if the argument is not a player, otherwise:
|
||||
* `shadow`: any carpet-shadowed real player
|
||||
* `realms`: ?
|
||||
|
||||
### `query(e, 'team')`
|
||||
|
||||
Team name for entity, or `null` if no team is assigned.
|
||||
|
||||
### `query(e,'ping')`
|
||||
|
||||
Player's ping in milliseconds, or `null` if its not a player.
|
||||
|
||||
@@ -113,15 +113,25 @@ Triple of entity motion vector, `l(motion_x, motion_y, motion_z)`
|
||||
|
||||
Respective component of the motion vector
|
||||
|
||||
### `query(e,'name'), query(e,'custom_name'), query(e,'type')`
|
||||
### `query(e,'name'), query(e,'display_name'), query(e,'custom_name'), query(e,'type')`
|
||||
|
||||
String of entity name
|
||||
|
||||
<pre>query(e,'name') => Leatherworker
|
||||
<pre>
|
||||
query(e,'name') => Leatherworker
|
||||
query(e,'custom_name') => null
|
||||
query(e,'type') => villager
|
||||
</pre>
|
||||
|
||||
## `query(e, 'command_name')`
|
||||
|
||||
Returns a valid string to be used in commands to address an entity. Its UUID for all entities except
|
||||
player, where its their name.
|
||||
|
||||
<pre>
|
||||
run('/kill ' + e~'command_name');
|
||||
</pre>
|
||||
|
||||
### `query(e,'is_riding')`
|
||||
|
||||
Boolean. True if riding another entity.
|
||||
@@ -265,6 +275,10 @@ Returns `null` if the argument is not a player, otherwise:
|
||||
* `shadow`: any carpet-shadowed real player
|
||||
* `realms`: ?
|
||||
|
||||
### `query(e, 'team')`
|
||||
|
||||
Team name for entity, or `null` if no team is assigned.
|
||||
|
||||
### `query(e,'ping')`
|
||||
|
||||
Player's ping in milliseconds, or `null` if its not a player.
|
||||
|
||||
@@ -220,7 +220,9 @@ public class EntityValue extends Value
|
||||
put("motion_x", (e, a) -> new NumericValue(e.getVelocity().x));
|
||||
put("motion_y", (e, a) -> new NumericValue(e.getVelocity().y));
|
||||
put("motion_z", (e, a) -> new NumericValue(e.getVelocity().z));
|
||||
put("name", (e, a) -> new StringValue(e.getDisplayName().getString()));
|
||||
put("name", (e, a) -> new StringValue(e.getName().getString()));
|
||||
put("display_name", (e, a) -> new StringValue(e.getDisplayName().getString()));
|
||||
put("command_name", (e, a) -> new StringValue(e.getEntityName()));
|
||||
put("custom_name", (e, a) -> e.hasCustomName()?new StringValue(e.getCustomName().getString()):Value.NULL);
|
||||
put("type", (e, a) -> new StringValue(nameFromRegistryId(Registry.ENTITY_TYPE.getId(e.getType()))));
|
||||
put("is_riding", (e, a) -> new NumericValue(e.hasVehicle()));
|
||||
@@ -331,6 +333,8 @@ public class EntityValue extends Value
|
||||
return Value.NULL;
|
||||
});
|
||||
|
||||
put("team", (e, a) -> e.getScoreboardTeam()==null?Value.NULL:new StringValue(e.getScoreboardTeam().getName()));
|
||||
|
||||
put("ping", (e, a) -> {
|
||||
if (e instanceof ServerPlayerEntity)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user