Skip to content

Prefab Adapter

The Strux Mason

adapter-prefab lets players build with multi-block prefabs — a whole wall, arch, or pillar placed as one piece — and runs each piece through the strux physics engine as a single node.

One placed prefab = one node. Its mass is massPerBlock × block count; its maxLoad is the prefab type's capacity. Two prefabs are connected (a load path) when any of their blocks touch face-to-face.

Grounding and earth anchors

A prefab that sits directly on solid terrain is held up by a hidden earth anchor: an extra ground node placed just below the prefab, exactly how the Minecraft adapter uses bedrock. The prefab itself stays crushable; the anchor is what makes it "grounded".

The anchor lives in the same coordinate space as prefab nodes, so it must never land on top of one. Two rules keep them apart:

  • An anchor is only created where there is no real prefab node. If the cell just below a prefab is already another prefab's node, that neighbour is the support (a normal edge) — no separate anchor is made. This stops one prefab's anchor from aliasing a neighbour's node and later deleting it when the first prefab is removed.
  • A prefab placed exactly onto an existing anchor takes the spot. The old ground node is dropped and replaced by the real, crushable prefab node; anything that was leaning on the anchor re-connects to the new prefab. Without this the prefab would silently become a weightless, indestructible ground node.

Anchors are reference-counted: an anchor is only removed once the last prefab leaning on it is gone.

Capturing prefabs

/prefab capture <name> saves the selected blocks as a new prefab type in prefabs.yml. Names must be flat keys: letters, digits, - and _ only.

A . in a name is rejected. In prefabs.yml a dot is a path separator, so my.house would be written as a nested section (my → house) that the loader can't parse — and because prefabs are reloaded during onEnable, a single bad entry like that used to throw and brick the whole plugin on the next restart. The command now refuses dotted (and other unsafe) names up front.

Loading is resilient

Prefabs are loaded from prefabs.yml when the plugin starts (and on /prefab reload). One bad entry no longer takes everything down: each prefab definition is parsed on its own, and a broken one (missing blocks, an unparseable block line) is skipped with a warning in the log while every good prefab still loads. The plugin always finishes enabling.

Rotation

A prefab can be placed facing north, east, south, or west. Rotating it turns both the block positions and each block's own facing: stairs, logs, doors, fences, and other directional blocks now point the right way after a turn instead of keeping the facing they had when captured. Plain blocks (stone, planks) are unaffected.

Permission

Everything in the prefab plugin is gated by the struxprefab.use permission: the /prefab command (all subcommands) and the build wand (place, remove, rotate). It defaults to true, so on a fresh server everyone can build — but an admin can revoke it (e.g. struxprefab.use: false) and that player can no longer use prefabs, even if they still hold a wand from before.