blockupgrader

package
v1.99.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 22, 2026 License: MIT Imports: 9 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterSchema

func RegisterSchema(r io.Reader) error

RegisterSchema attempts to decode and parse a schema from the provided file reader. The file must follow the correct specification otherwise an error will be returned.

Types

type Block

type Block interface {
	// contains filtered or unexported methods
}

Block holds the data that identifies a block. It is implemented by BlockState and BlockMeta.

type BlockMeta

type BlockMeta struct {
	Name     string `nbt:"name"`
	Metadata int16  `nbt:"meta"`
}

BlockMeta holds the name and metadata value (int16) of a block. This format is used by blocks from Minecraft Bedrock Edition versions before v1.13.

type BlockState

type BlockState struct {
	Name       string         `nbt:"name"`
	Properties map[string]any `nbt:"states"`
	Version    int32          `nbt:"version"`
}

BlockState holds the name, properties and version of a block. The name and properties of the same block may differ, depending on the Version.

func Upgrade

func Upgrade(b Block) BlockState

Upgrade upgrades the given block using the registered block state upgrade schemas. If a Block has not been changed through several versions, Upgrade will simply return the original value. Calling blockupgrader.Upgrade is therefore safe regardless of whether the block is already up-to-date or not.

func UpgradeToVersion

func UpgradeToVersion(b Block, targetVersion string) BlockState

UpgradeToVersion upgrades the given block up to targetVersion. If there is no schema for targetVersion, the closest older schema version is used.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL