feat(world): add resolve-block-state and set-block-entity-nbt - #19
Open
IndrajeethY wants to merge 2 commits into
Open
feat(world): add resolve-block-state and set-block-entity-nbt#19IndrajeethY wants to merge 2 commits into
IndrajeethY wants to merge 2 commits into
Conversation
IndrajeethY
force-pushed
the
plugin-api-block-resolution
branch
2 times, most recently
from
July 17, 2026 08:13
c849425 to
c123583
Compare
IndrajeethY
force-pushed
the
plugin-api-block-resolution
branch
from
July 17, 2026 20:54
9ca9a56 to
67cd3b9
Compare
vyPal
reviewed
Aug 8, 2026
|
|
||
| /// 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>; |
Collaborator
There was a problem hiding this comment.
Would probably be nice to have a get-block-entity-nbt method as well while we're at it
Collaborator
There was a problem hiding this comment.
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?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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. Returnsnonefor 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 valididfield (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
.litematicafiles, resolves palette entries viaresolve-block-state, places blocks withset-block-state, and restores tile entities viaset-block-entity-nbt. Verified with multiple schematics of varying complexity.