Skip to content

Add SB Worn Display Editor plugin#914

Open
hrmcngs wants to merge 10 commits into
JannisX11:masterfrom
hrmcngs:add-sb-worn-display
Open

Add SB Worn Display Editor plugin#914
hrmcngs wants to merge 10 commits into
JannisX11:masterfrom
hrmcngs:add-sb-worn-display

Conversation

@hrmcngs
Copy link
Copy Markdown

@hrmcngs hrmcngs commented May 30, 2026

What

Adds a new plugin SB Worn Display Editor (id: sb_worn_display) that adds a Custom Slot row to the Display panel, letting users visually edit custom item display contexts defined by Forge mods — using the same sliders as the vanilla head / gui / ground slots.

Currently ships with three keys:

  • sophisticatedbackpacks:worn — Sophisticated Backpacks worn on Curios back slot
  • the_four_primitives_and_weapons:back — MAW saya on Curios back slot
  • the_four_primitives_and_weapons:belt — MAW saya on Curios belt slot

Designed to be trivially extensible to any other custom display key by editing the TARGETS array.

Why

Blockbench's built-in Display panel only supports the 8 vanilla Java display contexts. Custom contexts defined by mods via ItemDisplayContext.create(...) are silently dropped on save because the exporter iterates DisplayMode.slots. This plugin registers the custom keys in DisplayMode.slots (round-trip safe) and injects a new section into the Display panel DOM using Blockbench's own native markup (panel_toolbar_label + bar tabs_small icon_bar + label.tool) so the new row blends visually with the vanilla UI.

Validation

$ npm run validate sb_worn_display
Plugin "sb_worn_display" passed validation with no errors!

Files added

  • plugins/sb_worn_display/sb_worn_display.js — the plugin
  • plugins/sb_worn_display/about.md
  • plugins/sb_worn_display/members.yml
  • plugins/sb_worn_display/LICENSE.MD (MIT)
  • plugins.json — added entry at the end

Source / changelog

Notes

  • variant: both — works on desktop and web
  • min_version: 4.8.0 — uses new-structure format with about.md
  • The plugin uses DOM injection (no official extension point exists for adding to the hardcoded slot row in DisplayModePanel.vue); a MutationObserver re-attaches after Vue re-renders. A numeric Edit dialog under Tools serves as a stable fallback if the injection ever breaks. This trade-off is documented in about.md.

Adds a Custom Slot row to the Display panel so users can edit custom
item display keys (currently sophisticatedbackpacks:worn,
the_four_primitives_and_weapons:back/belt) visually in the 3D
viewport, using the same sliders as the vanilla slots.

Source: https://github.com/hrmcngs/sb-worn-display-blockbench
@hrmcngs hrmcngs force-pushed the add-sb-worn-display branch from 7f6b19b to 4182532 Compare May 31, 2026 09:02
hrmcngs added 5 commits June 1, 2026 20:48
When a custom slot was active and the user switched between project
tabs, DisplayMode.slot kept pointing at the previous project's slot
object. updateDisplayBase then read stale data and the model rendered
floating off-center with the reference model gone.

Fix: on select_project, silently rebind DisplayMode.slot to the new
project's display_settings[key] without resetting the camera or
forcing display mode.
v4.2.2 fixed the value-loss bug by skipping DisplayMode.loadHead() on
project switch, but loadHead is also what re-populates the
reference-model bar (player/zombie/armor_stand). Skipping it caused
the reference figure to vanish after every tab switch.

Now: call loadHead (so the reference bar is correctly re-populated),
but save+restore the camera position/target around it so the user's
viewpoint stays put.
New Tools action "Import display values from another model…" opens
a JSON/bbmodel file, parses its display section, and shows a dialog
where the user picks source slot, target slot, and which fields to
overwrite via 3 independent checkboxes (Rotation / Translation /
Scale). Supports partial replace — e.g. copy only sizing from a
sibling model without touching rotation.
Two new actions, available from both Tools menu and the outliner
right-click context menu (Cube / Group / Mesh):

- Center Model at Origin (Undo-able, modifies geometry): shifts every
  element + group origin so model bbox center is (0,0,0). Display
  rotation then orbits around the model center.
- Center View on Selection (non-destructive): sets active preview's
  camera target to selection bbox center. Works in Edit and Display
  modes.
- fix: Center Model at Origin's Undo entry was incomplete because
  Undo.initEdit was called with {group: [...]} which Blockbench
  doesn't recognize as an array. Switched to {outliner: true} which
  snapshots all group origins. Ctrl/Cmd+Z now reverts in one step.
- add: Center Pivot of Groups — sets each group's origin to its
  children's bbox center, non-destructive. Tools menu + outliner
  right-click menu. Undo-able.
- chg: Center View in outliner ctx menu now references Blockbench's
  built-in focus_on_selection action ('センタービュー' in JP) — 1:1
  with View menu / preview ctx menu behavior. Custom impl removed.
@hrmcngs hrmcngs force-pushed the add-sb-worn-display branch from ccfaf71 to 497dc2a Compare June 2, 2026 04:12
hrmcngs added 4 commits June 2, 2026 19:19
- Import dialog redesigned: one checkbox per TARGETS slot
  (auto-checked when source file contains the key) + shared
  Rotation / Translation / Scale checkboxes. One Confirm now
  overwrites every checked slot × every checked field. v4.3.0 only
  did one slot per Confirm.
- fix: after import, if the active display_slot is among the
  replaced keys, rebind DisplayMode.slot + vue._data.slot +
  $forceUpdate so sliders show the new values immediately.
Bulk-import was Tools-menu only. Add a download-icon button to the
right of the "Custom Slot" label in the Display panel, styled like
Blockbench's native .tool.head_right buttons (e.g. Reset arrow next
to Rotation). Click opens the same dialog as the Tools menu action.
3 channel checkboxes (Rotation/Translation/Scale) split into 9
per-axis checkboxes. Each axis can be toggled independently — copy
just Scale Y from another model without touching anything else, etc.

Combined with the v4.6.0 per-slot checkboxes, the bulk-import dialog
now exposes (3 slots × 9 axes) = 27 independent decisions per
Confirm. Result message reports exactly which axes were written:
'sophisticatedbackpacks:worn ← rotation.XZ + scale.Y'.
Previously the bulk-import dialog only listed the 3 plugin-registered
custom slots. Extended to ALL keys present in source.display:
vanilla (head/gui/ground/firstperson_*/thirdperson_*/fixed/on_shelf/
embedded) + custom + any other namespaced keys.

Keys ordered vanilla → custom → other; each tagged in the dialog.
All default checked = still works as one-click "import everything".
Per-axis 9-checkbox partial replace (v4.7.0) applies uniformly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant