Quick start
Create a statically supplied module.Module and register content during Load.
On this page
Overview
Create a statically supplied module.Module and register content during Load. This example adds an item and a block with an automatic block item. Assets token and example_block must already exist in the enabled resource stack; the code does not generate a resource pack.
package examplecontent
import (
"context"
"github.com/pulce-core/Pulce/core/content"
"github.com/pulce-core/Pulce/core/module"
)
type Plugin struct{}
func (*Plugin) Descriptor() module.Descriptor {
return module.Descriptor{
Name: "Example", Version: "0.1.0",
Description: "A token and a placeable block",
Authors: []string{"Example"},
}
}
func (*Plugin) Load(ctx module.Context) error {
api, err := module.TypedContent(ctx)
if err != nil {
return err
}
if _, err := api.Items().Register(
content.Item("example:token").
DisplayName("Token").Icon("token").StackSize(16).
Creative(content.Items),
); err != nil {
return err
}
_, err = api.Blocks().Register(
content.Block("example:block").
DisplayName("Example Block").Texture("example_block").
Hardness(1.5).Tool(content.Pickaxe).
DropsSelf().WithItem().Creative(content.Construction),
)
return err
}
func (*Plugin) Start(context.Context) error { return nil }
func (*Plugin) Stop(context.Context) error { return nil }
Supply the module instance to the host from your executable. The module itself neither opens a listener nor depends on the concrete server implementation:
h, err := host.Open(baseDir, &examplecontent.Plugin{})
This is a caller fragment: import host and your package, handle err, close the host and use the executable's normal lifecycle. Importing the module package alone does not activate it. Descriptor.Dependencies names module dependencies; resource requirements are inferred from asset references.
Server configuration
Place the resource pack in <baseDir>/resource_packs/ and enable it in resource_packs.yml:
force_resources: true
resource_stack:
- Example.zip
The filename is an administrator setting. Plugin declarations contain aliases, not filenames or UUIDs. force_resources controls client pack acceptance; it does not create assets or change registrations.
Typed lowering currently supports 898, 1001, 2168, 2169, 2193. Select those client protocols explicitly in server.yml:
bedrock:
protocols: [898, 1001, 2168, 2169, 2193]
Keep the other existing configuration fields. Omitting bedrock.protocols retains the full default provider, including older protocols. Typed content may therefore reject startup on an unsupported protocol: Pulce does not exclude versions automatically. The allowlist is an administrator decision; see multi-version.
Return errors from Load. If a second registration fails after a successful first one and Load returns that error, the module's entire typed batch is discarded. These declarations need neither Verify(*server.Server) nor manual registry checks after host.Open.
Next: items, blocks, resources, complete module example.
Documentation source
Snapshot from Pulce 4fc8a1bb. This page is generated from committed Markdown; code examples are preserved unchanged.