Display Templates
Create and Use Reusable Item Appearance Templates
Overview
Display templates are reusable configurations in Zaphkiel for defining item appearances. With display templates, you can create a unified format for the name and description of multiple items, avoiding redundant configurations.
Basic Concepts
What is a Display Template
A display template defines the format structure of an item's name and description, using variable placeholders to dynamically insert item-specific content. Each item can reference a display template and provide corresponding variable values.
Relationship Between Templates and Items
Creating Display Templates
Template File Location
Display template configuration files are located in the plugins/Zaphkiel/display/
directory, and multiple .yml
files are supported.
Basic Template Structure
Template Configuration Items
Configuration Item | Description | Example |
---|---|---|
name | Item name format | '&7<item_name>' |
lore | List of item description formats | ['&9<item_type>', '&f<item_description...>'] |
Variable System
Variable Syntax
Display templates use the <variable_name>
syntax to define placeholders:
Special Variable Syntax
Expanded Variables (...
)
Using the <variable_name...>
syntax allows list variables to be expanded into multiple lines:
Data-Mapped Variables
Display templates can use dynamic variables from data-mapper
:
Template Application Process
1. Template Selection
When an item is constructed, the system selects the corresponding display template based on the item's display
configuration.
2. Variable Replacement
The system replaces the placeholders in the template with the variable values provided by the item to generate the final display content.
3. Structure Processing
The template uses structural processing to handle complex variable replacements, including expanding variables and conditional display.
Practical Template Examples
Weapon Template
Consumable Template
Equipment Template
Advanced Features
Conditional Display
Combined with data mapping, conditional display can be implemented:
Metadata Integration
Display templates can include metadata configurations to apply common functions to all items using the template.
Usage Tips
1. Template Naming Conventions
It is recommended to use descriptive template names:
weapon_common
- Common weapon templatearmor_legendary
- Legendary armor templateconsumable_potion
- Potion consumable template
2. Variable Naming Consistency
Maintain consistent variable naming across all templates:
item_name
- Item nameitem_type
- Item typeitem_description
- Item description
3. Unified Color Theme
Use a unified color theme for different types of items:
- Weapons: Red series (
&c
,&4
) - Armor: Blue series (
&9
,&b
) - Consumables: Green series (
&a
,&2
)
Notes
- Template Reload: After modifying display templates, use
/zaphkiel reload
to reload - Variable Matching: Ensure the variables provided by the item match the placeholders in the template
- Performance Considerations: Avoid using overly complex variable processing in templates
- Compatibility: Template modifications may affect all items using the template