Migration from legacy ContentRegistrar
The current release is additive.
On this page
Overview
The current release is additive. module.Context.Content() still returns legacy content.ContentRegistrar; its return type has not changed, preserving Context implementations and mocks. The typed entry point has a distinct transitional name:
api, err := module.TypedContent(ctx)
if err != nil {
return err
}
On a host without the optional typed capability, the helper returns an error. It does not fall back to an eager registrar. module.Content(ctx), ctx.ContentV2() and ctx.Resources() are not current APIs.
Migrating an ordinary item/full block
| Legacy concern | Typed declaration / host responsibility |
|---|---|
ItemSpec.Name, MaxCount | content.Item(id).StackSize(n) |
| Raw display-name/icon components | .DisplayName(text).Icon(alias) |
BlockSpec.Hardness, string tool | .Hardness(h).Tool(content.Pickaxe) |
| Full-block geometry/material instances | Defaults + .Texture(alias) |
PlaceableBlock + raw block placer/publisher | .WithItem() or item .Places(blockID) |
item.Stack{...} for self drop | .DropsSelf() |
| ZIP/atlas/model/file checks | Resource catalog validation |
Concrete server Verify | Global validation and publication barrier |
Global slog.Info | ctx.Logger() |
First move semantic declarations into Load, then remove duplicate registration of the generated block item. Supply display names explicitly where needed: omitted labels do not turn into semantic IDs. Select a creative category if the item should appear in creative; the default is hidden. Set gameplay-significant hardness explicitly.
Enabled assets must be available to the host before validation. Move deployment path/UUID checks from the plugin into admin stack configuration. Remove Verify(*server.Server) for these declarations and manual custom-block send switches from the executable. Configure explicitly supported protocols in admin configuration.
Behavior that cannot yet be migrated unchanged
The typed API has no custom hooks, effects/entities registration, durability, multiple/conditional loot, Fortune/Silk Touch behavior, material transparency/per-face overrides or state/permutation API. Existing DefineBlock, DefineItem, BlockSpec, ItemSpec and raw Components remain the legacy API for those consumers.
Do not present legacy .Component or raw Components as typed .RawComponent: the explicit typed advanced escape hatch does not exist yet. Bedrock-specific legacy maps need their own version validation and do not automatically receive semantic lowering stability. External plugins cannot import internal lowering packages; doing so would also violate the architectural boundary.
Mixing typed and legacy calls does not make the whole Load transactional. Typed declarations are staged/discarded as a batch; legacy calls publish eagerly and rely on existing owner cleanup. Final typed validation checks collisions against authoritative legacy content, so registering an ID through both paths fails.
Major target
A planned future major API naturally replaces the accessor with ctx.Content() content.Service and adds ctx.Resources() resources.Service. This is a migration direction, not a current signature or a promised date. Use module.TypedContent(ctx) and module.Resources(ctx) today.
Do not automatically deprecate every effects/entities behavior contract: those consumers still need migration paths. A legacy registrar in a public package does not permit bypassing typed freeze after publication. Existing contracts remain supported today; check source for actual Deprecated: annotations instead of relying on a design proposal.
See ExampleContent for a complete module using the new API. The older Content Builders guide describes the legacy capability and lower-level hooks; start new ordinary content with quick start.
Documentation source
Snapshot from Pulce 4fc8a1bb. This page is generated from committed Markdown; code examples are preserved unchanged.