Feature Template Blocks Menu - bh679/dungeon-train-mc GitHub Wiki

Home > Features > Template Blocks Menu

Template Blocks Menu

A world-space editor menu that lists every block used in the current plot and lets you swap one block everywhere — base structure and block-variant candidates alike — with whatever you're holding, while preserving orientation. Built for the "copy a part, reskin it" workflow: duplicate an existing carriage/part template, then reskin every block in one pass instead of hand-editing each position.

Since: v0.387.0 — PR #636

How It Works

Open the menu with the V key (rebindable) or /dungeontrain editor blocks while standing in any editor plot (carriage / part / contents / track). The panel lists one row per block type used anywhere in the plot — icon, name, usage count, and a Swap button — with counts combining base structure blocks and matching block-variant candidates so nothing is double-counted.

  • Click a row's body to preview that block in-world across every variant cell that lists it as a candidate (transient — doesn't touch the sidecar).
  • Click a row's Swap button to replace that block everywhere in the plot with the block currently in your hand:
    • Base structure blocks are mutated in-world directly.
    • Matching block-variant candidates are rewritten in the .variants.json sidecar immediately (no separate save needed for those).
    • Shared orientation properties (facing, half, axis, slab type, etc.) are copied from the old block onto the new one, so the shape stays the same and only the material changes.

Swapped structure blocks are captured by the normal editor Save (fillFromWorld) like any other in-world edit.

Technical Notes

  • Server driver: TemplateBlocksMenuController — resolves the plot via BlockVariantPlot (the same seam the block-variant menu uses), tallies blocks, and performs the orientation-preserving swap via BlockState.getProperties() / hasProperty() / setValue().
  • Three packets (toggle / sync / edit), client world-space menu (state / renderer / raycast / input handler) — the whole client stack mirrors the block-variant menu family's architecture.
  • OP-only (permission level 2), same as every other editor menu.

Related