Skip to main content

Overview

Block identifier resolvers handle the conversion of block identifiers between Minecraft’s Java and Bedrock editions and Chunker’s intermediate format. These resolvers manage block states, properties, and format-specific differences like waterlogging.

Base Resolver

ChunkerBlockIdentifierResolver

Abstract base class for converting format-specific identifiers into ChunkerBlockIdentifier.
ChunkerBlockIdentifierResolver
abstract class
Located at: com.hivemc.chunker.conversion.encoding.base.resolver.identifier.ChunkerBlockIdentifierResolver

Constructor

public ChunkerBlockIdentifierResolver(
    Converter converter,
    Version version,
    boolean reader,
    boolean customIdentifiersAllowed
)
converter
Converter
The converter instance
version
Version
The version this resolver handles
reader
boolean
Whether this is the reader (true) or writer (false)
customIdentifiersAllowed
boolean
Whether custom identifiers are processed as custom

Core Methods

to()
Converts a format-specific identifier to a Chunker block identifier.
public Optional<ChunkerBlockIdentifier> to(Identifier input)
input
Identifier
The input identifier from the format (e.g., minecraft:stone)
returns
Optional<ChunkerBlockIdentifier>
The converted Chunker block identifier, or empty if not supported
from()
Converts a Chunker block identifier to a format-specific identifier.
public Optional<Identifier> from(ChunkerBlockIdentifier input)
input
ChunkerBlockIdentifier
The Chunker block identifier
returns
Optional<Identifier>
The format-specific identifier, or empty if not supported
isSupported()
Checks if an identifier can be resolved.
public boolean isSupported(String identifier)
public boolean isSupported(ChunkerBlockType chunkerBlockType)
identifier
String
The input identifier in the format namespace:key
chunkerBlockType
ChunkerBlockType
The block type object (usually ChunkerVanillaBlockType enum entry)
returns
boolean
True if the block can potentially be resolved

Registration Methods

These methods are used during resolver initialization to register block mappings:
register()
Registers a standard block mapping.
protected void register(BlockMapping mapping)
protected void register(BlockMapping[] mappings)
registerDuplicateInput()
Registers a mapping where the input is duplicated (multiple Chunker types map to the same input).
protected void registerDuplicateInput(BlockMapping mapping)
protected void registerDuplicateInput(BlockMapping[] mappings)
registerDuplicateOutput()
Registers a mapping where the output is duplicated (one Chunker type maps to multiple inputs).
protected void registerDuplicateOutput(BlockMapping mapping)
protected void registerDuplicateOutput(BlockMapping[] mappings)
registerOverrideInput()
Overrides an existing Input → Chunker mapping.
protected void registerOverrideInput(BlockMapping mapping)
protected void registerOverrideInput(BlockMapping[] mappings)
registerOverrideOutput()
Overrides an existing Chunker → Output mapping.
protected void registerOverrideOutput(BlockMapping mapping)
protected void registerOverrideOutput(BlockMapping[] mappings)
removeOutputMapping()
Removes all mappings from Chunker → input of a specific type.
protected void removeOutputMapping(ChunkerBlockType chunkerBlockType)

Abstract Methods

registerMappings()
Called on construction to register all block mappings. Must be implemented by subclasses.
public abstract void registerMappings(Version version)

Bedrock Implementation

BedrockBlockIdentifierResolver

Resolver for converting between Bedrock block identifiers and ChunkerBlockIdentifier.
Waterlogging is automatically handled by this resolver and states don’t need to be manually registered.
public BedrockBlockIdentifierResolver(
    Converter converter,
    Version version,
    boolean reader,
    boolean customIdentifiersAllowed
)

Waterlogging Support

public static final StateMappingGroup WATERLOGGED = new StateMappingGroup.Builder()
    .state("waterlogged", VanillaBlockStates.WATERLOGGED, BedrockStateTypes.BOOL_DEFAULT_FALSE)
    .build();
On Bedrock, waterlogging is allowed on every block, so an extra state handler is used to infer this automatically.

Example Mappings

register(BlockMapping.of("minecraft:stone", ChunkerVanillaBlockType.STONE));

Java Implementation

JavaBlockIdentifierResolver

Resolver for converting between Java block identifiers and ChunkerBlockIdentifier.
public JavaBlockIdentifierResolver(
    Converter converter,
    Version version,
    boolean reader,
    boolean customIdentifiersAllowed
)

Waterlogging Support

public static final StateMappingGroup DEFAULT_WATERLOGGED_FALSE = 
    new StateMappingGroup.Builder()
        .defaultOutput(VanillaBlockStates.WATERLOGGED, Bool.FALSE)
        .build();
On Java, waterlogging is block-specific, so the resolver assumes waterlogging isn’t present when the state isn’t explicitly defined.

Example Mappings

register(BlockMapping.of("minecraft:stone", ChunkerVanillaBlockType.STONE));

Usage Examples

Converting a Block Identifier

// Create resolver
BedrockBlockIdentifierResolver resolver = new BedrockBlockIdentifierResolver(
    converter,
    version,
    true, // reader mode
    true  // allow custom identifiers
);

// Convert from Bedrock to Chunker
Identifier bedrockBlock = new Identifier(
    "minecraft:stone",
    Collections.emptyMap()
);
Optional<ChunkerBlockIdentifier> chunkerBlock = resolver.to(bedrockBlock);

// Convert from Chunker back to Bedrock
ChunkerBlockIdentifier block = new ChunkerBlockIdentifier(
    ChunkerVanillaBlockType.STONE,
    Collections.emptyMap()
);
Optional<Identifier> outputBlock = resolver.from(block);

Checking Support

// Check if a block identifier is supported
if (resolver.isSupported("minecraft:diamond_ore")) {
    // Block can be converted
}

// Check if a Chunker block type is supported
if (resolver.isSupported(ChunkerVanillaBlockType.DIAMOND_ORE)) {
    // Block type can be converted
}

Custom Block Handling

// When customIdentifiersAllowed is true, unknown blocks are preserved
Identifier customBlock = new Identifier(
    "mymod:custom_block",
    Map.of("color", new StateValueString("red"))
);

Optional<ChunkerBlockIdentifier> result = resolver.to(customBlock);
// Returns a ChunkerBlockIdentifier with custom block type

Block State Mapping

Block states are mapped using StateMappingGroup objects that define how states convert between formats.

State Mapping Example

StateMappingGroup FACING_HORIZONTAL = new StateMappingGroup.Builder()
    .state("facing", VanillaBlockStates.FACING_HORIZONTAL, 
           new EnumStateGroup<>(Direction.Horizontal.class))
    .build();

Common State Groups

  • WATERLOGGED - Waterlogging state handling
  • FACING_HORIZONTAL - Horizontal facing direction
  • FACING_DIRECTION - All-direction facing
  • LIT - Lit/unlit state
  • POWERED - Powered/unpowered state
  • AGE - Age/growth state
State groups handle the conversion of block properties between different naming conventions and value representations across Java and Bedrock editions.

Build docs developers (and LLMs) love