Creating a simple block
Filament blocks are defined in data/<namespace>/filament/block/ using a configuration file.
A block definition combines:
- a unique
id - a
blockModelType - resource mappings for models
- optional
propertiesfor hardness etc. - optional
behaviours
Minimal block
JSON
{
"id": "mynamespace:ruby_block",
"blockModelType": "full_block",
"blockResource": {
"models": {
"default": "mynamespace:block/ruby_block"
}
}
}
YAML
id: mynamespace:ruby_block
blockModelType: full_block,
blockResource:
models:
default: mynamespace:block/ruby_block
Behaviours and block states
Block states in Filament are introduced only through explicit behaviours.
If no behaviour is defined:
- the block has no additional state keys
- only the
defaultmodel is used
Example with a behaviour
JSON
{
"id": "mynamespace:lamp_block",
"blockModelType": "full_block",
"behaviours": {
"powerlevel": {}
},
"blockResource": {
"models": {
"powerlevel=0": "mynamespace:block/lamp_off",
"powerlevel=1": "mynamespace:block/lamp_on"
}
}
}
YAML
id: mynamespace:lamp_block
blockModelType: full_block,
behaviours:
powerlevel: {}
blockResource:
models:
powerlevel=0: mynamespace:block/lamp_off
powerlevel=1: mynamespace:block/lamp_on
Summary
ididentifies the block in Filamentbehavioursdefine block-states sources and functionalityblockResourcemaps resulting states to modelsblockModelTypeclient-side block shape and collision, see Block Model Typespropertiesdefine destroyTime and other properties