code fixes
This commit is contained in:
1 parent
6bf1d46c50
commit
a7fcaaddf1
3 files changed
+59
-50
No files matched your search
+45
-36
@@ -1920,15 +1920,20 @@ used to match specific information from it, or use it to copy to another block
|
|||||||
<pre> block_data(x,y,z) => '{TransferCooldown:0,x:450,y:68, ... }'
|
<pre> block_data(x,y,z) => '{TransferCooldown:0,x:450,y:68, ... }'
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
### `poi(pos), poi(pos, radius), poi(pos, radius, status)`
|
### `poi(pos), poi(pos, radius?, type?, status?, column?)`
|
||||||
|
|
||||||
Queries a POI (Point of Interest) at a given position, returning `null` if none is found, or tuple of poi type and its
|
Queries a POI (Point of Interest) at a given position, returning `null` if none is found, or tuple of poi type and its
|
||||||
occupancy load. With optional `radius` and `status`, returns a list of POIs around `pos` within a given `radius`.
|
occupancy load. With optional `type`, `radius` and `status`, returns a list of POIs around `pos` within a
|
||||||
If `status` is specified (either 'available', or 'occupied') returns only POIs with that status. The return format is
|
given `radius`. If the `type` is specified, returns only poi types of that types, or everything if omitted or `'any'`.
|
||||||
again, poi type, occupancy load, and extra tripple of coordinates.
|
If `status` is specified (either `'any'`, `'available'`, or `'occupied'`) returns only POIs with that status.
|
||||||
|
With `column` set to `true`, it will return all POIs in a cuboid with `radius` blocks away on x and z, in the entire
|
||||||
|
block column from 0 to 255. Default (`false`) returns POIs within a spherical area centered on `pos` and with `radius`
|
||||||
|
radius.
|
||||||
|
|
||||||
Querying for POIs using the radius is intended use of POI mechanics and ability of accessing individual POIs
|
The return format of the results is a list of poi type, occupancy load, and extra triple of coordinates.
|
||||||
via `poi(pos)` in only provided for completness.
|
|
||||||
|
Querying for POIs using the radius is the intended use of POI mechanics, and the ability of accessing individual POIs
|
||||||
|
via `poi(pos)` in only provided for completeness.
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
poi(x,y,z) => null // nothing set at position
|
poi(x,y,z) => null // nothing set at position
|
||||||
@@ -2625,14 +2630,14 @@ query(e,'type') => villager
|
|||||||
Returns a valid string to be used in commands to address an entity. Its UUID for all entities except
|
Returns a valid string to be used in commands to address an entity. Its UUID for all entities except
|
||||||
player, where its their name.
|
player, where its their name.
|
||||||
|
|
||||||
### `query(e, 'persistence')`
|
|
||||||
|
|
||||||
Returns if a mob has a persistence tag or not. Returns `null` for non-mob entities.
|
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
run('/kill ' + e~'command_name');
|
run('/kill ' + e~'command_name');
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
|
### `query(e, 'persistence')`
|
||||||
|
|
||||||
|
Returns if a mob has a persistence tag or not. Returns `null` for non-mob entities.
|
||||||
|
|
||||||
### `query(e, 'is_riding')`
|
### `query(e, 'is_riding')`
|
||||||
|
|
||||||
Boolean, true if the entity is riding another entity.
|
Boolean, true if the entity is riding another entity.
|
||||||
@@ -2699,7 +2704,7 @@ Age of the entity in ticks, i.e. how long it existed.
|
|||||||
|
|
||||||
### `query(e, 'breeding_age')`
|
### `query(e, 'breeding_age')`
|
||||||
|
|
||||||
Breeding age of passive entity, in ticks. If negative, time to adulthood, if positive, breeding cooldown
|
Breeding age of passive entity, in ticks. If negative, time to adulthood, if positive, breeding cooldown.
|
||||||
|
|
||||||
### `query(e, 'despawn_timer')`
|
### `query(e, 'despawn_timer')`
|
||||||
|
|
||||||
@@ -2715,15 +2720,15 @@ Number of ticks an entity sits in a portal.
|
|||||||
|
|
||||||
### `query(e, 'item')`
|
### `query(e, 'item')`
|
||||||
|
|
||||||
The item triple (name, count, nbt) if its an item entity, `null` otherwise
|
The item triple (name, count, nbt) if its an item entity, `null` otherwise.
|
||||||
|
|
||||||
### `query(e, 'count')`
|
### `query(e, 'count')`
|
||||||
|
|
||||||
Number of items in a stack from item entity, `null` otherwise
|
Number of items in a stack from item entity, `null` otherwise.
|
||||||
|
|
||||||
### `query(e, 'pickup_delay')`
|
### `query(e, 'pickup_delay')`
|
||||||
|
|
||||||
Retrieves pickup delay timeout for an item entity, `null` otherwise
|
Retrieves pickup delay timeout for an item entity, `null` otherwise.
|
||||||
|
|
||||||
### `query(e, 'is_baby')`
|
### `query(e, 'is_baby')`
|
||||||
|
|
||||||
@@ -2744,7 +2749,7 @@ of block value, node type, penalty, and a boolean indicated if the node has been
|
|||||||
|
|
||||||
### `query(e, 'pose')`
|
### `query(e, 'pose')`
|
||||||
|
|
||||||
Returns a pose of an entity, one of the following options
|
Returns a pose of an entity, one of the following options:
|
||||||
* `'standing'`
|
* `'standing'`
|
||||||
* `'fall_flying'`
|
* `'fall_flying'`
|
||||||
* `'sleeping'`
|
* `'sleeping'`
|
||||||
@@ -2790,7 +2795,7 @@ Returns `null` if the argument is not a player, otherwise:
|
|||||||
* `realms`: ?
|
* `realms`: ?
|
||||||
|
|
||||||
### `query(e, 'category')`
|
### `query(e, 'category')`
|
||||||
Returns a lowercase string containing the category of the entity (hostile, passive, water, ambient, misc)
|
Returns a lowercase string containing the category of the entity (hostile, passive, water, ambient, misc).
|
||||||
|
|
||||||
### `query(e, 'team')`
|
### `query(e, 'team')`
|
||||||
|
|
||||||
@@ -2854,8 +2859,8 @@ Returns currently mined block by the player, as registered by the game server.
|
|||||||
### `query(e, 'breaking_progress')`
|
### `query(e, 'breaking_progress')`
|
||||||
|
|
||||||
Returns current breaking progress of a current player mining block, or `null`, if no block is mined.
|
Returns current breaking progress of a current player mining block, or `null`, if no block is mined.
|
||||||
Breaking progress, it not null, is any number 0 or above, while 10 means that the block should already be
|
Breaking progress, if not null, is any number 0 or above, while 10 means that the block should already be
|
||||||
broken by the client. This value may tick above 10, if the client / connection is lagging
|
broken by the client. This value may tick above 10, if the client / connection is lagging.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
@@ -2897,19 +2902,23 @@ _break(player, pos, name, step, lvl) ->
|
|||||||
### `query(e, 'facing', order?)`
|
### `query(e, 'facing', order?)`
|
||||||
|
|
||||||
Returns where the entity is facing. optional order (number from 0 to 5, and negative), indicating primary directions
|
Returns where the entity is facing. optional order (number from 0 to 5, and negative), indicating primary directions
|
||||||
where entity is looking at. From most prominent (order 0) to opposite (order 5, or -1)
|
where entity is looking at. From most prominent (order 0) to opposite (order 5, or -1).
|
||||||
|
|
||||||
### `query(e, 'trace', reach?, options?...)`
|
### `query(e, 'trace', reach?, options?...)`
|
||||||
|
|
||||||
Returns the result of ray tracing from entity perspective, indicating what it is looking at. Default reach is 4.5
|
Returns the result of ray tracing from entity perspective, indicating what it is looking at. Default reach is 4.5
|
||||||
blocks (5 for creative players), and by default it traces for blocks and entities, identical to player attack tracing
|
blocks (5 for creative players), and by default it traces for blocks and entities, identical to player attack tracing
|
||||||
action. This can be customized with `options`, use 'blocks' to trace for blocks, 'liquids' to include liquid blocks
|
action. This can be customized with `options`, use `'blocks'` to trace for blocks, `'liquids'` to include liquid blocks
|
||||||
as possible results, and 'entities' to trace entities. Any combination of the above is possible. When tracing
|
as possible results, and `'entities'` to trace entities. You can also specify `'exact'` which returns the actual hit
|
||||||
|
coordinate as a triple, instead of a block or entity value. Any combination of the above is possible. When tracing
|
||||||
entities and blocks, blocks will take over the priority even if transparent or non-colliding
|
entities and blocks, blocks will take over the priority even if transparent or non-colliding
|
||||||
(aka fighting chickens in tall grass).
|
(aka fighting chickens in tall grass).
|
||||||
|
|
||||||
Regardless of the options selected, the result could be `null` if nothing is in reach, entity, if look targets an
|
Regardless of the options selected, the result could be:
|
||||||
entity, and block value if block is in reach.
|
- `null` if nothing is in reach
|
||||||
|
- an entity if look targets an entity
|
||||||
|
- block value if block is in reach, or
|
||||||
|
- a coordinate triple if `'exact'` option was used and hit was successful.
|
||||||
|
|
||||||
### `query(e, 'brain', memory)`
|
### `query(e, 'brain', memory)`
|
||||||
|
|
||||||
@@ -2957,7 +2966,7 @@ type objects via `get, put, has, delete`, so try to use API calls first for that
|
|||||||
Like with entity querying, entity modifications happen through one function. Most position and movements modifications
|
Like with entity querying, entity modifications happen through one function. Most position and movements modifications
|
||||||
don't work currently on players as their position is controlled by clients.
|
don't work currently on players as their position is controlled by clients.
|
||||||
|
|
||||||
Currently there is no ability to modify NBT directly, but you could always use `run('data modify entity ...')`
|
Currently there is no ability to modify NBT directly, but you could always use `run('data modify entity ...')`.
|
||||||
|
|
||||||
### `modify(e, 'remove')`
|
### `modify(e, 'remove')`
|
||||||
|
|
||||||
@@ -2977,7 +2986,7 @@ Changes full location vector all at once.
|
|||||||
|
|
||||||
### `modify(e, 'x', x), modify(e, 'y', y), modify(e, 'z', z)`
|
### `modify(e, 'x', x), modify(e, 'y', y), modify(e, 'z', z)`
|
||||||
|
|
||||||
Moves the entity in one direction.
|
Changes entity's location in the specified direction.
|
||||||
|
|
||||||
### `modify(e, 'pitch', pitch), modify(e, 'yaw', yaw)`
|
### `modify(e, 'pitch', pitch), modify(e, 'yaw', yaw)`
|
||||||
|
|
||||||
@@ -3099,7 +3108,7 @@ a permanent effect. Use `'jump'` to make an entity jump once for sure.
|
|||||||
|
|
||||||
Requires a living entity as an argument.
|
Requires a living entity as an argument.
|
||||||
|
|
||||||
### `modify(e, 'jump'))`
|
### `modify(e, 'jump')`
|
||||||
|
|
||||||
Will make the entity jump once.
|
Will make the entity jump once.
|
||||||
|
|
||||||
@@ -3127,23 +3136,23 @@ Modifies entity air
|
|||||||
|
|
||||||
### `modify(e, 'add_exhaustion', value)`
|
### `modify(e, 'add_exhaustion', value)`
|
||||||
|
|
||||||
adds exhaustion value to the current player exhaustion level - that's the method you probably want to use
|
Adds exhaustion value to the current player exhaustion level - that's the method you probably want to use
|
||||||
to manipulate how much 'food' some action cost.
|
to manipulate how much 'food' an action costs.
|
||||||
|
|
||||||
### `modify(e, 'breaking_progress', value)`
|
### `modify(e, 'breaking_progress', value)`
|
||||||
|
|
||||||
Modifies a breaking progress of a player currently mined block. Value of `null`, `-1` make it reset.
|
Modifies the breaking progress of a player currently mined block. Value of `null`, `-1` makes it reset.
|
||||||
Values `0` to `10` will show respective animation of a breaking block. Check `query(e, 'breaking_progress')` for
|
Values `0` to `10` will show respective animation of a breaking block. Check `query(e, 'breaking_progress')` for
|
||||||
examples.
|
examples.
|
||||||
|
|
||||||
### `modify(e, 'nbt_merge', partial_tag)`
|
### `modify(e, 'nbt_merge', partial_tag)`
|
||||||
|
|
||||||
Merges a partial tag into the entity data and reloads the entity from its updated tag. Cannot be applied to players
|
Merges a partial tag into the entity data and reloads the entity from its updated tag. Cannot be applied to players.
|
||||||
|
|
||||||
### `modify(e, 'nbt', tag)`
|
### `modify(e, 'nbt', tag)`
|
||||||
|
|
||||||
Reloads the entity from a supplied tag. Better get a valid entity tag, what can go wrong. Wonder what would happen if
|
Reloads the entity from a supplied tag. Better use a valid entity tag, what can go wrong? Wonder what would happen if you
|
||||||
transplant rabbit's brain into a villager. Cannot be applied to players.
|
transplant rabbit's brain into a villager? Cannot be applied to players.
|
||||||
|
|
||||||
## Entity Events
|
## Entity Events
|
||||||
|
|
||||||
@@ -3151,9 +3160,9 @@ There is a number of events that happen to entities that you can attach your own
|
|||||||
The event handler is any function that runs in your package that accepts certain expected parameters, which you can
|
The event handler is any function that runs in your package that accepts certain expected parameters, which you can
|
||||||
expand with your own arguments. When it comes to the moment when the given command needs to be executed, it does so
|
expand with your own arguments. When it comes to the moment when the given command needs to be executed, it does so
|
||||||
providing that number of arguments it accepts is equal number of event arguments, and extra arguments passed when
|
providing that number of arguments it accepts is equal number of event arguments, and extra arguments passed when
|
||||||
defining the callback with `entity_event`
|
defining the callback with `entity_event`.
|
||||||
|
|
||||||
The following events can be handled by entities.
|
The following events can be handled by entities:
|
||||||
|
|
||||||
* `'on_tick'`: executes every tick right before the entity is ticked in the game. Required arguments: `entity`
|
* `'on_tick'`: executes every tick right before the entity is ticked in the game. Required arguments: `entity`
|
||||||
* `'on_death'`: executes once when a living entity dies. Required arguments: `entity, reason`
|
* `'on_death'`: executes once when a living entity dies. Required arguments: `entity, reason`
|
||||||
@@ -3162,7 +3171,7 @@ The following events can be handled by entities.
|
|||||||
Required arguments: `entity, amount, source, attacking_entity`
|
Required arguments: `entity, amount, source, attacking_entity`
|
||||||
|
|
||||||
It doesn't mean that all entity types will have a chance to execute a given event, but entities will not error
|
It doesn't mean that all entity types will have a chance to execute a given event, but entities will not error
|
||||||
when you attach inapplicable event to it.
|
when you attach an inapplicable event to it.
|
||||||
|
|
||||||
### `entity_event(e, event, call_name, args...)`
|
### `entity_event(e, event, call_name, args...)`
|
||||||
|
|
||||||
@@ -3186,7 +3195,7 @@ __on_player_interacts_with_entity(player, entity, hand) ->
|
|||||||
)
|
)
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
In this case this will protect a villager from entity damage (zombies, etc.) except players by granting all the
|
In this case this will protect a villager from entity damage (zombies, etc.) except from players by granting all the
|
||||||
health back to the villager after being harmed.
|
health back to the villager after being harmed.
|
||||||
# Inventory and Items API
|
# Inventory and Items API
|
||||||
|
|
||||||
|
|||||||
@@ -3403,25 +3403,25 @@ public class CarpetExpression
|
|||||||
|
|
||||||
Value res;
|
Value res;
|
||||||
|
|
||||||
if(lv.size()==1){
|
if(lv.size()==1)
|
||||||
|
{
|
||||||
res = lv.get(0).evalValue(c);
|
res = lv.get(0).evalValue(c);
|
||||||
CarpetSettings.LOG.info(res.getString());
|
CarpetSettings.LOG.info(res.getString());
|
||||||
}
|
}
|
||||||
else if(lv.size()==2){
|
else if(lv.size()==2)
|
||||||
String level = lv.get(0).evalValue(c).toString();
|
{
|
||||||
|
String level = lv.get(0).evalValue(c).getString().toLowerCase(Locale.ROOT);
|
||||||
res = lv.get(1).evalValue(c);
|
res = lv.get(1).evalValue(c);
|
||||||
|
|
||||||
switch(level){
|
switch(level){
|
||||||
case "error":CarpetSettings.LOG.error(res.getString()); break;
|
case "error": CarpetSettings.LOG.error(res.getString()); break;
|
||||||
case "warn":CarpetSettings.LOG.warn(res.getString()); break;
|
case "warn": CarpetSettings.LOG.warn(res.getString()); break;
|
||||||
case "debug":CarpetSettings.LOG.debug(res.getString()); break;
|
case "debug": CarpetSettings.LOG.debug(res.getString()); break;
|
||||||
case "fatal":CarpetSettings.LOG.fatal(res.getString()); break;
|
case "fatal": CarpetSettings.LOG.fatal(res.getString()); break;
|
||||||
case "info":CarpetSettings.LOG.info(res.getString()); break;
|
case "info": CarpetSettings.LOG.info(res.getString()); break;
|
||||||
default: throw new InternalExpressionException("Unknown error type: "+level);
|
default: throw new InternalExpressionException("Unknown log level for 'logger': "+level);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else throw new InternalExpressionException("logger takes 1 or 2 arguments");
|
||||||
else throw new InternalExpressionException("logger only takes 1 or 2 arguments");
|
|
||||||
|
|
||||||
return (_c, _t) -> res; // pass through for variables
|
return (_c, _t) -> res; // pass through for variables
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -343,7 +343,7 @@ public class EntityValue extends Value
|
|||||||
put("sneaking", (e, a) -> e.isSneaking()?Value.TRUE:Value.FALSE);
|
put("sneaking", (e, a) -> e.isSneaking()?Value.TRUE:Value.FALSE);
|
||||||
put("sprinting", (e, a) -> e.isSprinting()?Value.TRUE:Value.FALSE);
|
put("sprinting", (e, a) -> e.isSprinting()?Value.TRUE:Value.FALSE);
|
||||||
put("swimming", (e, a) -> e.isSwimming()?Value.TRUE:Value.FALSE);
|
put("swimming", (e, a) -> e.isSwimming()?Value.TRUE:Value.FALSE);
|
||||||
put("air", (e, a) -> return new NumericValue(e.getAir()));
|
put("air", (e, a) -> new NumericValue(e.getAir()));
|
||||||
put("persistence", (e, a) -> {
|
put("persistence", (e, a) -> {
|
||||||
if (e instanceof MobEntity) return new NumericValue(((MobEntity) e).isPersistent());
|
if (e instanceof MobEntity) return new NumericValue(((MobEntity) e).isPersistent());
|
||||||
return Value.NULL;
|
return Value.NULL;
|
||||||
@@ -1108,7 +1108,7 @@ public class EntityValue extends Value
|
|||||||
if(e instanceof PlayerEntity) ((PlayerEntity) e).getHungerManager().setSaturationLevelClient((float)NumericValue.asNumber(v).getLong());
|
if(e instanceof PlayerEntity) ((PlayerEntity) e).getHungerManager().setSaturationLevelClient((float)NumericValue.asNumber(v).getLong());
|
||||||
});
|
});
|
||||||
|
|
||||||
put("air", (e, v) -> e.setAir(NumericValue.asNumber(v).getLong()));
|
put("air", (e, v) -> e.setAir(NumericValue.asNumber(v).getInt()));
|
||||||
|
|
||||||
put("breaking_progress", (e, a) -> {
|
put("breaking_progress", (e, a) -> {
|
||||||
if (e instanceof ServerPlayerEntity)
|
if (e instanceof ServerPlayerEntity)
|
||||||
|
|||||||
Reference in new issue
Block a user