Pulcedocs

Complete module example

This module adds the item example:token and the block example:stone, including a placeable block item.

On this page

Overview

This module adds the item example:token and the block example:stone, including a placeable block item. It refers to the item texture alias token and the terrain texture alias example_stone.

The names and resource archive below are illustrative. Supply an enabled pack with these aliases; the example does not bundle third-party assets. The complete module is compiler-checked in core/module/example_content_test.go.

package examplecontent

import (
	"context"

	"github.com/pulce-core/Pulce/core/content"
	"github.com/pulce-core/Pulce/core/module"
)

// Plugin is a compile-checked consumer of the typed capability API.
// Load stages declarations. The standard bootstrap publishes and freezes them
// after preparation, before returning an instance that can admit sessions.
type Plugin struct{}

const (
	Token = "example:token"
	Stone = "example:stone"
)

func (*Plugin) Descriptor() module.Descriptor {
	return module.Descriptor{
		Name: "ExampleContent", Version: "0.1.0",
		Description: "Example item and placeable block",
		Authors:     []string{"Example author"},
	}
}

func (*Plugin) Load(ctx module.Context) error {
	api, err := module.TypedContent(ctx)
	if err != nil {
		return err
	}
	if _, err := api.Items().Register(
		content.Item(Token).
			DisplayName("Token").
			Icon("token").
			StackSize(1).
			Creative(content.Items),
	); err != nil {
		return err
	}
	if _, err := api.Blocks().Register(
		content.Block(Stone).
			DisplayName("Example Stone").
			Texture("example_stone").Hardness(.5).
			Tool(content.Pickaxe).DropsSelf().WithItem().
			Creative(content.Construction),
	); err != nil {
		return err
	}
	ctx.Logger().Info("content definitions staged")
	return nil
}

func (*Plugin) Start(context.Context) error { return nil }
func (*Plugin) Stop(context.Context) error  { return nil }

What the host creates

The token stacks to one item and appears in the Items creative category. The block uses a full cube with one opaque texture, explicit hardness 0.5 and a preferred pickaxe. It drops one associated item when broken. That item inherits the block display name, stacks to 64, places the block, uses the block as its icon and appears in Construction.

The module needs no ZIP parser, manifest UUID, raw component maps, direct server registry access or external verification function. Assets are checked from the enabled resource stack.

Deployment and activation

The executable supplies the module to the host:

server, err := host.Open(wd, &examplecontent.Plugin{})

This is a call-site fragment: imports, wd, error handling and closing the host belong to the application.

The administrator enables a pack providing the example textures:

# resource_packs/resource_packs.yml
force_resources: true
resource_stack:
  - example-pack.zip

Select the client protocols supported by typed content:

# server.yml
bedrock:
  protocols: [898, 1001, 2168, 2169, 2193]

The filename is an administrator setting, not a plugin dependency. Changing it or the pack UUID requires no code change if the aliases and assets remain available. Missing or conflicting resources reject startup.

Verification

The example compiles. Content regression tests separately cover registration, resource validation, publication, item granting, placement, breaking, self drops and consistent IDs across protocols. They exercise server and serializer behavior, not a real Minecraft client. The archive name above is illustrative; those tests do not certify a bundled pack with that name.

Before release, verify item icons, block rendering, placement, creative categories, breaking, drops, sounds, particles and reconnects with actual Bedrock clients. Live rendering has not yet been confirmed.

Next: lifecycle, resources, validation, multi-version.

Documentation source

Snapshot from Pulce 4fc8a1bb. This page is generated from committed Markdown; code examples are preserved unchanged.