Blocks and automatic block items
Registration returns (BlockRef, error).
On this page
Overview
_, err := api.Blocks().Register(
content.Block("example:stone").
DisplayName("Example Stone").Texture("stone").
Hardness(0.5).Tool(content.Pickaxe).
DropsSelf().WithItem().Creative(content.Construction),
)
Registration returns (BlockRef, error). WithItem is opt-in: the host creates an associated item with the same textual ID, placement association and default stack limit. Do not register that item separately with RegisterItem: it will collide with the generated item ID.
A block's .DisplayName(...) stores a semantic label inherited by its automatic block item. Current lowering emits no separate block display-name component; without WithItem, this method does not promise a client-visible block name.
Defaults
| Property | Omitted behavior |
|---|---|
| Display name | Not generated automatically |
| Texture | Terrain alias required before publication |
| Geometry | Builtin minecraft:geometry.full_block |
| Render mode | Opaque, one texture for all faces |
| Hardness | Frozen Pulce default mining profile; current engine default 1.0 |
| Preferred tool | None; no harvest requirement |
| Drops | None |
| Block item | Not created |
| Creative | Hidden |
Omitted hardness differs from .Hardness(0): omission resolves through the profile, while zero explicitly selects instant break. .Hardness(0.5) fixes numeric behavior. Values must be finite non-negative float64; lowering also rejects positive values that become zero or overflow when represented as client mining hardness in float32. Negative hardness is not an unbreakable sentinel.
The current profile's number is not permanently fixed in the public semantic definition. Set hardness explicitly when gameplay needs a fixed value. Every enabled protocol receives the same resolved profile; resource packs do not determine server hardness.
.Tool(content.Pickaxe) selects a preferred mining family, not a required pickaxe or minimum tier for obtaining drops. None, Axe, Shovel, Hoe and Shears are also available. Typed harvest restrictions, correct-tool policies and minimum tiers are not implemented.
In the current server mining path, acceleration depends on matching item.Definition.Family to the preferred family, tool tier/efficiency and existing effects/enchantments. Choosing an enum does not promise a dedicated multiplier for every tool: for example, shears without tier-specific metadata retain base speed 1. Hoe and Shears are valid declarations, not guarantees of a separate Bedrock-equivalent mining policy. Check the gameplay behavior you need; see block_mining.go.
Associated item overrides
label := "Stone Item"
limit := 16
category := content.Items
definition := content.Block("example:stone").Texture("stone").
WithItemDefinition(content.BlockItemDefinition{
ID: "example:stone_item", Label: &label, StackLimit: &limit,
IconRef: resources.ItemTexture("stone_icon"),
CreativeCategory: &category,
}).DropsSelf()
_, err := api.Blocks().Register(definition)
An empty item ID inherits the block ID. A nil item label inherits only an explicitly supplied block label; a nil stack limit resolves to 64. Without a custom icon, the item uses block-as-icon. A nil item creative category inherits the block's convenience category; explicit Hidden hides the item. The block menu follows the item's effective category. A block without an item remains hidden even with .Creative(content.Construction).
DropsSelf selects the associated item: this example drops example:stone_item, not the textual block ID. WithItem alone does not enable a self drop.
Drops
.NoDrops() and omission produce no drop. .DropsSelf() requires WithItem or WithItemDefinition; an independent .Places item does not establish the self-item binding. Fixed drops use semantic item IDs:
definition := content.Block("example:ore").Texture("ore").
Drops(content.Drop{Item: "minecraft:diamond", Count: 1})
The reference must exist in the authoritative item graph and its count must be positive. The builder accepts variadic drops, but current normalization supports one fixed output; multiple outputs return ErrUnsupportedFeature. Local Validate checks their shape without promising host support. Mixing .NoDrops() and .DropsSelf() is invalid: conflicting modes return an error. Repeating the same builder mode replaces its declaration rather than accumulating outputs.
Fortune, Silk Touch, conditional drops, loot tables and callback loot integration are outside the current typed MVP.
Geometry and materials
.Geometry("geometry.example_stone") requires a geometry identifier in the enabled resource catalog. .Geometry("") is explicitly invalid; omitted geometry retains the builtin. This is client visual geometry, not a custom collision/selection-box or physics API: the model's shape does not describe server collision. A terrain texture remains required. Plugin authors do not supply geometry file paths.
Per-face textures, material instances, transparent/cutout/alpha-blend selectors, permutations and block states are unavailable through the current typed declarations. Keep raw components out of ordinary declarations; see legacy migration for complex consumers awaiting migration.
Documentation source
Snapshot from Pulce 4fc8a1bb. This page is generated from committed Markdown; code examples are preserved unchanged.