Lua API: Blocks - Unarelith/OpenMiner GitHub Wiki
Attributes
Blocks can have the following attributes:
| Attribute | Type | Description |
|---|---|---|
| id* | string | ID of the block without the "mod:" prefix |
| label* | string | Label of the block |
| on_block_placed | function | Called when the block is placed |
| on_block_activated | function | Called when a player right-click the block |
| on_tick | function | Called every tick |
| harvest_requirements | u8 | Set which tools are more effective |
| hardness | float | Hardness of the block, affects mining speed |
| is_opaque | bool | Whether or not the block let light pass |
| is_light_source | bool | Whether or not the block is a light source |
| is_rotatable | bool | Whether or not the block is rotatable |
| bounding_box | float[6] | Bounding box of the block {x,y,z,w,d,h} |
| draw_type | string | Draw type of the block (see Draw types) |
| item_drop | ItemStack | Item stack that is dropped when the block is broken |
| color_multiplier | u8[4] | Only grayscale colors are affected by this attribute |
NB: Attributes with a * means they're mandatory
Data types
ItemStack is a table composed of:
id(string): item id with the "mod:" prefixamount(u16): amount in the stack
Draw types
The currently allowed draw type values are:
solidxshapeleavesliquidglass
Functions
on_block_placed
Parameters:
pos(vec3): position of the blockworld(World): instance ofServerWorld
on_block_activated
Parameters:
pos(vec3): position of the blockplayer(Player): current playerworld(World): instance of theServerWorldclient(Client): client that activated the blockscreen_width(u16): width of the screenscreen_height(u16): height of the screengui_scale(u8): current scaling setting
on_tick
Parameters:
pos(vec3): position of the blockplayer(Player): current playerchunk(Chunk): current chunkworld(World): instance of theServerWorld