Skip to main content

Overview

Item identifier resolvers handle the conversion of item identifiers between Minecraft’s Java and Bedrock editions and Chunker’s intermediate format. These resolvers manage item properties, data values, and format-specific differences.

Base Resolver

ChunkerItemIdentifierResolver

Abstract base class for converting format-specific identifiers into ChunkerItemStack.
ChunkerItemIdentifierResolver
abstract class
Located at: com.hivemc.chunker.conversion.encoding.base.resolver.identifier.ChunkerItemIdentifierResolver
This is very similar to ChunkerBlockIdentifierResolver but allows properties to be used and has no mapping groups.

Constructor

public ChunkerItemIdentifierResolver(
    Converter converter,
    Version version,
    boolean reader,
    boolean defaultData
)
converter
Converter
The converter instance
version
Version
The version being resolved
reader
boolean
Whether this is the reader (true) or writer (false)
defaultData
boolean
Whether the data should default to 0 instead of absent

Core Methods

to()
Converts a format-specific identifier to a Chunker item stack.
public Optional<ChunkerItemStack> to(Identifier input)
input
Identifier
The input identifier from the format (e.g., minecraft:diamond_sword)
returns
Optional<ChunkerItemStack>
The converted Chunker item stack, or empty if not supported
from()
Converts a Chunker item stack to a format-specific identifier.
public Optional<Identifier> from(ChunkerItemStack input)
input
ChunkerItemStack
The Chunker item stack
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(ChunkerItemType chunkerItemType)
identifier
String
The input identifier in the format namespace:key
chunkerItemType
ChunkerItemType
The item type object (usually ChunkerVanillaItemType enum entry)
returns
boolean
True if the item can potentially be resolved

Registration Methods

These methods are used during resolver initialization to register item mappings:
register()
Registers a standard item mapping.
protected void register(ItemMapping mapping)
protected void register(ItemMapping[] mappings)
registerDuplicateInput()
Registers a mapping where the input is duplicated.
protected void registerDuplicateInput(ItemMapping mapping)
protected void registerDuplicateInput(ItemMapping[] mappings)
registerDuplicateOutput()
Registers a mapping where the output is duplicated.
protected void registerDuplicateOutput(ItemMapping mapping)
protected void registerDuplicateOutput(ItemMapping[] mappings)
registerOverrideInput()
Overrides an existing Input → Chunker mapping.
protected void registerOverrideInput(ItemMapping mapping)
protected void registerOverrideInput(ItemMapping[] mappings)
registerOverrideOutput()
Overrides an existing Chunker → Output mapping.
protected void registerOverrideOutput(ItemMapping mapping)
protected void registerOverrideOutput(ItemMapping[] mappings)
removeOutputMapping()
Removes all mappings from Chunker → input of a specific type.
protected void removeOutputMapping(ChunkerItemStackIdentifierType chunkerItemStackIdentifierType)

Abstract Methods

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

Bedrock Implementation

BedrockItemIdentifierResolver

Resolver for converting between Bedrock item identifiers and ChunkerItemStackIdentifier.
public BedrockItemIdentifierResolver(
    Converter converter,
    Version version,
    boolean reader
)

Special Features

Potion ID Resolution
Bedrock uses numeric IDs for potions. The resolver includes a BedrockPotionIDResolver for handling these conversions.
// Create a potion ID resolver
BedrockPotionIDResolver potionIDResolver = new BedrockPotionIDResolver(version);

// Register each potion type
for (ChunkerPotionType potionType : ChunkerPotionType.values()) {
    int id = potionIDResolver.from(potionType).orElse(-1);
    if (id < 0) continue;
    
    register(ItemMapping.of(
        "minecraft:potion",
        id,
        ChunkerVanillaItemType.POTION,
        ChunkerItemProperty.POTION,
        potionType
    ));
}
Data Value Mappings
Bedrock uses data values for item variants (e.g., different banner colors).
// Banners by data value
register(ItemMapping.flatten(
    "minecraft:banner",
    ImmutableMultimap.<Integer, ChunkerVanillaItemType>builder()
        .put(15, ChunkerVanillaItemType.WHITE_BANNER)
        .put(14, ChunkerVanillaItemType.ORANGE_BANNER)
        .put(13, ChunkerVanillaItemType.MAGENTA_BANNER)
        // ...
        .build()
));

Example Mappings

