Navigation: Documentation Home โบ Server Owner Guide โบ Custom Blocks Related: ็ฉๅๆบๅผ็จ.md ยท ๅค้จๆไปถๅฏนๆฅ / ๆนๅๆจกๅไฝ็ฉ.md ยท ่ๆฌๅ ฅ้จ.md
๐งฑ Custom Blocks (CustomBlock) โ
QCL provides a custom block abstraction layer that unifies custom blocks/furniture from different sources (currently CraftEngine) under a single interface, with a built-in fallback mechanismโwhen the backend plugin isn't installed or placement fails, it automatically falls back to a normal block, so no holes are left in the world.
โ ๏ธ This is an advanced / development capability, in most cases driven by sub-plugins or scripts. At the pure server-owner level, there are mainly two things you need to understand:
item_sources(item sources) and the fallback mechanism.
๐ง Concepts โ
QCL's custom blocks consist of several layers:
CustomBlockBridge (aggregation layer)
โโโ CustomBlockProvider (backend, can be multiple)
โโโ CraftEngineBlockProvider (id = craftengine, requires CraftEngine)| Layer | Role |
|---|---|
CustomBlockBridge | The unified outward entry point, aggregating multiple Providers |
CustomBlockProvider | The concrete implementation of a specific backend; there can be multiple |
CraftEngineBlockProvider | Currently the only built-in backend, id = craftengine, depends on the CraftEngine plugin |
In other words: custom block functionality = CraftEngine providing blocks/furniture + QCL's unified wrapping and fallback. When CraftEngine isn't installed, the custom part is unusable, but normal blocks can still be placed via the fallback mechanism.
๐๏ธ CustomBlockConfig Field Table โ
A custom block is parsed from a ConfigurationSection (a YAML config section), with the following fields:
| Key | Type | Default | Description |
|---|---|---|---|
material | Material name | CHEST | Fallback material: the normal block to fall back to when custom placement fails |
custom-model-data | Integer | (unset) | Fallback CMD: takes effect when โฅ 0, attaching custom model data to the fallback item/block |
displayname | String | โ | Display name |
item_sources | List | โ | List of item source references, ordered by priority |
my_block:
displayname: "&bMana Ore"
material: STONE # Fallback material (falls back to stone when CraftEngine is unavailable)
custom-model-data: 10001 # Fallback CMD, only takes effect when โฅ0
item_sources: # Priority from top to bottom
- craftengine-myaddon_mana_ore
- STONE๐ Relationship Between item_sources and Unified Item Sources โ
item_sources uses exactly QCL's unified item source references (see ็ฉๅๆบๅผ็จ.md for details). In the list, entries higher up have higher priority.
The syntax for a CraftEngine source is:
craftengine-namespace_idParsing rule: after the
craftengine-prefix, the first underscore_is converted to a colon:, thereby corresponding to CraftEngine'snamespace:id.Example:
craftengine-myaddon_mana_oreโ CraftEngine'smyaddon:mana_ore(note that only the first underscore is converted; subsequent_are preserved).
๐ฏ Placement Priority and Fallback Mechanism โ
The logic of place() (placement) tries each source in item_sources order, one by one:
For each source in item_sources (in order):
โโ If the source starts with craftengine-:
โ 1) First try "furniture placement"
โ 2) If furniture fails โ then try "block placement"
โโ If both fail โ continue to the next source
If all sources fail:
โโ Place a normal block using material (fallbackMaterial) (fallback)| Stage | Behavior |
|---|---|
1๏ธโฃ Iterate over item_sources | Try each one by priority |
| 2๏ธโฃ CraftEngine source | Try furniture first, then block if it fails |
| 3๏ธโฃ All fail | Fall back to placing a normal block with material + (optional) custom-model-data |
This way, even if CraftEngine isn't installed or a custom block id is mistyped, the world will only turn into a normal block of the "fallback material", rather than throwing an error or leaving a gapโthat's the point of the fallback mechanism.
๐ช Furniture vs Block โ
Custom content in CraftEngine comes in two forms, and QCL tries furniture first, then block when placing:
| Form | Description | Try Order |
|---|---|---|
| Furniture | Decoration/model in entity form | Tried first |
| Block | A real block | Tried after furniture fails |
For the same craftengine-xxx source, QCL automatically tries both, so you don't need to care whether it's furniture or a block.
๐งฐ Capability Overview โ
The custom block object (at the development/script level) provides these capabilities:
| Capability | Method | Description |
|---|---|---|
| Get item | getItem(amount) | Retrieve the corresponding item by item_sources priority |
| Place | place(location) | Place at the specified location (with the fallback logic above) |
| Identify | isThis(block/entity) | Determine whether a block or entity is "this" custom block |
| Remove | remove(block/entity) | Remove the custom block |
These four capabilities (get / place / identify / remove) are usually called by sub-plugins or scripts. Server owners generally use them indirectly through configs provided by sub-plugins.
๐ YAML Example Skeletons โ
Single CraftEngine source + fallback โ
mana_ore:
displayname: "&bMana Ore"
material: STONE # Falls back to stone when CraftEngine is unavailable
custom-model-data: -1 # <0 has no effect; set โฅ0 if you want a fallback model
item_sources:
- craftengine-myaddon_mana_ore # โ myaddon:mana_oreMulti-source fallback (prefer custom, fall back to normal) โ
magic_chest:
displayname: "&dMagic Chest"
material: CHEST # Final last-resort material
custom-model-data: 20001
item_sources: # Priority from top to bottom
- craftengine-myaddon_magic_chest # โ First choice: CraftEngine custom
- craftengine-coreaddon_fancy_box # โก Second choice: another custom
- CHEST # โข Fall back: a normal chestThe parsing logic tries from top to bottom: if โ fails, try โก; if โก fails, try โข; only if โข also fails does it fall back to
material(CHEST).
๐ Notes โ
- ๐ Depends on CraftEngine: custom forms (furniture/block) require CraftEngine installed to place properly; otherwise everything goes through fallback.
- ๐งช This is an advanced capability: mostly driven by sub-plugins / scripts; server owners just need to focus on
item_sourcesand fallback. - ๐ Only the first underscore is converted to a colon:
craftengine-a_b_cโa:b_c, don't be misled by multiple underscores. - ๐ป
custom-model-dataonly takes effect whenโฅ 0: a negative value means unset.
โก๏ธ Continue Reading โ
- ็ฉๅๆบๅผ็จ.md โโ the unified item source reference format used by
item_sources(including thecraftengine-prefix rule) - ๅค้จๆไปถๅฏนๆฅ / ๆนๅๆจกๅไฝ็ฉ.md โโ integration details for CraftEngine blocks/furniture/crops
- ่ๆฌๅ ฅ้จ.md โโ driving custom block get / place / identify / remove via scripts