Block Type Architecture
BlockType Class
TheBlockType class (src/renderer/block_type.h:9-28) combines model data with texture bindings:
ModelData Structure
Models are defined as reusable templates (src/models/model_data.h:6-17):
Standard Models
Cube Model
The foundational model (src/models/models.cpp:16-32):
Util::DIRECTIONS)
Vertex format: Each face has 12 floats (4 vertices × 3 components)
UV coordinates: UV_FULL = {0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 1.0, 1.0} (8 floats)
Non-Cube Models
Plant Model (Cross Shape)
Plant Model (Cross Shape)
Liquid Model (Lowered Top)
Liquid Model (Lowered Top)
Slab Model (Half-Height)
Slab Model (Half-Height)
Torch Model (Thin Cross)
Torch Model (Thin Cross)
src/models/models.cpp for all 14+ model definitions including Door, Ladder, Cactus, Crops, etc.
Shading Values
Default per-face shading simulates directional lighting (src/models/models.cpp:4-12):
Texture Mapping System
TheBlockType constructor (src/renderer/block_type.cpp:5-54) applies textures with a priority hierarchy:
Texture Keywords
| Keyword | Faces Applied | Use Case |
|---|---|---|
all | 0-5 (all faces) | Uniform blocks (stone, dirt) |
sides | 0,1,4,5 (horizontal) | Logs, grass blocks |
x | 0,1 (East/West) | Fine-grained control |
y | 2,3 (Top/Bottom) | Fine-grained control |
z | 4,5 (South/North) | Fine-grained control |
top | 2 | Grass, crafting table |
bottom | 3 | Rarely used alone |
front | 4 | Furnaces, chests |
back | 5 | Rarely used |
right | 0 | Custom face textures |
left | 1 | Custom face textures |
Block Definition Format
Thedata/blocks.mccpp file defines all block types in a simple text format:
Examples from blocks.mccpp
Property Reference
| Property | Format | Example |
|---|---|---|
name | name "String" | name "Diamond Ore" |
texture.<face> | texture.all <file> | texture.all stone |
model | model models.<name> | model models.plant |
sameas | sameas <ID> | sameas 8, name "New Name" |
Texture filenames reference PNGs in
assets/textures/ without the .png extension.Block ID Registry
Fromdata/blocks.mccpp:1-92, the standard blocks are:
Basic Blocks (1-7)
Basic Blocks (1-7)
- 1: Stone
- 2: Grass
- 3: Dirt
- 4: Cobblestone
- 5: Planks
- 6: Sapling (plant model)
- 7: Bedrock
Liquids (8-11)
Liquids (8-11)
- 8: Water (liquid model)
- 9: Stationary Water
- 10: Lava (liquid model)
- 11: Stationary Lava
Natural Materials (12-18)
Natural Materials (12-18)
- 12: Sand
- 13: Gravel
- 14-16: Ores (Gold, Iron, Coal)
- 17: Log (directional texture)
- 18: Leaves (transparent cube)
Special Blocks (19-24)
Special Blocks (19-24)
- 19: Sponge
- 20: Glass (glass model)
- 21-40: Colored Cloth (16 colors)
Decorative (37-55)
Decorative (37-55)
- 37-38: Flowers (plant model)
- 39-40: Mushrooms (plant model)
- 41-42: Metal blocks
- 43-44: Slabs (slab model)
- 50: Torch (torch model)
- 51: Fire (fire model)
Functional (53-84)
Functional (53-84)
- 53, 67, 72: Stairs
- 54: Chest (directional)
- 59: Crops (crop model)
- 60: Soil (soil model)
- 61-62: Furnaces (directional)
- 64, 71, 76: Doors (door model)
- 65: Ladder (ladder model)
- 78: Snow (snow model)
- 88: Cactus (cactus model)
Usage Examples
Creating a Custom Block
- Add texture to
assets/textures/my_block.png - Define in blocks.mccpp:
- Reload world or restart game
Custom Multi-Texture Block
Custom Model Block
Performance Notes
Related Topics
Chunk Meshing
See how BlockType data is used during mesh generation
Texture Manager
Learn about the texture atlas system