register(ItemMapping.of(
    "minecraft:bucket",
    ChunkerVanillaItemType.BUCKET
));

Java Implementation

JavaItemIdentifierResolver

Resolver for converting between Java item identifiers and ChunkerItemStackIdentifier.
public JavaItemIdentifierResolver(
    Converter converter,
    Version version,
    boolean reader
)

Special Features

Spawn Egg Mappings
Java uses separate identifiers for each spawn egg type, mapped with entity properties.
register(ItemMapping.of(
    "minecraft:bat_spawn_egg",
    ChunkerVanillaItemType.SPAWN_EGG,
    ChunkerItemProperty.SPAWN_EGG_MOB,
    ChunkerVanillaEntityType.BAT
));
Banner Patterns
Java handles banner patterns through separate item identifiers.
register(ItemMapping.of(
    "minecraft:creeper_banner_pattern",
    ChunkerVanillaItemType.BANNER_PATTERN,
    ChunkerItemProperty.BANNER_PATTERN,
    ChunkerBannerPattern.CREEPER
));

Example Mappings

register(ItemMapping.of(
    "minecraft:diamond_sword",
    ChunkerVanillaItemType.DIAMOND_SWORD
));

Usage Examples

Converting an Item Identifier

// Create resolver
BedrockItemIdentifierResolver resolver = new BedrockItemIdentifierResolver(
    converter,
    version,
    true // reader mode
);

// Convert from Bedrock to Chunker
Identifier bedrockItem = new Identifier(
    "minecraft:diamond_sword",
    Collections.emptyMap()
);
Optional<ChunkerItemStack> chunkerItem = resolver.to(bedrockItem);

// Convert from Chunker back to Bedrock
ChunkerItemStack item = new ChunkerItemStack(
    ChunkerVanillaItemType.DIAMOND_SWORD
);
Optional<Identifier> outputItem = resolver.from(item);

Working with Item Properties

// Create an item with properties
Map<Property<? super ChunkerItemStack, ?>, Object> properties = new HashMap<>();
properties.put(ChunkerItemProperty.POTION, ChunkerPotionType.HEALING);

ChunkerItemStack potion = new ChunkerItemStack(
    ChunkerVanillaItemType.POTION,
    properties
);

// Convert to format-specific identifier
Optional<Identifier> identifier = resolver.from(potion);

Handling Data Values (Bedrock)

// Convert Bedrock item with data value
Identifier bedrockBanner = new Identifier(
    "minecraft:banner",
    Map.of("data", new StateValueInt(15)) // White banner
);

Optional<ChunkerItemStack> chunkerBanner = resolver.to(bedrockBanner);
// Returns ChunkerItemStack with WHITE_BANNER type

Checking Item Support

// Check if an item is supported
if (resolver.isSupported("minecraft:diamond")) {
    // Item can be converted
}

// Check if a Chunker item type is supported
if (resolver.isSupported(ChunkerVanillaItemType.DIAMOND)) {
    // Item type can be converted
}

Item Properties

Item properties are used to store additional data about items that goes beyond the basic identifier.

Common Item Properties

ChunkerItemProperty.POTION
ChunkerPotionType
Potion effect type for potions and tipped arrows
ChunkerItemProperty.SPAWN_EGG_MOB
ChunkerEntityType
Entity type for spawn eggs
ChunkerItemProperty.BANNER_PATTERN
ChunkerBannerPattern
Banner pattern for banner pattern items
ChunkerItemProperty.HORN_INSTRUMENT
ChunkerHornInstrument
Instrument type for goat horns
ChunkerItemProperty.STEW_EFFECT
ChunkerStewEffect
Suspicious stew effect

Using Item Properties

// Get a property from an item stack
ChunkerPotionType potionType = itemStack.get(ChunkerItemProperty.POTION);

// Check if a property exists
if (itemStack.has(ChunkerItemProperty.SPAWN_EGG_MOB)) {
    ChunkerEntityType mobType = itemStack.get(ChunkerItemProperty.SPAWN_EGG_MOB);
}

Converter Mappings

Both resolvers support user-defined mappings through the converter’s mapping files:
// User mappings are automatically applied
MappingsFileResolvers mappings = converter.getBlockMappings();
if (mappings != null) {
    // Mappings will be applied during conversion
    Optional<Identifier> mapped = mappings.getMappings().convertItem(input, true);
}
User mappings allow custom item conversions to be defined without modifying the resolver code.

Build docs developers (and LLMs) love