This folder contains documentation for the template system used to create new Minecraft Bedrock files.
The template system allows you to customize how the language server creates new files for your Minecraft projects. You can:
- Override default file templates
- Customize file naming patterns
- Use variables for dynamic content
- Create consistent file structures across your project
- Templates - How to create and configure custom templates
- Variables - Available template variables for substitution
Templates are configured through the .mcattributes file in your project root.
# Customize entity file naming
template.behavior.entity.filename=entities/${{id.safe}}.entity.json
# Use a custom template file
template.behavior.entity.file=./.minecraft/templates/entity.bp.json{
"format_version": "1.20.41",
"minecraft:entity": {
"description": {
"identifier": "${{id}}",
"is_spawnable": true,
"is_summonable": true
},
"components": {}
}
}- User triggers file creation - Via command palette or IDE integration
- Template is selected - Based on file type (entity, block, item, etc.)
- Variables are replaced -
${{variable}}syntax is substituted with actual values - File is created - At the specified location with the generated content
The template system supports various variables that are automatically replaced:
${{id}}- The identifier entered by the user${{id.safe}}- A sanitized version of the identifier${{filename}}- The name of the file being created${{uuid}}- A randomly generated UUID- And more...
For a complete list, see Variables.
You can customize templates for:
- Entities, blocks, items
- Animations and animation controllers
- Loot tables, recipes, trading
- Spawn rules, dialogues
- Manifests and more
- Entities, models, attachables
- Animations and animation controllers
- Particles, render controllers
- Texture definitions
- Sound definitions
- Manifests and more
- Manifests
For the complete list of template attributes, see Templates.
- Use version control - Keep template files in your project repository
- Start with defaults - Only override what you need to customize
- Test templates - Create test files to verify your templates work correctly
- Use safe identifiers - Prefer
${{id.safe}}over${{id}}for filenames - Document custom templates - Add comments explaining customizations
Create a file at .minecraft/templates/entity.bp.json:
{
"format_version": "1.20.41",
"minecraft:entity": {
"description": {
"identifier": "${{id}}",
"is_spawnable": true,
"is_summonable": true,
"is_experimental": false
},
"component_groups": {},
"components": {
"minecraft:type_family": {
"family": ["${{id.safe.nonamespace}}"]
},
"minecraft:collision_box": {
"width": 1,
"height": 1
},
"minecraft:physics": {}
},
"events": {}
}
}Configure in .mcattributes:
template.behavior.entity.filename=entities/${{id.safe}}.json
template.behavior.entity.file=./.minecraft/templates/entity.bp.json# Use different naming convention
template.behavior.block.filename=blocks/${{id.safe.nonamespace}}.block.bp.json
template.resource.block.filename=blocks/${{id.safe.nonamespace}}.block.rp.json- MCAttributes - Configure templates in your project
- Commands - Commands that use templates to create files
- Style Guide - Coding conventions
Template not being used:
- Check that
.mcattributesis in the project root - Verify the template file path is correct
- Ensure the template file exists at the specified location
Variables not being replaced:
- Use the correct syntax:
${{variable}} - Check that the variable name is valid (see Variables)
- Ensure braces are doubled:
${{}}not${}
Invalid JSON after substitution:
- Test your template with sample values
- Check for missing commas or quotes after variable substitution
- Use a JSON validator on the generated file
For more help, see the Debugging guide or open an issue on GitHub.