Skip to content

feat(world): add resolve-block-state and set-block-entity-nbt - #19

Open
IndrajeethY wants to merge 2 commits into
Pumpkin-MC:masterfrom
IndrajeethY:plugin-api-block-resolution
Open

feat(world): add resolve-block-state and set-block-entity-nbt#19
IndrajeethY wants to merge 2 commits into
Pumpkin-MC:masterfrom
IndrajeethY:plugin-api-block-resolution

Conversation

@IndrajeethY

Copy link
Copy Markdown

Description

Adds two new functions to the world interface that allow plugins to work with block states and tile entities:

  • resolve-block-state(name, properties) -> option<u16> — resolves a block name (e.g. minecraft:oak_stairs) with optional properties to its numeric state ID. Returns none for unknown blocks, making it safe to use with schematics from different MC versions.

  • set-block-entity-nbt(pos, nbt-data) -> result<_, string> — restores a block entity from raw NBT bytes at a given position. The NBT must contain a valid id field (e.g. minecraft:chest). This enables bulk tile entity placement for operations like schematic pasting.

These were needed for building a litematica schematic paster plugin, but they're general-purpose enough for any plugin that needs to programmatically place blocks with specific states or restore tile entities.

Testing

Tested with a working schematic paster plugin that loads .litematica files, resolves palette entries via resolve-block-state, places blocks with set-block-state, and restores tile entities via set-block-entity-nbt. Verified with multiple schematics of varying complexity.

@IndrajeethY
IndrajeethY force-pushed the plugin-api-block-resolution branch from 9ca9a56 to 67cd3b9 Compare July 17, 2026 20:54
Comment thread v0.1/world.wit

/// Restores a block entity from raw NBT bytes at the given position.
/// The NBT must contain a valid "id" field (e.g. "minecraft:chest").
set-block-entity-nbt: func(pos: block-pos, nbt-data: list<u8>) -> result<_, string>;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would probably be nice to have a get-block-entity-nbt method as well while we're at it

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After reviewing the main PR, the host implementation of the WIT does define a get_block_entity_nbt() method, but it doesn't seem to be present in this PR for the WIT repo. Maybe you forgot to push a commit?

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.

2 participants