* Updating logger to support different types * changing to ouptut info by default * updating docs with air * adding air modify definition
This commit is contained in:
1 parent
d072e4946a
commit
26169f042e
5 files changed
+63
-14
No files matched your search
+17
-5
@@ -2826,6 +2826,9 @@ Number indicating remaining entity health, or `null` if not applicable.
|
|||||||
|
|
||||||
Retrieves player hunger related information. For non-players, returns `null`.
|
Retrieves player hunger related information. For non-players, returns `null`.
|
||||||
|
|
||||||
|
### `query(e, 'air')`
|
||||||
|
|
||||||
|
Number indicating remaining entity health, or `null` if not applicable.
|
||||||
|
|
||||||
### `query(e, 'holds', slot?)`
|
### `query(e, 'holds', slot?)`
|
||||||
|
|
||||||
@@ -3118,6 +3121,10 @@ Will set entity on fire for `ticks` ticks. Set to 0 to extinguish.
|
|||||||
|
|
||||||
Modifies directly player raw hunger components. Has no effect on non-players
|
Modifies directly player raw hunger components. Has no effect on non-players
|
||||||
|
|
||||||
|
### `modify(e, 'air', ticks)`
|
||||||
|
|
||||||
|
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
|
||||||
@@ -3692,13 +3699,18 @@ Example usages:
|
|||||||
// not a problem in apps
|
// not a problem in apps
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
### `logger(expr)`
|
### `logger(msg), logger(type, msg)`
|
||||||
|
|
||||||
Prints the message to system logs, and not to chat.
|
Prints the message to system logs, and not to chat. By default prints an info, unless you specify otherwise in the `type` parameter.
|
||||||
|
|
||||||
### read_file(resource, type)
|
Available output types:
|
||||||
### delete_file(resource, type)
|
|
||||||
### write_file(resource, type, data, ...)
|
`'debug'`, `'warn'`, `'fatal'`, `'info'` and `'error'`
|
||||||
|
|
||||||
|
|
||||||
|
### `read_file(resource, type)`
|
||||||
|
### `delete_file(resource, type)`
|
||||||
|
### `write_file(resource, type, data, ...)`
|
||||||
|
|
||||||
With the specified `resource` in the scripts folder, of a specific `type`, writes/appends `data` to it, reads its
|
With the specified `resource` in the scripts folder, of a specific `type`, writes/appends `data` to it, reads its
|
||||||
content, or deletes the resource.
|
content, or deletes the resource.
|
||||||
|
|||||||
@@ -245,13 +245,18 @@ Example usages:
|
|||||||
// not a problem in apps
|
// not a problem in apps
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
### `logger(expr)`
|
### `logger(msg), logger(type, msg)`
|
||||||
|
|
||||||
Prints the message to system logs, and not to chat.
|
Prints the message to system logs, and not to chat. By default prints an info, unless you specify otherwise in the `type` parameter.
|
||||||
|
|
||||||
### read_file(resource, type)
|
Available output types:
|
||||||
### delete_file(resource, type)
|
|
||||||
### write_file(resource, type, data, ...)
|
`'debug'`, `'warn'`, `'fatal'`, `'info'` and `'error'`
|
||||||
|
|
||||||
|
|
||||||
|
### `read_file(resource, type)`
|
||||||
|
### `delete_file(resource, type)`
|
||||||
|
### `write_file(resource, type, data, ...)`
|
||||||
|
|
||||||
With the specified `resource` in the scripts folder, of a specific `type`, writes/appends `data` to it, reads its
|
With the specified `resource` in the scripts folder, of a specific `type`, writes/appends `data` to it, reads its
|
||||||
content, or deletes the resource.
|
content, or deletes the resource.
|
||||||
|
|||||||
@@ -361,6 +361,10 @@ Number indicating remaining entity health, or `null` if not applicable.
|
|||||||
|
|
||||||
Retrieves player hunger related information. For non-players, returns `null`.
|
Retrieves player hunger related information. For non-players, returns `null`.
|
||||||
|
|
||||||
|
### `query(e, 'air')`
|
||||||
|
|
||||||
|
Number indicating remaining entity health, or `null` if not applicable.
|
||||||
|
|
||||||
### `query(e, 'holds', slot?)`
|
### `query(e, 'holds', slot?)`
|
||||||
|
|
||||||
Returns triple of short name, stack count, and NBT of item held in `slot`, or `null` if nothing or not applicable. Available options for `slot` are:
|
Returns triple of short name, stack count, and NBT of item held in `slot`, or `null` if nothing or not applicable. Available options for `slot` are:
|
||||||
@@ -654,7 +658,11 @@ Will set entity on fire for `ticks` ticks. Set to 0 to extinguish.
|
|||||||
### `modify(e, 'saturation', value)`
|
### `modify(e, 'saturation', value)`
|
||||||
### `modify(e, 'exhaustion', value)`
|
### `modify(e, 'exhaustion', value)`
|
||||||
|
|
||||||
Modifies player raw hunger components. Has no effect on non-players.
|
Modifies directly player raw hunger components. Has no effect on non-players
|
||||||
|
|
||||||
|
### `modify(e, 'air', ticks)`
|
||||||
|
|
||||||
|
Modifies entity air
|
||||||
|
|
||||||
### `modify(e, 'add_exhaustion', value)`
|
### `modify(e, 'add_exhaustion', value)`
|
||||||
|
|
||||||
|
|||||||
@@ -3381,7 +3381,7 @@ public class CarpetExpression
|
|||||||
return (c_, t_) -> Value.TRUE;
|
return (c_, t_) -> Value.TRUE;
|
||||||
});
|
});
|
||||||
|
|
||||||
this.expr.addLazyFunction("logger", 1, (c, t, lv) ->
|
this.expr.addLazyFunction("logger", -1, (c, t, lv) ->
|
||||||
{
|
{
|
||||||
//CarpetSettings.LOG.error("Standard Structures:");
|
//CarpetSettings.LOG.error("Standard Structures:");
|
||||||
//CarpetSettings.LOG.error(Registry.STRUCTURE_FEATURE.getIds().stream().map(i -> "`'"+NBTSerializableValue.nameFromRegistryId(i)+"'`").sorted(). collect(Collectors.joining(", ")));
|
//CarpetSettings.LOG.error(Registry.STRUCTURE_FEATURE.getIds().stream().map(i -> "`'"+NBTSerializableValue.nameFromRegistryId(i)+"'`").sorted(). collect(Collectors.joining(", ")));
|
||||||
@@ -3399,8 +3399,29 @@ public class CarpetExpression
|
|||||||
//CarpetSettings.LOG.error(FeatureGenerator.featureMap.keySet().stream().map(i -> "`'"+i+"'`").sorted().collect(Collectors.joining(", ")));
|
//CarpetSettings.LOG.error(FeatureGenerator.featureMap.keySet().stream().map(i -> "`'"+i+"'`").sorted().collect(Collectors.joining(", ")));
|
||||||
|
|
||||||
//CarpetSettings.LOG.error(Registry.ENTITY_TYPE.getIds().stream().sorted().map(ValueConversions::simplify).collect(Collectors.joining("`, `")));
|
//CarpetSettings.LOG.error(Registry.ENTITY_TYPE.getIds().stream().sorted().map(ValueConversions::simplify).collect(Collectors.joining("`, `")));
|
||||||
Value res = lv.get(0).evalValue(c);
|
|
||||||
CarpetSettings.LOG.error(res.getString());
|
Value res;
|
||||||
|
|
||||||
|
if(lv.size()==1){
|
||||||
|
res = lv.get(0).evalValue(c);
|
||||||
|
CarpetSettings.LOG.info(res.getString());
|
||||||
|
}
|
||||||
|
else if(lv.size()==2){
|
||||||
|
String level = lv.get(0).evalValue(c).toString();
|
||||||
|
res = lv.get(1).evalValue(c);
|
||||||
|
|
||||||
|
switch(level){
|
||||||
|
case "error":CarpetSettings.LOG.error(res.getString()); break;
|
||||||
|
case "warn":CarpetSettings.LOG.warn(res.getString()); break;
|
||||||
|
case "debug":CarpetSettings.LOG.debug(res.getString()); break;
|
||||||
|
case "fatal":CarpetSettings.LOG.fatal(res.getString()); break;
|
||||||
|
case "info":CarpetSettings.LOG.info(res.getString()); break;
|
||||||
|
default: throw new InternalExpressionException("Unknown error type: "+level);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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,6 +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("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;
|
||||||
@@ -1107,6 +1108,8 @@ 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("breaking_progress", (e, a) -> {
|
put("breaking_progress", (e, a) -> {
|
||||||
if (e instanceof ServerPlayerEntity)
|
if (e instanceof ServerPlayerEntity)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in new issue
Block a user