Material List Generation
Relevant source files
The following files were used as context for generating this wiki page:
Material List Generation is a core system within HoloPrint designed to calculate, translate, and display the exact quantity of items required to construct a holographic schematic in Minecraft Bedrock Edition. It transforms raw block data from .mcstructure files into a human-readable list of survival items, accounting for block-to-item conversions (e.g., silk touch requirements or drops), item multipliers (e.g., slabs vs. full blocks), and excluded aesthetic blocks.
Sources: src/MaterialList.js, src/HoloPrint.js:260-290
This system operates during the resource pack generation phase. It processes every block within the structure's volume and exports a finalized list that is integrated into the pack's metadata and the in-game Custom UI.
Architecture and Core Logic
The primary component is the MaterialList class, which maintains an internal map of material names and their respective counts.
Data Flow Overview
The generation process follows a structured pipeline from raw NBT data to localized UI elements.
The MaterialList Class
The MaterialList class handles the conversion of block states into item counts. It utilizes several metadata maps to ensure accuracy.
| Method | Description |
|---|---|
add(block, count) | Processes a block or block object, applying filters and mappings before updating the count. |
addItem(itemName, count) | Directly adds an item to the list without block-to-item mapping logic. |
export() | Finalizes the list, applying translations, calculating Aux IDs for UI rendering, and partitioning counts. |
setLanguage(translations) | Loads .lang file content to translate serialization IDs into user-facing names. |
Sources: src/MaterialList.js:27-146
Configuration and Mappings
Material List generation relies on a JSON-based mapping system to handle discrepancies between internal block names and survival items.
Mapping Schema
The configuration schema defines how blocks are treated during the counting process:
- ignored_blocks: Blocks like "air" or "light_block" that are never included.
- block_to_item_mappings: Maps blocks that drop different items (e.g.,
lit_redstone_oremapping toredstone_ore). - item_count_multipliers: Handles blocks that represent multiple items or fractional items, such as double slabs or items that drop multiple units.
- special_block_entity_properties: Used for blocks whose item identity depends on NBT data (e.g., colors of shulker boxes).
Sources: src/data/schemas/materialListMappings.schema.json:7-115
Logic Sequence for Adding Materials
When add() is called, the following logic is applied:
Sources: src/MaterialList.js:61-88
Localization and Quantity Formatting
Exporting the material list involves converting technical identifiers into localized strings and formatting large numbers into Minecraft-specific units (Stacks and Shulker Boxes).
Quantity Partitioning
The system automatically formats large quantities for easier inventory management:
- Stacks (s): Calculated as
floor(count / 64) % 27. - Shulker Boxes (Emoji \uE200): Calculated as
floor(count / 1728). - Remainder: The remaining individual items.
Example: 100 = 1s + 36.
Sources: src/MaterialList.js:189-195
Translation Pipeline
- Attempt to find item
serialization_id. - If missing, attempt to find block
serialization_id. - Apply
serialization_id_patches(e.g., adding.namesuffixes). - Apply
translation_patchesfor missing strings. - Look up final key in the provided
.langmap.
Sources: src/MaterialList.js:108-135
UI Integration
The finalized list is rendered in the Bedrock Edition client using a custom JSON UI definition.
UI Component Structure
The UI utilizes a stack_panel within a scrolling_panel to display entries. Each entry includes:
- Item Renderer: Uses the calculated
auxIdto display the 3D/2D item icon. - Item Name: Localized name string.
- Item Count: The partitioned quantity string.
Dynamic Scaling
The generation script in HoloPrint.js dynamically adjusts the UI width if item names or counts are exceptionally long to prevent text clipping.
Sources: src/HoloPrint.js:589-593
Summary
The Material List Generation system ensures that HoloPrint users have a precise manifest of resources needed for their builds. By combining complex block-to-item mapping logic with localized translation and intuitive quantity partitioning (Stacks/Boxes), it bridges the gap between technical schematic data and practical survival gameplay. This manifest is delivered both in the pack's texts/*.lang files for the description and via a custom in-game UI.