Skip to content

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)
LayerRole
CustomBlockBridgeThe unified outward entry point, aggregating multiple Providers
CustomBlockProviderThe concrete implementation of a specific backend; there can be multiple
CraftEngineBlockProviderCurrently 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:

KeyTypeDefaultDescription
materialMaterial nameCHESTFallback material: the normal block to fall back to when custom placement fails
custom-model-dataInteger(unset)Fallback CMD: takes effect when โ‰ฅ 0, attaching custom model data to the fallback item/block
displaynameStringโ€”Display name
item_sourcesListโ€”List of item source references, ordered by priority
yaml
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_id

Parsing rule: after the craftengine- prefix, the first underscore _ is converted to a colon :, thereby corresponding to CraftEngine's namespace:id.

Example: craftengine-myaddon_mana_ore โ†’ CraftEngine's myaddon: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)
StageBehavior
1๏ธโƒฃ Iterate over item_sourcesTry each one by priority
2๏ธโƒฃ CraftEngine sourceTry furniture first, then block if it fails
3๏ธโƒฃ All failFall 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:

FormDescriptionTry Order
FurnitureDecoration/model in entity formTried first
BlockA real blockTried 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:

CapabilityMethodDescription
Get itemgetItem(amount)Retrieve the corresponding item by item_sources priority
Placeplace(location)Place at the specified location (with the fallback logic above)
IdentifyisThis(block/entity)Determine whether a block or entity is "this" custom block
Removeremove(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 โ€‹

yaml
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_ore

Multi-source fallback (prefer custom, fall back to normal) โ€‹

yaml
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 chest

The 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_sources and 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-data only takes effect when โ‰ฅ 0: a negative value means unset.

โžก๏ธ Continue Reading โ€‹