Overview
TheMappingsFile class provides a powerful API for customizing how blocks and items are converted between Java and Bedrock editions. It uses a JSON-based format with three main components: identifier mappings, state mappings, and type mappings.
Class: MappingsFile
Package:com.hivemc.chunker.mapping
Components
Identifier Mappings
Turn an identifier into another and can introduce or filter based on old_state_values/new_state_values
State Mappings
Groups of states commonly used together (e.g., all stairs)
Type Mappings
Mapping of input values to output values
Loading Mappings
load(File file)
Load a MappingsFile from a JSON file.The input JSON file in the format of a mappings file
The loaded MappingsFile
load(String json)
Load a MappingsFile from a JSON string.The input JSON in the format of a mappings file
The loaded MappingsFile
load(JsonElement jsonElement)
Load a MappingsFile from a JsonElement.The input element in the format of a mappings file
The loaded MappingsFile
Converting Identifiers
convertBlock(Identifier inputBlock)
Convert an input block identifier using this mappings file.The input block identifier to convert
Empty if there is no mapping found, otherwise an output identifier based on the mappings
convertItem(Identifier inputItem, boolean fallback)
Convert an input item identifier using this mappings file.The input item identifier to convert
Whether the block mappings should be tested if the item is not found
Empty if there is no mapping found, otherwise an output identifier based on the mappings
convertItem(Identifier inputItem)
Convert an input item identifier using this mappings file with block mappings as a fallback.The input item identifier to convert
Empty if there is no mapping found, otherwise an output identifier based on the mappings
Accessors
getTypeMappings()
The type mappings lookup used for converting types
getStateMappings()
The state mappings lookup used for converting different groupings of states
getBlockIdentifierLookup()
The block lookup used for converting block identifiers
getItemIdentifierLookup()
The item lookup used for converting item identifiers
Advanced Operations
inverse()
Generate the inverse of the current mapping file, where the current file is A → B, the result is B → A.A copy of the current mappings inverted to allow backwards mapping
toJson() / toJsonString()
Convert the MappingsFile into a JSON representation.The JSON element representation of these mappings
The JSON string representation (pretty-printed) of these mappings
Special States
isSpecialState(String stateName)
Check whether a state is marked as special. Special states are used to hold additional data which should persist through conversion.The state name to check
True if the state begins with
meta: or virtual:meta:- Used to attach additional metadata to a statevirtual:- Used to provide state data which does not have parity and is inferred by Chunker
JSON Format Example
Example which changes wool from orange to red:CLI Integration
Mappings can be provided to the CLI using the--blockMappings parameter:
Programmatic Usage
Integrate custom mappings into the WorldConverter:Custom Block Handler
The constantCUSTOM_BLOCK_HANDLER ("$custom_block") can be used as a special identifier to handle custom (non-vanilla) blocks:
minecraft: namespace.
Best Practices
Use state_list for reusable mappings
Use state_list for reusable mappings
Group similar blocks (like stairs, slabs) that share state transformations into reusable state_lists.
Test with small worlds first
Test with small worlds first
Always test your custom mappings on a small test world before applying to your main world.
Preserve special states
Preserve special states
Special states (meta: and virtual:) are automatically preserved through conversion - use them for custom metadata.
Use inverse() for round-trip testing
Use inverse() for round-trip testing
Generate inverse mappings to verify your mappings work in both directions.
Related APIs
Dimension Mapping
Configure dimension conversion between editions
Pruning Config
Control which world regions to keep or remove