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
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
)
The version being resolved
Whether this is the reader (true) or writer (false)
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)
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)
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)
The input identifier in the format namespace:key
The item type object (usually ChunkerVanillaItemType enum entry)
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
Simple Item
With Data Value
With Property
register(ItemMapping.of(
"minecraft:bucket",
ChunkerVanillaItemType.BUCKET
));
register(ItemMapping.of(
"minecraft:arrow",
1,
ChunkerVanillaItemType.TIPPED_ARROW
));
register(ItemMapping.of(
"minecraft:arrow",
id + 1,
ChunkerVanillaItemType.TIPPED_ARROW,
ChunkerItemProperty.POTION,
potionType
));
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
Simple Item
Spawn Egg
Music Disc
register(ItemMapping.of(
"minecraft:diamond_sword",
ChunkerVanillaItemType.DIAMOND_SWORD
));
register(ItemMapping.of(
"minecraft:zombie_spawn_egg",
ChunkerVanillaItemType.SPAWN_EGG,
ChunkerItemProperty.SPAWN_EGG_MOB,
ChunkerVanillaEntityType.ZOMBIE
));
register(ItemMapping.of(
"minecraft:music_disc_cat",
ChunkerVanillaItemType.MUSIC_DISC_CAT
));
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
Potion effect type for potions and tipped arrows
ChunkerItemProperty.SPAWN_EGG_MOB
Entity type for spawn eggs
ChunkerItemProperty.BANNER_PATTERN
Banner pattern for banner pattern items
ChunkerItemProperty.HORN_INSTRUMENT
Instrument type for goat horns
ChunkerItemProperty.STEW_EFFECT
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.