Merge docs for 'Carpet Mod 1.4.29 for Minecraft 1.16.5 and Minecraft 21w10a'
This commit is contained in:
1 parent
4e168626dd
commit
4dbe6ca41d
1 file changed
+266
-82
+266
-82
@@ -296,8 +296,8 @@ For more information, see: [EvalEx GitHub repository](https://github.com/uklimas
|
|||||||
`scarpet` provides a number of constants that can be used literally in scripts
|
`scarpet` provides a number of constants that can be used literally in scripts
|
||||||
|
|
||||||
* `null`: nothing, zilch, not even false
|
* `null`: nothing, zilch, not even false
|
||||||
* `true`: pure true, or just 1 (one)
|
* `true`: pure true, can act as `1`
|
||||||
* `false`: false truth, or true falsth, 0 (zero) actually
|
* `false`: false truth, or true falsth, equals to `0`
|
||||||
* `pi`: for the fans of perimeters, its a perimeter of an apple pi of diameter 1\. About 3.14
|
* `pi`: for the fans of perimeters, its a perimeter of an apple pi of diameter 1\. About 3.14
|
||||||
* `euler`: clever guy. Derivative of its exponent is goto 1\. About 2.72
|
* `euler`: clever guy. Derivative of its exponent is goto 1\. About 2.72
|
||||||
|
|
||||||
@@ -343,7 +343,7 @@ in [User Defined Functions and Program Control Flow](docs/scarpet/language/Funct
|
|||||||
1357-5 => 1352
|
1357-5 => 1352
|
||||||
1357-'5' => 137
|
1357-'5' => 137
|
||||||
3*'foo'-'o' => 'fff'
|
3*'foo'-'o' => 'fff'
|
||||||
l(1,3,5)+7 => l(8,10,12)
|
[1,3,5]+7 => [8,10,12]
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
As you can see, values can behave differently when mixed with other types in the same expression.
|
As you can see, values can behave differently when mixed with other types in the same expression.
|
||||||
@@ -403,8 +403,8 @@ In Minecraft API portion `entity ~ feature` is a shortcode for `query(entity,fea
|
|||||||
any extra arguments.
|
any extra arguments.
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
l(1,2,3) ~ 2 => 1
|
[1,2,3] ~ 2 => 1
|
||||||
l(1,2,3) ~ 4 => null
|
[1,2,3] ~ 4 => null
|
||||||
|
|
||||||
'foobar' ~ 'baz' => null
|
'foobar' ~ 'baz' => null
|
||||||
'foobar' ~ '.b' => 'ob'
|
'foobar' ~ '.b' => 'ob'
|
||||||
@@ -430,10 +430,10 @@ Or an example to find if a player has specific enchantment on a held axe (either
|
|||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
global_get_enchantment(p, ench) -> (
|
global_get_enchantment(p, ench) -> (
|
||||||
$ for(l('main','offhand'),
|
$ for(['main','offhand'],
|
||||||
$ holds = query(p, 'holds', _);
|
$ holds = query(p, 'holds', _);
|
||||||
$ if( holds,
|
$ if( holds,
|
||||||
$ l(what, count, nbt) = holds;
|
$ [what, count, nbt] = holds;
|
||||||
$ if( what ~ '_axe' && nbt ~ ench,
|
$ if( what ~ '_axe' && nbt ~ ench,
|
||||||
$ lvl = max(lvl, number(nbt ~ '(?<=lvl:)\\d') )
|
$ lvl = max(lvl, number(nbt ~ '(?<=lvl:)\\d') )
|
||||||
$ )
|
$ )
|
||||||
@@ -470,8 +470,8 @@ Examples:
|
|||||||
'foo'*3 => 'foofoofoo'
|
'foo'*3 => 'foofoofoo'
|
||||||
'foofoofoo' / 3 => 'foo'
|
'foofoofoo' / 3 => 'foo'
|
||||||
'foofoofoo'-'o' => 'fff'
|
'foofoofoo'-'o' => 'fff'
|
||||||
l(1,2,3)+1 => l(2,3,4)
|
[1,2,3]+1 => [2,3,4]
|
||||||
b = l(100,63,100); b+l(10,0,10) => l(110,63,110)
|
b = [100,63,100]; b+[10,0,10] => [110,63,110]
|
||||||
{'a' -> 1} + {'b' -> 2} => {'a' -> 1, 'b' -> 2}
|
{'a' -> 1} + {'b' -> 2} => {'a' -> 1, 'b' -> 2}
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
@@ -513,11 +513,12 @@ second operand is not necessary, it won't be evaluated, which means one can use
|
|||||||
case of success returns first positive operand (`||`) or last one (`&&`).
|
case of success returns first positive operand (`||`) or last one (`&&`).
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
true || false => 1
|
true || false => true
|
||||||
null || false => 0
|
null || false => false
|
||||||
null != false || run('kill gnembon') => 1 // gnembon survives
|
false || null => null
|
||||||
null != false && run('kill gnembon') => 0 // when cheats not allowed
|
null != false || run('kill gnembon') // gnembon survives
|
||||||
null != false && run('kill gnembon') => 1 // gnembon dies, cheats allowed
|
null != false && run('kill gnembon') // when cheats not allowed
|
||||||
|
null != false && run('kill gnembon') // gnembon dies, cheats allowed
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
### `Assignment Operators = <> +=`
|
### `Assignment Operators = <> +=`
|
||||||
@@ -531,11 +532,11 @@ require rewriting of the array anyways.
|
|||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
a = 5 => a == 5
|
a = 5 => a == 5
|
||||||
l(a,b,c) = l(3,4,5) => a==3, b==4, c==5
|
[a,b,c] = [3,4,5] => a==3, b==4, c==5
|
||||||
l(minx,maxx) = sort(xi,xj); // minx assumes min(xi, xj) and maxx, max(xi, xj)
|
[minx,maxx] = sort(xi,xj); // minx assumes min(xi, xj) and maxx, max(xi, xj)
|
||||||
l(a,b,c,d,e,f) = l(range(6)); l(a,b,c) <> l(d,e,f); l(a,b,c,d,e,f) => [3,4,5,0,1,2]
|
[a,b,c,d,e,f] = [range(6)]; [a,b,c] <> [d,e,f]; [a,b,c,d,e,f] => [3,4,5,0,1,2]
|
||||||
a = l(1,2,3); a += 4 => [1,2,3,4]
|
a = [1,2,3]; a += 4 => [1,2,3,4]
|
||||||
a = l(1,2,3,4); a = filter(a,_!=2) => [1,3,4]
|
a = [1,2,3,4]; a = filter(a,_!=2) => [1,3,4]
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
### `Unary Operators - +`
|
### `Unary Operators - +`
|
||||||
@@ -553,12 +554,12 @@ Require a number, flips the sign. One way to assert it's a number is by crashing
|
|||||||
flips boolean condition of the expression. Equivalent of `bool(expr)==false`
|
flips boolean condition of the expression. Equivalent of `bool(expr)==false`
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
!true => 0
|
!true => false
|
||||||
!false => 1
|
!false => true
|
||||||
!null => 1
|
!null => true
|
||||||
!5 => 0
|
!5 => false
|
||||||
!l() => 1
|
!l() => true
|
||||||
!l(null) => 0
|
!l(null) => false
|
||||||
</pre>
|
</pre>
|
||||||
# Arithmetic operations
|
# Arithmetic operations
|
||||||
|
|
||||||
@@ -696,30 +697,31 @@ as well as minecraft related concepts like `block`, `entity`, `nbt`, `text`.
|
|||||||
|
|
||||||
### `bool(expr)`
|
### `bool(expr)`
|
||||||
|
|
||||||
Returns a boolean context of the expression. Note that there are no true/false values in scarpet. `true` is
|
Returns a boolean context of the expression.
|
||||||
alias of 1, and `false` is 0\. Bool is also interpreting string values as boolean, which is different from other
|
Bool is also interpreting string values as boolean, which is different from other
|
||||||
places where boolean context can be used. This can be used in places where API functions return string values to
|
places where boolean context can be used. This can be used in places where API functions return string values to
|
||||||
represent binary values
|
represent binary values.
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
bool(pi) => 1
|
bool(pi) => true
|
||||||
bool(false) => 0
|
bool(false) => false
|
||||||
bool('') => 0
|
bool('') => false
|
||||||
bool(l()) => 0
|
bool(l()) => false
|
||||||
bool(l('')) => 1
|
bool(l('')) => true
|
||||||
bool('foo') => 1
|
bool('foo') => true
|
||||||
bool('false') => 0
|
bool('false') => false
|
||||||
bool('nulL') => 0
|
bool('nulL') => false
|
||||||
if('false',1,0) => 1
|
if('false',1,0) => true
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
### `number(expr)`
|
### `number(expr)`
|
||||||
|
|
||||||
Returns a numeric context of the expression. Can be used to read numbers from strings
|
Returns a numeric context of the expression. Can be used to read numbers from strings, or other types
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
number(null) => null
|
number(null) => 0
|
||||||
number(false) => 0
|
number(false) => 0
|
||||||
|
number(true) => 1
|
||||||
number('') => null
|
number('') => null
|
||||||
number('3.14') => 3.14
|
number('3.14') => 3.14
|
||||||
number(l()) => 0
|
number(l()) => 0
|
||||||
@@ -747,15 +749,15 @@ Supported types (with `"%<?>"` syntax):
|
|||||||
* `%%`: '%' character
|
* `%%`: '%' character
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
str(null) => null
|
str(null) => 'null'
|
||||||
str(false) => 0
|
str(false) => 'false'
|
||||||
str('') => null
|
str('') => ''
|
||||||
str('3.14') => 3.14
|
str('3.14') => '3.14'
|
||||||
str(l()) => 0
|
str([]) => '[]'
|
||||||
str(l('')) => 1
|
str(['']) => '[]'
|
||||||
str('foo') => null
|
str('foo') => 'foo'
|
||||||
str('3bar') => null
|
str('3bar') => '3bar'
|
||||||
str(2)+str(2) => 22
|
str(2)+str(2) => '22'
|
||||||
str('pi: %.2f',pi) => 'pi: 3.14'
|
str('pi: %.2f',pi) => 'pi: 3.14'
|
||||||
str('player at: %d %d %d',pos(player())) => 'player at: 567, -2423, 124'
|
str('player at: %d %d %d',pos(player())) => 'player at: 567, -2423, 124'
|
||||||
</pre>
|
</pre>
|
||||||
@@ -916,7 +918,7 @@ same random object. Scarpet keeps track of up to 1024 custom random number gener
|
|||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
map(range(10), floor(rand(10))) => [5, 8, 0, 6, 9, 3, 9, 9, 1, 8]
|
map(range(10), floor(rand(10))) => [5, 8, 0, 6, 9, 3, 9, 9, 1, 8]
|
||||||
map(range(10), bool(rand(2))) => [1, 1, 1, 0, 0, 1, 1, 0, 0, 0]
|
map(range(10), bool(rand(2))) => [false, false, true, false, false, false, true, false, true, false]
|
||||||
map(range(10), str('%.1f',rand(_))) => [0.0, 0.4, 0.6, 1.9, 2.8, 3.8, 5.3, 2.2, 1.6, 5.6]
|
map(range(10), str('%.1f',rand(_))) => [0.0, 0.4, 0.6, 1.9, 2.8, 3.8, 5.3, 2.2, 1.6, 5.6]
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
@@ -1217,12 +1219,12 @@ to `all(list,expr) <=> for(list,expr)==length(list)`. `expr` also receives bound
|
|||||||
and `continue` have no sense and cannot be used inside of `expr` body.
|
and `continue` have no sense and cannot be used inside of `expr` body.
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
all([1,2,3], check_prime(_)) => 1
|
all([1,2,3], check_prime(_)) => true
|
||||||
all(neighbours(x,y,z), _=='stone') => 1 // if all neighbours of [x, y, z] are stone
|
all(neighbours(x,y,z), _=='stone') => true // if all neighbours of [x, y, z] are stone
|
||||||
map(filter(rect(0,4,0,1000,0,1000), l(x,y,z)=pos(_); all(rect(x,y,z,1,0,1),_=='bedrock') ), pos(_) )
|
map(filter(rect(0,4,0,1000,0,1000), [x,y,z]=pos(_); all(rect(x,y,z,1,0,1),_=='bedrock') ), pos(_) )
|
||||||
=> [[-298, 4, -703], [-287, 4, -156], [-269, 4, 104], [242, 4, 250], [-159, 4, 335], [-208, 4, 416], [-510, 4, 546], [376, 4, 806]]
|
=> [[-298, 4, -703], [-287, 4, -156], [-269, 4, 104], [242, 4, 250], [-159, 4, 335], [-208, 4, 416], [-510, 4, 546], [376, 4, 806]]
|
||||||
// find all 3x3 bedrock structures in the top bedrock layer
|
// find all 3x3 bedrock structures in the top bedrock layer
|
||||||
map( filter( rect(0,4,0,1000,1,1000,1000,0,1000), l(x,y,z)=pos(_);
|
map( filter( rect(0,4,0,1000,1,1000,1000,0,1000), [x,y,z]=pos(_);
|
||||||
all(rect(x,y,z,1,0,1),_=='bedrock') && for(rect(x,y-1,z,1,1,1,1,0,1),_=='bedrock')<8),
|
all(rect(x,y,z,1,0,1),_=='bedrock') && for(rect(x,y-1,z,1,1,1,1,0,1),_=='bedrock')<8),
|
||||||
pos(_) ) => [[343, 3, -642], [153, 3, -285], [674, 3, 167], [-710, 3, 398]]
|
pos(_) ) => [[343, 3, -642], [153, 3, -285], [674, 3, 167], [-710, 3, 398]]
|
||||||
// ditto, but requiring at most 7 bedrock block in the 18 blocks below them
|
// ditto, but requiring at most 7 bedrock block in the 18 blocks below them
|
||||||
@@ -1475,15 +1477,73 @@ returns everywhere, but it would often lead to a messy code.
|
|||||||
|
|
||||||
It terminates entire program passing `expr` as the result of the program execution, or null if omitted.
|
It terminates entire program passing `expr` as the result of the program execution, or null if omitted.
|
||||||
|
|
||||||
### `try(expr, catch_expr(_)?) ... throw(value?)`
|
### `try(expr)` `try(expr, user_catch_expr)` `try(expr, type, catch_expr, type?, catch_expr?, ...)`
|
||||||
|
|
||||||
`try` function evaluates expression, and continues further unless `throw` function is called anywhere
|
`try` evaluates expression, allowing capturing exceptions that would be thrown inside `expr` statement. The exceptions can be
|
||||||
inside `expr`. In that case the `catch_expr` is evaluates with `_` set to the argument `throw` was called with.
|
thrown explicitly using `throw()` or internally by scarpet where code is correct but detects illegal state. The 2-argument form
|
||||||
This mechanic accepts skipping thrown value - it throws null instead, and catch expression - then try returns
|
catches only user-thrown exceptions and one argument call `try(expr)` is equivalent to `try(expr, null)`,
|
||||||
null as well This mechanism allows to terminate large portion of a convoluted call stack and continue program
|
or `try(expr, 'user_exception', null)`. If multiple `type-catch` pairs are defined, the execution terminates on the first
|
||||||
execution. There is only one level of exceptions currently in carpet, so if the inner function also defines
|
applicable type for the exception thrown. Therefore, even if the caught exception matches multiple filters, only
|
||||||
the `try` catchment area, it will received the exception first, but it can technically rethrow the value its
|
the first matching block will be executed.
|
||||||
getting for the outer scope. Unhandled throw acts like an exit statement.
|
|
||||||
|
Catch expressions are evaluated with
|
||||||
|
`_` set to the value associated with the exception and `_trace` set to contain details about point of error (token, and line and
|
||||||
|
column positions), call stack and local
|
||||||
|
variables at the time of failure. The `type` will catch any exception of that type and any subtype of this type.
|
||||||
|
|
||||||
|
|
||||||
|
You can use `try` mechanism to exit from large portion of a convoluted call stack and continue program execution, although catching
|
||||||
|
exceptions is typically much more expensive comparing to not throwing them.
|
||||||
|
|
||||||
|
The `try` function allows you to catch some scarpet exceptions for cases covering invalid data, like invalid
|
||||||
|
blocks, biomes, dimensions and other things, that may have been modified by datapacks, resourcepacks or other mods,
|
||||||
|
or when an error is outside of the programmers scope, such as problems when reading or decoding files.
|
||||||
|
|
||||||
|
This is the hierarchy of the exceptions that could be thrown/caught in the with the `try` function:
|
||||||
|
- `exception`: This is the base exception. Catching `'exception'` allows to catch everything that can be caught,
|
||||||
|
but like everywhere else, doing that sounds like a bad idea.
|
||||||
|
- `value_exception`: This is the parent for any exception that occurs due to an
|
||||||
|
incorrect argument value provided to a built-in function
|
||||||
|
- `unknown_item`, `unknown_block`, `unknown_biome`, `unknown_sound`, `unknown_particle`,
|
||||||
|
`unknown_poi_type`, `unknown_dimension`, `unknown_structure`, `unknown_criterion`: Specific
|
||||||
|
errors thrown when a specified internal name does not exist or is invalid.
|
||||||
|
- `io_exception`: This is the parent for any exception that occurs due to an error handling external data.
|
||||||
|
- `nbt_read_error`: Incorrect input NBT file.
|
||||||
|
- `json_read_error`: Incorrect input JSON data.
|
||||||
|
- `user_exception`: Exception thrown by default with `throw` function.
|
||||||
|
|
||||||
|
Synopsis:
|
||||||
|
<pre>
|
||||||
|
inner_call() ->
|
||||||
|
(
|
||||||
|
aaa = 'booyah';
|
||||||
|
try(
|
||||||
|
for (range(10), item_tags('stick'+_*'k'));
|
||||||
|
,
|
||||||
|
print(_trace) // not caught, only catching user_exceptions
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
outer_call() ->
|
||||||
|
(
|
||||||
|
try(
|
||||||
|
inner_call()
|
||||||
|
, 'exception', // catching everything
|
||||||
|
print(_trace)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
</pre>
|
||||||
|
Producing:
|
||||||
|
```
|
||||||
|
{stack: [[<app>, inner_call, 1, 14]], locals: {_a: 0, aaa: booyah, _: 1, _y: 0, _i: 1, _x: 0, _z: 0}, token: [item_tags, 5, 23]}
|
||||||
|
```
|
||||||
|
|
||||||
|
### `throw(value?)`, `throw(type, value)`, `throw(subtype, type, value)`
|
||||||
|
|
||||||
|
Throws an exception that can be caught in a `try` block (see above). If ran without arguments, it will throw a `user_exception`
|
||||||
|
passing `null` as the value to the `catch_expr`. With two arguments you can mimic any other exception type thrown in scarpet.
|
||||||
|
With 3 arguments, you can specify a custom exception acting as a `subtype` of a provided `type`, allowing to customize `try`
|
||||||
|
statements with custom exceptions.
|
||||||
|
|
||||||
### `if(cond, expr, cond?, expr?, ..., default?)`
|
### `if(cond, expr, cond?, expr?, ..., default?)`
|
||||||
|
|
||||||
@@ -1518,12 +1578,12 @@ In case to simplify the access with nested objects, you can add chain of address
|
|||||||
than calling it multiple times. `get(get(foo,a),b)` is equivalent to `get(foo, a, b)`, or `foo:a:b`.
|
than calling it multiple times. `get(get(foo,a),b)` is equivalent to `get(foo, a, b)`, or `foo:a:b`.
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
get(l(range(10)), 5) => 5
|
get([range(10)], 5) => 5
|
||||||
get(l(range(10)), -1) => 9
|
get([range(10)], -1) => 9
|
||||||
get(l(range(10)), 10) => 0
|
get([range(10)], 10) => 0
|
||||||
l(range(10)):93 => 3
|
[range(10)]:93 => 3
|
||||||
get(player() ~ 'nbt', 'Health') => 20 // inefficient way to get player health, use player() ~ 'health' instead
|
get(player() ~ 'nbt', 'Health') => 20 // inefficient way to get player health, use player() ~ 'health' instead
|
||||||
get(m( l('foo',2), l('bar',3), l('baz',4) ), 'bar') => 3
|
get({ 'foo' -> 2, 'bar' -> 3, 'baz' -> 4 }, 'bar') => 3
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
### `has(container, address, ...), has(lvalue)`
|
### `has(container, address, ...), has(lvalue)`
|
||||||
@@ -1595,13 +1655,13 @@ of the existing elements. Use `replace` to remove and replace existing element.
|
|||||||
and merges keys from `value` with the compound tag under the path
|
and merges keys from `value` with the compound tag under the path
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
a = l(1, 2, 3); put(a, 1, 4); a => [1, 4, 3]
|
a = [1, 2, 3]; put(a, 1, 4); a => [1, 4, 3]
|
||||||
a = l(1, 2, 3); put(a, null, 4); a => [1, 2, 3, 4]
|
a = [1, 2, 3]; put(a, null, 4); a => [1, 2, 3, 4]
|
||||||
a = l(1, 2, 3); put(a, 1, 4, 'insert'); a => [1, 4, 2, 3]
|
a = [1, 2, 3]; put(a, 1, 4, 'insert'); a => [1, 4, 2, 3]
|
||||||
a = l(1, 2, 3); put(a, null, l(4, 5, 6), 'extend'); a => [1, 2, 3, 4, 5, 6]
|
a = [1, 2, 3]; put(a, null, [4, 5, 6], 'extend'); a => [1, 2, 3, 4, 5, 6]
|
||||||
a = l(1, 2, 3); put(a, 1, l(4, 5, 6), 'extend'); a => [1, 4, 5, 6, 2, 3]
|
a = [1, 2, 3]; put(a, 1, [4, 5, 6], 'extend'); a => [1, 4, 5, 6, 2, 3]
|
||||||
a = l(l(0,0,0),l(0,0,0),l(0,0,0)); put(a.1, 1, 1); a => [[0, 0, 0], [0, 1, 0], [0, 0, 0]]
|
a = [[0,0,0],[0,0,0],[0,0,0]]; put(a:1, 1, 1); a => [[0, 0, 0], [0, 1, 0], [0, 0, 0]]
|
||||||
a = m(1,2,3,4); put(a, 5, null); a => {1: null, 2: null, 3: null, 4: null, 5: null}
|
a = {1,2,3,4}; put(a, 5, null); a => {1: null, 2: null, 3: null, 4: null, 5: null}
|
||||||
tag = nbt('{}'); put(tag, 'BlockData.Properties', '[1,2,3,4]'); tag => {BlockData:{Properties:[1,2,3,4]}}
|
tag = nbt('{}'); put(tag, 'BlockData.Properties', '[1,2,3,4]'); tag => {BlockData:{Properties:[1,2,3,4]}}
|
||||||
tag = nbt('{a:[{lvl:3},{lvl:5},{lvl:2}]}'); put(tag, 'a[].lvl', 1); tag => {a:[{lvl:1},{lvl:1},{lvl:1}]}
|
tag = nbt('{a:[{lvl:3},{lvl:5},{lvl:2}]}'); put(tag, 'a[].lvl', 1); tag => {a:[{lvl:1},{lvl:1},{lvl:1}]}
|
||||||
tag = nbt('{a:[{lvl:[1,2,3]},{lvl:[3,2,1]},{lvl:[4,5,6]}]}'); put(tag, 'a[].lvl', 1, 2); tag
|
tag = nbt('{a:[{lvl:[1,2,3]},{lvl:[3,2,1]},{lvl:[4,5,6]}]}'); put(tag, 'a[].lvl', 1, 2); tag
|
||||||
@@ -1682,10 +1742,10 @@ other parts. In that case consecutive calls to `slice` will refer to index `0` t
|
|||||||
cannot go back nor track where they are in the sequence (see examples).
|
cannot go back nor track where they are in the sequence (see examples).
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
slice([0,1,2,3,4,5], 1, 3) => [1, 2, 3]
|
slice([0,1,2,3,4,5], 1, 3) => [1, 2]
|
||||||
slice('foobar', 0, 1) => 'f'
|
slice('foobar', 0, 1) => 'f'
|
||||||
slice('foobar', 3) => 'bar'
|
slice('foobar', 3) => 'bar'
|
||||||
slice(range(10), 3, 5) => [3, 4, 5]
|
slice(range(10), 3, 5) => [3, 4]
|
||||||
slice(range(10), 5) => [5, 6, 7, 8, 9]
|
slice(range(10), 5) => [5, 6, 7, 8, 9]
|
||||||
r = range(100); [slice(r, 5, 7), slice(r, 1, 3)] => [[5, 6], [8, 9]]
|
r = range(100); [slice(r, 5, 7), slice(r, 1, 3)] => [[5, 6], [8, 9]]
|
||||||
</pre>
|
</pre>
|
||||||
@@ -1720,7 +1780,7 @@ Primarily to be used in higher order functions
|
|||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
range(10) => [...]
|
range(10) => [...]
|
||||||
l(range(10)) => [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
|
[range(10)] => [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
|
||||||
map(range(10),_*_) => [0, 1, 4, 9, 16, 25, 36, 49, 64, 81]
|
map(range(10),_*_) => [0, 1, 4, 9, 16, 25, 36, 49, 64, 81]
|
||||||
reduce(range(10),_a+_, 0) => 45
|
reduce(range(10),_a+_, 0) => 45
|
||||||
range(5,10) => [5, 6, 7, 8, 9]
|
range(5,10) => [5, 6, 7, 8, 9]
|
||||||
@@ -2077,6 +2137,8 @@ when it was used. Block values passed in various places like `scan` functions, e
|
|||||||
its properties are needed. This means that if the block at the location changes before its queried in the program this
|
its properties are needed. This means that if the block at the location changes before its queried in the program this
|
||||||
might result in getting the later state, which might not be desired. Consider the following example:
|
might result in getting the later state, which might not be desired. Consider the following example:
|
||||||
|
|
||||||
|
Throws `unknown_block` if provided input is not valid.
|
||||||
|
|
||||||
<pre>set(10,10,10,'stone');
|
<pre>set(10,10,10,'stone');
|
||||||
scan(10,10,10,0,0,0, b = _);
|
scan(10,10,10,0,0,0, b = _);
|
||||||
set(10,10,10,'air');
|
set(10,10,10,'air');
|
||||||
@@ -2106,6 +2168,8 @@ properties that the original source block may have contained.
|
|||||||
|
|
||||||
The returned value is either the block state that has been set, or `false` if block setting was skipped, or failed
|
The returned value is either the block state that has been set, or `false` if block setting was skipped, or failed
|
||||||
|
|
||||||
|
Throws `unknown_block` if provided block to set is not valid
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
set(0,5,0,'bedrock') => bedrock
|
set(0,5,0,'bedrock') => bedrock
|
||||||
set(l(0,5,0), 'bedrock') => bedrock
|
set(l(0,5,0), 'bedrock') => bedrock
|
||||||
@@ -2184,6 +2248,8 @@ but doesn't open chests / containers, so have no effect on interactive blocks, l
|
|||||||
Returns true if placement/use was
|
Returns true if placement/use was
|
||||||
successful, false otherwise.
|
successful, false otherwise.
|
||||||
|
|
||||||
|
Throws `unknown_item` if `item` doesn't exist
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
place_item('stone',x,y,z) // places a stone block on x,y,z block
|
place_item('stone',x,y,z) // places a stone block on x,y,z block
|
||||||
place_item('piston,x,y,z,'down') // places a piston facing down
|
place_item('piston,x,y,z,'down') // places a piston facing down
|
||||||
@@ -2202,6 +2268,8 @@ If type is `null`, POI at position is removed. In any case, previous POI is also
|
|||||||
Interestingly, `unemployed`, and `nitwit` are not used in the game, meaning, they could be used as permanent spatial
|
Interestingly, `unemployed`, and `nitwit` are not used in the game, meaning, they could be used as permanent spatial
|
||||||
markers for scarpet apps. `meeting` is the only one with increased max occupancy of 32.
|
markers for scarpet apps. `meeting` is the only one with increased max occupancy of 32.
|
||||||
|
|
||||||
|
Throws `unknown_poi` if the provided point of interest doesn't exist
|
||||||
|
|
||||||
### `set_biome(pos, biome_name, update=true)`
|
### `set_biome(pos, biome_name, update=true)`
|
||||||
|
|
||||||
Changes the biome at that block position. if update is specified and false, then chunk will not be refreshed
|
Changes the biome at that block position. if update is specified and false, then chunk will not be refreshed
|
||||||
@@ -2212,6 +2280,8 @@ is only effective if you set it at y=0, and affects the entire column of. In the
|
|||||||
specific Y coordinate of the biome you want to change, and it affects roughly 4x4x4 area (give or take some random
|
specific Y coordinate of the biome you want to change, and it affects roughly 4x4x4 area (give or take some random
|
||||||
noise).
|
noise).
|
||||||
|
|
||||||
|
Throws `unknown_biome` if the `biome_name` doesn't exist.
|
||||||
|
|
||||||
### `update(pos)`
|
### `update(pos)`
|
||||||
|
|
||||||
Causes a block update at position.
|
Causes a block update at position.
|
||||||
@@ -2236,6 +2306,8 @@ In item context, `true` means that breaking item has no nbt to use, `null` indic
|
|||||||
considered broken in process, and `nbt` type value, for a resulting NBT tag on a hypothetical tool. Its up to the
|
considered broken in process, and `nbt` type value, for a resulting NBT tag on a hypothetical tool. Its up to the
|
||||||
programmer to use that nbt to apply it where it belong
|
programmer to use that nbt to apply it where it belong
|
||||||
|
|
||||||
|
Throws `unknown_item` if `tool` doesn't exist.
|
||||||
|
|
||||||
Here is a sample code that can be used to mine blocks using items in player inventory, without using player context
|
Here is a sample code that can be used to mine blocks using items in player inventory, without using player context
|
||||||
for mining. Obviously, in this case the use of `harvest` would be much more applicable:
|
for mining. Obviously, in this case the use of `harvest` would be much more applicable:
|
||||||
|
|
||||||
@@ -2327,6 +2399,8 @@ back in state definition in various applications where block properties are requ
|
|||||||
|
|
||||||
`block_state` can also accept block names as input, returning block's default state.
|
`block_state` can also accept block names as input, returning block's default state.
|
||||||
|
|
||||||
|
Throws `unknown_block` if the provided input is not valid.
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
set(x,y,z,'iron_trapdoor','half','top'); block_state(x,y,z) => {waterlogged: false, half: top, open: false, ...}
|
set(x,y,z,'iron_trapdoor','half','top'); block_state(x,y,z) => {waterlogged: false, half: top, open: false, ...}
|
||||||
set(x,y,z,'iron_trapdoor','half','top'); block_state(x,y,z,'half') => top
|
set(x,y,z,'iron_trapdoor','half','top'); block_state(x,y,z,'half') => top
|
||||||
@@ -2347,6 +2421,8 @@ Without arguments, returns list of available tags, with block supplied (either b
|
|||||||
of tags the block belongs to, and if a tag is specified, returns `null` if tag is invalid, `false` if this block doesn't belong
|
of tags the block belongs to, and if a tag is specified, returns `null` if tag is invalid, `false` if this block doesn't belong
|
||||||
to this tag, and `true` if the block belongs to the tag.
|
to this tag, and `true` if the block belongs to the tag.
|
||||||
|
|
||||||
|
Throws `unknown_block` if `block` doesn't exist
|
||||||
|
|
||||||
### `block_data(pos)`
|
### `block_data(pos)`
|
||||||
|
|
||||||
Return NBT string associated with specific location, or null if the block does not carry block data. Can be currently
|
Return NBT string associated with specific location, or null if the block does not carry block data. Can be currently
|
||||||
@@ -2381,9 +2457,9 @@ poi(x,y,z,5) => [['nether_portal',0,[7,8,9]],['nether_portal',0,[7,9,9]]] // two
|
|||||||
|
|
||||||
Without arguments, returns the list of biomes in the world.
|
Without arguments, returns the list of biomes in the world.
|
||||||
|
|
||||||
With block, or name, returns the name of the biome in that position, or null, if provided biome is not valid.
|
With block, or name, returns the name of the biome in that position, or throws `'unknown_biome'` if provided biome or block are not valid.
|
||||||
|
|
||||||
With an optional feature, it returns value for the specified attribute for that biome. Available and querable features include:
|
With an optional feature, it returns value for the specified attribute for that biome. Available and queryable features include:
|
||||||
* `'top_material'`: unlocalized block representing the top surface material
|
* `'top_material'`: unlocalized block representing the top surface material
|
||||||
* `'under_material'`: unlocalized block representing what sits below topsoil
|
* `'under_material'`: unlocalized block representing what sits below topsoil
|
||||||
* `'category'`: the parent biome this biome is derived from. Possible values include:
|
* `'category'`: the parent biome this biome is derived from. Possible values include:
|
||||||
@@ -2772,6 +2848,7 @@ If structure is not specified, it will return a set of structure names that are
|
|||||||
as keys, and same type of map values as with a single structure call. An empty set or an empty map would indicate that nothing
|
as keys, and same type of map values as with a single structure call. An empty set or an empty map would indicate that nothing
|
||||||
should be generated there.
|
should be generated there.
|
||||||
|
|
||||||
|
Throws `unknown_structure` if structure doesn't exist.
|
||||||
|
|
||||||
### `structures(pos), structures(pos, structure_name)`
|
### `structures(pos), structures(pos, structure_name)`
|
||||||
|
|
||||||
@@ -2805,6 +2882,8 @@ structure starts.
|
|||||||
Requires a `Structure Variant` or `Standard Structure` name (see above). If standard name is used, the variant of the
|
Requires a `Structure Variant` or `Standard Structure` name (see above). If standard name is used, the variant of the
|
||||||
structure may depend on the biome, otherwise the default structure for this type will be generated.
|
structure may depend on the biome, otherwise the default structure for this type will be generated.
|
||||||
|
|
||||||
|
Throws `unknown_structure` if structure doesn't exist.
|
||||||
|
|
||||||
### `plop(pos, what)`
|
### `plop(pos, what)`
|
||||||
|
|
||||||
Plops a structure or a feature at a given `pos`, so block, triple position coordinates or a list of coordinates.
|
Plops a structure or a feature at a given `pos`, so block, triple position coordinates or a list of coordinates.
|
||||||
@@ -2827,7 +2906,9 @@ All generated structures will retain their properties, like mob spawning, howeve
|
|||||||
itself has certain rules to spawn mobs, like plopping a nether fortress in the overworld will not spawn nether mobs,
|
itself has certain rules to spawn mobs, like plopping a nether fortress in the overworld will not spawn nether mobs,
|
||||||
because nether mobs can spawn only in the nether, but plopped in the nether - will behave like a valid nether fortress.
|
because nether mobs can spawn only in the nether, but plopped in the nether - will behave like a valid nether fortress.
|
||||||
|
|
||||||
### `custom_dimension(name, seed?)`
|
### (deprecated) `custom_dimension(name, seed?)`
|
||||||
|
|
||||||
|
Deprecated by `create_datapack()` which can be used to setup custom dimensions
|
||||||
|
|
||||||
Ensures the dimension with the given `'name'` is available and configured with the given seed. It merely sets the world
|
Ensures the dimension with the given `'name'` is available and configured with the given seed. It merely sets the world
|
||||||
generator settings to the overworld, and the optional custom seed (or using current world seed, if not provided).
|
generator settings to the overworld, and the optional custom seed (or using current world seed, if not provided).
|
||||||
@@ -3082,7 +3163,7 @@ Returns `true` if en entity is standing on firm ground and falling down due to t
|
|||||||
|
|
||||||
### `query(e, 'name'), query(e, 'display_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
|
String of entity name or formatted text in the case of `display_name`
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
query(e,'name') => Leatherworker
|
query(e,'name') => Leatherworker
|
||||||
@@ -3808,14 +3889,16 @@ an inventory, all API functions typically do nothing and return null.
|
|||||||
|
|
||||||
Most items returned are in the form of a triple of item name, count, and nbt or the extra data associated with an item.
|
Most items returned are in the form of a triple of item name, count, and nbt or the extra data associated with an item.
|
||||||
|
|
||||||
### item_list(tag?)
|
### `item_list(tag?)`
|
||||||
|
|
||||||
With no arguments, returns a list of all items in the game. With an item tag provided, list items matching the tag, or `null` if tag is not valid.
|
With no arguments, returns a list of all items in the game. With an item tag provided, list items matching the tag, or `null` if tag is not valid.
|
||||||
|
|
||||||
### item_tags(item, tag?)
|
### `item_tags(item, tag?)`
|
||||||
|
|
||||||
Returns list of tags the item belongs to, or, if tag is provided, `true` if an item maches the tag, `false` if it doesn't and `null` if that's not a valid tag
|
Returns list of tags the item belongs to, or, if tag is provided, `true` if an item maches the tag, `false` if it doesn't and `null` if that's not a valid tag
|
||||||
|
|
||||||
|
Throws `unknown_item` if item doesn't exist.
|
||||||
|
|
||||||
### `stack_limit(item)`
|
### `stack_limit(item)`
|
||||||
|
|
||||||
Returns number indicating what is the stack limit for the item. Its typically 1 (non-stackable), 16 (like buckets),
|
Returns number indicating what is the stack limit for the item. Its typically 1 (non-stackable), 16 (like buckets),
|
||||||
@@ -3823,6 +3906,8 @@ or 64 - rest. It is recommended to consult this, as other inventory API function
|
|||||||
it is up to the programmer to keep it at bay. As of 1.13, game checks for negative numbers and setting an item to
|
it is up to the programmer to keep it at bay. As of 1.13, game checks for negative numbers and setting an item to
|
||||||
negative is the same as empty.
|
negative is the same as empty.
|
||||||
|
|
||||||
|
Throws `unknown_item` if item doesn't exist.
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
stack_limit('wooden_axe') => 1
|
stack_limit('wooden_axe') => 1
|
||||||
stack_limit('ender_pearl') => 16
|
stack_limit('ender_pearl') => 16
|
||||||
@@ -3833,6 +3918,8 @@ stack_limit('stone') => 64
|
|||||||
|
|
||||||
Returns the string representing the category of a given item, like `building_blocks`, `combat`, or `tools`.
|
Returns the string representing the category of a given item, like `building_blocks`, `combat`, or `tools`.
|
||||||
|
|
||||||
|
Throws `unknown_item` if item doesn't exist.
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
item_category('wooden_axe') => tools
|
item_category('wooden_axe') => tools
|
||||||
item_category('ender_pearl') => misc
|
item_category('ender_pearl') => misc
|
||||||
@@ -3955,6 +4042,8 @@ while( (slot = inventory_find(p, 'diamond', slot)) != null, 41, drop_item(p, slo
|
|||||||
inventory_drop(x,y,z, 0) => 64 // removed and spawned in the world a full stack of items
|
inventory_drop(x,y,z, 0) => 64 // removed and spawned in the world a full stack of items
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
|
Throws `unknown_item` if item doesn't exist.
|
||||||
|
|
||||||
### `inventory_remove(inventory, item, amount?)`
|
### `inventory_remove(inventory, item, amount?)`
|
||||||
|
|
||||||
Removes amount (defaults to 1) of item from inventory. If the inventory doesn't have the defined amount, nothing
|
Removes amount (defaults to 1) of item from inventory. If the inventory doesn't have the defined amount, nothing
|
||||||
@@ -4357,6 +4446,8 @@ Adds a new objective to scoreboard. If `criterion` is not specified, assumes `'d
|
|||||||
If the objective already exists, changes the criterion of that objective and returns `false`. If the criterion was not specified but the objective already exists, returns the current criterion.
|
If the objective already exists, changes the criterion of that objective and returns `false`. If the criterion was not specified but the objective already exists, returns the current criterion.
|
||||||
If the objective was added, returns `true`. If nothing is affected, returns `null`
|
If the objective was added, returns `true`. If nothing is affected, returns `null`
|
||||||
|
|
||||||
|
Throws `unknown_criterion` if criterion doesn't exist.
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
scoreboard_add('counter')
|
scoreboard_add('counter')
|
||||||
scoreboard_add('lvl','level')
|
scoreboard_add('lvl','level')
|
||||||
@@ -4520,6 +4611,8 @@ Valid mixer options are `master`, `music`, `record`, `weather`, `block`, `hostil
|
|||||||
and `voice`. `pos` can be either a block, triple of coords, or a list of thee numbers. Uses the same options as a
|
and `voice`. `pos` can be either a block, triple of coords, or a list of thee numbers. Uses the same options as a
|
||||||
corresponding `playsound` command.
|
corresponding `playsound` command.
|
||||||
|
|
||||||
|
Throws `unknown_sound` if sound doesn't exist.
|
||||||
|
|
||||||
## Particles
|
## Particles
|
||||||
|
|
||||||
### `particle(name, pos, count?. spread?, speed?, player?)`
|
### `particle(name, pos, count?. spread?, speed?, player?)`
|
||||||
@@ -4529,12 +4622,15 @@ of 0, and to all players nearby, but these options can be changed via optional a
|
|||||||
command on details on those options. Valid particle names are
|
command on details on those options. Valid particle names are
|
||||||
for example `'angry_villager', 'item diamond', 'block stone', 'dust 0.8 0.1 0.1 4'`.
|
for example `'angry_villager', 'item diamond', 'block stone', 'dust 0.8 0.1 0.1 4'`.
|
||||||
|
|
||||||
|
Throws `unknown_particle` if particle doesn't exist.
|
||||||
|
|
||||||
### `particle_line(name, pos, pos2, density?, player?)`
|
### `particle_line(name, pos, pos2, density?, player?)`
|
||||||
|
|
||||||
Renders a line of particles from point `pos` to `pos2` with supplied density (defaults to 1), which indicates how far
|
Renders a line of particles from point `pos` to `pos2` with supplied density (defaults to 1), which indicates how far
|
||||||
apart you would want particles to appear, so `0.1` means one every 10cm. If a player (or player name) is supplied, only
|
apart you would want particles to appear, so `0.1` means one every 10cm. If a player (or player name) is supplied, only
|
||||||
that player will receive particles.
|
that player will receive particles.
|
||||||
|
|
||||||
|
Throws `unknown_particle` if particle doesn't exist.
|
||||||
|
|
||||||
### `particle_box(name, pos, pos2, density?, player?)`
|
### `particle_box(name, pos, pos2, density?, player?)`
|
||||||
### `particle_rect` (deprecated)
|
### `particle_rect` (deprecated)
|
||||||
@@ -4542,6 +4638,8 @@ that player will receive particles.
|
|||||||
Renders a cuboid of particles between points `pos` and `pos2` with supplied density. If a player (or player name) is
|
Renders a cuboid of particles between points `pos` and `pos2` with supplied density. If a player (or player name) is
|
||||||
supplied, only that player will receive particles.
|
supplied, only that player will receive particles.
|
||||||
|
|
||||||
|
Throws `unknown_particle` if particle doesn't exist.
|
||||||
|
|
||||||
## Markers
|
## Markers
|
||||||
|
|
||||||
### `draw_shape(shape, duration, key?, value?, ... )`,
|
### `draw_shape(shape, duration, key?, value?, ... )`,
|
||||||
@@ -4828,6 +4926,10 @@ record to the file. Since files are closed after each write, sending multiple li
|
|||||||
write is beneficial for writing speed. To send multiple packs of data, either provide them flat or as a list in the
|
write is beneficial for writing speed. To send multiple packs of data, either provide them flat or as a list in the
|
||||||
third argument.
|
third argument.
|
||||||
|
|
||||||
|
Throws:
|
||||||
|
- `nbt_read_error`: When failed to read NBT file.
|
||||||
|
- `json_read_error`: When failed to read JSON file. The exception data will contain details about the problem.
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
write_file('foo', 'shared_text, ['one', 'two']);
|
write_file('foo', 'shared_text, ['one', 'two']);
|
||||||
write_file('foo', 'shared_text', 'three\n', 'four\n');
|
write_file('foo', 'shared_text', 'three\n', 'four\n');
|
||||||
@@ -4879,6 +4981,8 @@ specific data directory is under `world/scripts/foo.data/bar/../baz.nbt`, and sh
|
|||||||
|
|
||||||
You can use app data to save non-vanilla information separately from the world and other scripts.
|
You can use app data to save non-vanilla information separately from the world and other scripts.
|
||||||
|
|
||||||
|
Throws `nbt_read_error` if failed to read app data.
|
||||||
|
|
||||||
### `store_app_data(tag)`
|
### `store_app_data(tag)`
|
||||||
|
|
||||||
Note: `store_app_data(tag, file)` and `store_app_data(tag, file, shared?)` usages deprecated. Use `write_file` instead.
|
Note: `store_app_data(tag, file)` and `store_app_data(tag, file, shared?)` usages deprecated. Use `write_file` instead.
|
||||||
@@ -4893,6 +4997,83 @@ Returns `true` if the file was saved successfully, `false` otherwise.
|
|||||||
|
|
||||||
Uses the same file structure for exclusive app data, and shared data folder as `load_app_data`.
|
Uses the same file structure for exclusive app data, and shared data folder as `load_app_data`.
|
||||||
|
|
||||||
|
### `create_datapack(name, data)`
|
||||||
|
|
||||||
|
Creates and loads custom datapack. The data has to be a map representing the file structure and the content of the
|
||||||
|
json files of the target pack.
|
||||||
|
|
||||||
|
Returns `null` if the pack with this name already exists or is loaded, meaning no change has been made.
|
||||||
|
Returns `false` if adding of the datapack wasn't successful.
|
||||||
|
Returns `true` if creation and loading of the datapack was successful. Loading of a datapack results in
|
||||||
|
reloading of all other datapacks (vanilla restrictions, identical to /datapack enable), however unlike with `/reload`
|
||||||
|
command, scarpet apps will not be reloaded by adding a datapack using `create_datapack`.
|
||||||
|
|
||||||
|
Currently, only json files are supported in the packs. `'pack.mcmeta'` file is added automatically.
|
||||||
|
|
||||||
|
Reloading of datapacks that define new dimensions is not implemented in vanilla. Vanilla game only loads
|
||||||
|
dimension information on server start. `create_datapack` is therefore a direct replacement of manually ploping of the specified
|
||||||
|
file structure in a datapack file and calling `/datapack enable` on the new datapack with all its quirks and sideeffects
|
||||||
|
(like no worldgen changes, reloading all other datapacks, etc.). To enable newly added custom dimensions, call much more
|
||||||
|
experimental `check_hidden_dimensions()` after adding a datapack if needed.
|
||||||
|
|
||||||
|
Synopsis:
|
||||||
|
<pre>
|
||||||
|
script run create_datapack('foo',
|
||||||
|
{
|
||||||
|
'foo' -> {
|
||||||
|
'bar.json' -> {
|
||||||
|
'c' -> true,
|
||||||
|
'd' -> false,
|
||||||
|
'e' -> {'foo' -> [1,2,3]},
|
||||||
|
'a' -> 'foobar',
|
||||||
|
'b' -> 5
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
script run create_datapack('funky_world', {
|
||||||
|
'data' -> {
|
||||||
|
'minecraft' -> {
|
||||||
|
'dimension' -> {
|
||||||
|
'custom_ow.json' -> {
|
||||||
|
'type' -> 'minecraft:the_end',
|
||||||
|
'generator' -> {
|
||||||
|
'biome_source' -> {
|
||||||
|
'seed' -> 0,
|
||||||
|
'large_biomes' -> false,
|
||||||
|
'type' -> 'minecraft:vanilla_layered'
|
||||||
|
},
|
||||||
|
'seed' -> 0,
|
||||||
|
'settings' -> 'minecraft:nether',
|
||||||
|
'type' -> 'minecraft:noise'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
check_hidden_dimensions(); => ['funky_world']
|
||||||
|
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
### `enable_hidden_dimensions()`
|
||||||
|
|
||||||
|
The function reads current datapack settings detecting new dimensions defined by these datapacks that have not yet been added
|
||||||
|
to the list of current dimensions and adds them so that they can be used and accessed right away. It doesn't matter how the
|
||||||
|
datapacks have been added to the game, either with 'create_datapack()' or manually by dropping a datapack file and calling
|
||||||
|
`/datapack enable` on it. Returns the list of valid dimension names / identifiers that has been added in the process.
|
||||||
|
|
||||||
|
Fine print: The function should be
|
||||||
|
considered experimental. There 'should not be' (famous last words) any side-effects if no worlds are added. Already connected
|
||||||
|
clients will not see suggestions for commands that use dimensions `/execute in <dim>` (vanilla client limitation)
|
||||||
|
but all commands should work just fine with
|
||||||
|
the new dimensions. Existing worlds that have gotten modified settings by the datapacks will not be reloaded or replaced.
|
||||||
|
The usability of the dimensions added this way has not been fully tested, but it seems it works just fine. Generator settings
|
||||||
|
for the new dimensions will not be added to `'level.dat'` but it will be added there automatically next time the game restarts by
|
||||||
|
vanilla. One could have said to use this method with caution, and the authors take no responsibility of any losses incurred due to
|
||||||
|
mis-handlilng of the temporary added dimensions, yet the feature itself (custom dimensions) is clearly experimental for Mojang
|
||||||
|
themselves, so that's about it.
|
||||||
|
|
||||||
### `tick_time()`
|
### `tick_time()`
|
||||||
|
|
||||||
Returns server tick counter. Can be used to run certain operations every n-th ticks, or to count in-game time.
|
Returns server tick counter. Can be used to run certain operations every n-th ticks, or to count in-game time.
|
||||||
@@ -4956,6 +5137,8 @@ Evaluates the expression `expr` with different dimension execution context. `smt
|
|||||||
world-localized block, so not `block('stone')`, or a string representing a dimension like:
|
world-localized block, so not `block('stone')`, or a string representing a dimension like:
|
||||||
`'nether'`, `'the_nether'`, `'end'` or `'overworld'`, etc.
|
`'nether'`, `'the_nether'`, `'end'` or `'overworld'`, etc.
|
||||||
|
|
||||||
|
Throws `unknown_dimension` if provided dimension can't be found.
|
||||||
|
|
||||||
### `view_distance()`
|
### `view_distance()`
|
||||||
Returns the view distance of the server.
|
Returns the view distance of the server.
|
||||||
|
|
||||||
@@ -5010,6 +5193,7 @@ Available options in the scarpet app space:
|
|||||||
Relevant world related properties
|
Relevant world related properties
|
||||||
* `world_name` - name of the world
|
* `world_name` - name of the world
|
||||||
* `world_seed` - a numeric seed of the world
|
* `world_seed` - a numeric seed of the world
|
||||||
|
* `world_dimensions` - a list of dimensions in the world
|
||||||
* `world_path` - full path to the world saves folder
|
* `world_path` - full path to the world saves folder
|
||||||
* `world_folder` - name of the direct folder in the saves that holds world files
|
* `world_folder` - name of the direct folder in the saves that holds world files
|
||||||
* `world_carpet_rules` - returns all Carpet rules in a map form (`rule`->`value`). Note that the values are always returned as strings, so you can't do boolean comparisons directly. Includes rules from extensions with their namespace (`namespace:rule`->`value`). You can later listen to rule changes with the `on_carpet_rule_changes(rule, newValue)` event.
|
* `world_carpet_rules` - returns all Carpet rules in a map form (`rule`->`value`). Note that the values are always returned as strings, so you can't do boolean comparisons directly. Includes rules from extensions with their namespace (`namespace:rule`->`value`). You can later listen to rule changes with the `on_carpet_rule_changes(rule, newValue)` event.
|
||||||
|
|||||||
Reference in new issue
Block a user