block_state can accept string block name as well.

This commit is contained in:
gnembon committed 2020-11-27 15:50:57 -04:00
1 parent 07dce7bc2e
commit 6206753198
2 files changed
+5 -2

No files matched your search

+4 -1
View File
@@ -248,15 +248,18 @@ Deprecated by `block_state(pos, name)`
If used with a `block` argument only, it returns a map of block properties and their values. If a block has no properties, returns an
empty map.
If `property` is specified, returns value of that property, or `null` if property is not applicable.
If `property` is specified, returns a string value of that property, or `null` if property is not applicable.
Returned values or properties are always strings. It is expected from the user to know what to expect and convert
values to numbers using `number()` function or booleans using `bool()` function. Returned string values can be directly used
back in state definition in various applications where block properties are required.
`block_state` can also accept block names as input, returning block's default state.
<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,'half') => top
block_state('iron_trapdoor','half') => top
set(x,y,z,'air'); block_state(x,y,z,'half') => null
block_state(block('iron_trapdoor[half=top]'),'half') => top
block_state(block('iron_trapdoor[half=top]'),'powered') => false