Allow some exceptions to be handled

This commit is contained in:
altrisi committed 2021-02-19 19:54:41 +01:00
1 parent 7029c6b9b9
commit a155494d11
20 files changed
+283 -78

No files matched your search

+21
View File
@@ -21,6 +21,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
might result in getting the later state, which might not be desired. Consider the following example:
Throws `unknown_block` if block from `state` doesn't exist.
<pre>set(10,10,10,'stone');
scan(10,10,10,0,0,0, b = _);
set(10,10,10,'air');
@@ -50,6 +52,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
Throws `unknown_block` if `block` doesn't exist.
<pre>
set(0,5,0,'bedrock') => bedrock
set(l(0,5,0), 'bedrock') => bedrock
@@ -128,6 +132,8 @@ but doesn't open chests / containers, so have no effect on interactive blocks, l
Returns true if placement/use was
successful, false otherwise.
Throws `unknown_item` if `item` doesn't exist
<pre>
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
@@ -146,6 +152,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
markers for scarpet apps. `meeting` is the only one with increased max occupancy of 32.
Throws `unknown_poi_type` if POI type doesn't exist
### `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
@@ -156,6 +164,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
noise).
Throws `unknown_biome` if biome doesn't exist.
### `update(pos)`
Causes a block update at position.
@@ -180,6 +190,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
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
for mining. Obviously, in this case the use of `harvest` would be much more applicable:
@@ -271,6 +283,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.
Throws `unknown_block` if `block` comes from a String and doesn't exist.
<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
@@ -291,6 +305,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
to this tag, and `true` if the block belongs to the tag.
Throws `unknown_block` if `block` comes from a String and doesn't exist
### `block_data(pos)`
Return NBT string associated with specific location, or null if the block does not carry block data. Can be currently
@@ -348,6 +364,8 @@ and values < 0, below sea level.
* `'features'`: list of features that generate in the biome, grouped by generation steps
* `'structures'`: list of structures that generate in the biome.
Throws `unknown_block` if `block` comes from a String and doesn't exist.
### `solid(pos)`
Boolean function, true if the block is solid.
@@ -716,6 +734,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
should be generated there.
Throws `unknown_structure` if structure doesn't exist.
### `structures(pos), structures(pos, structure_name)`
@@ -749,6 +768,8 @@ structure starts.
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.
Throws `unknown_structure` if structure doesn't exist.
### `plop(pos, what)`
Plops a structure or a feature at a given `pos`, so block, triple position coordinates or a list of coordinates.