added view_distance to API

This commit is contained in:
gnembon committed 2020-06-02 18:44:23 -03:00
1 parent 681d6ec9ee
commit a7cd2c49cc
5 files changed
+14 -1

No files matched your search

+3
View File
@@ -3351,6 +3351,9 @@ Evaluates the expression `expr` with different dimension execution context. `smt
world-localized block, so not `block('stone')`, or a string representing a dimension like:
`'nether'`, `'the_nether'`, `'end'` or `'overworld'`, etc.
### `view_distance()`
Returns the view distance of the server.
### `schedule(delay, function, args...)`
Schedules a user defined function to run with a specified `delay` ticks of delay. Scheduled functions run at the end
+3
View File
@@ -259,6 +259,9 @@ Evaluates the expression `expr` with different dimension execution context. `smt
world-localized block, so not `block('stone')`, or a string representing a dimension like:
`'nether'`, `'the_nether'`, `'end'` or `'overworld'`, etc.
### `view_distance()`
Returns the view distance of the server.
### `schedule(delay, function, args...)`
Schedules a user defined function to run with a specified `delay` ticks of delay. Scheduled functions run at the end
@@ -102,6 +102,7 @@ ticks_randomly
top
transparent
update
view_distance
volume
without_updates
world_time
@@ -68,7 +68,7 @@
format logger sound particle particle_line particle_rect
run save tick_time world_time day_time last_tick_times game_tick seed current_dimension in_dimension
run save tick_time world_time day_time last_tick_times game_tick seed current_dimension in_dimension view_distance
plop harvest destroy schedule nbt draw_shape create_marker remove_all_markers
@@ -2968,6 +2968,12 @@ public class CarpetExpression
return (cc, tt) -> retval;
});
this.expr.addLazyFunction("view_distance", 0, (c, t, lv) -> {
ServerCommandSource s = ((CarpetContext)c).s;
Value retval = new NumericValue(s.getMinecraftServer().getPlayerManager().getViewDistance());
return (cc, tt) -> retval;
});
this.expr.addLazyFunction("in_dimension", 2, (c, t, lv) -> {
ServerCommandSource outerSource = ((CarpetContext)c).s;
Value dimensionValue = lv.get(0).evalValue(c);