Metadata System
Metadata System
The metadata system in zItems allows you to configure advanced item properties like food effects, potion effects, leather armor colors, armor trims, and more through a flexible, type-safe configuration system.
What is Metadata?
Metadata represents specialized item properties that go beyond basic attributes. Each metadata type applies to specific item types (e.g., food metadata only works on edible items, leather armor metadata only works on leather armor).
Key Concepts
Polymorphic Configuration: Each metadata type has its own configuration structure
Type-Safe: Structura validates metadata against the correct Java class
Auto-Discovery: Metadata implementations are discovered via
@AutoMetadataannotationItem-Specific: Each metadata type only works with compatible items
Metadata Structure
Metadata is configured in the metadata section of item configs:
id: "my_item"
material: GOLDEN_APPLE
metadata:
food: # Metadata type (discriminator)
nutrition: 8
saturation: 9.6
# Can have multiple metadata typesAvailable Metadata Types
Food Metadata
Discriminator: food Compatible Materials: Any edible item (Paper 1.20.5+) Purpose: Configure food properties and consumption effects
Configuration
Fields Reference
nutrition
int
Required
Hunger points restored (half drumsticks)
saturation
double
Required
Saturation value
can-always-eat
boolean
false
Can eat even when hunger is full
eat-seconds
double
-1
Time to consume (seconds)
animation
ItemUseAnimation
null
Eating animation type
sound
Sound
null
Sound played when eating
cooldown-seconds
double
-1
Cooldown after use (seconds)
group-cooldown
String
null
Cooldown group ID
effects
List<PotionEffectWrapper>
null
Potion effects on consumption
Animation Types
EAT- Normal eating animationDRINK- Drinking animationBLOCK- Shield blocking animationBOW- Bow drawing animationSPEAR- Trident throwing animationCROSSBOW- Crossbow loading animationSPYGLASS- Spyglass looking animationTOOT_HORN- Horn tooting animationBRUSH- Brush using animation
Complete Example
Potion Metadata
Discriminator: potion Compatible Materials: POTION, SPLASH_POTION, LINGERING_POTION, TIPPED_ARROW Purpose: Configure potion colors and effects
Configuration
Fields Reference
color
Color
null
Potion color (hex or Bukkit)
base-potion-type
PotionType
null
Base potion type
custom-effects
List<PotionEffectWrapper>
null
Custom potion effects
Base Potion Types
Common types: STRENGTH, SPEED, HEALING, HARMING, REGENERATION, FIRE_RESISTANCE, WATER_BREATHING, INVISIBILITY, NIGHT_VISION, WEAKNESS, POISON, SLOWNESS, etc.
See Bukkit PotionType for all types.
Complete Example
Leather Armor Metadata
Discriminator: leather-armor Compatible Materials: LEATHER_HELMET, LEATHER_CHESTPLATE, LEATHER_LEGGINGS, LEATHER_BOOTS, LEATHER_HORSE_ARMOR Purpose: Dye leather armor
Configuration
Color Formats
Hex Color:
Bukkit Color (RGB):
Complete Example
Armor Trim Metadata
Discriminator: trim Compatible Materials: Any armor piece Purpose: Apply armor trims (1.20+)
Configuration
Trim Materials
QUARTZ,IRON,NETHERITE,REDSTONE,COPPER,GOLD,EMERALD,DIAMOND,LAPIS,AMETHYST
Trim Patterns
SENTRY,VEX,WILD,COAST,DUNE,WAYFINDER,RAISER,SHAPER,HOST,WARD,SILENCE,TIDE,SNOUT,RIB,EYE,SPIRE
Complete Example
Banner Metadata
Discriminator: banner Compatible Materials: Any banner Purpose: Add patterns to banners
Configuration
Pattern Types
BASE,STRIPE_BOTTOM,STRIPE_TOP,STRIPE_LEFT,STRIPE_RIGHT,STRIPE_CENTER,STRIPE_MIDDLE,STRIPE_DOWNRIGHT,STRIPE_DOWNLEFT,SMALL_STRIPESCROSS,STRAIGHT_CROSS,TRIANGLE_BOTTOM,TRIANGLE_TOP,TRIANGLES_BOTTOM,TRIANGLES_TOPDIAGONAL_LEFT,DIAGONAL_RIGHT,DIAGONAL_UP_LEFT,DIAGONAL_UP_RIGHTCIRCLE,RHOMBUS,HALF_VERTICAL,HALF_HORIZONTAL,HALF_VERTICAL_RIGHT,HALF_HORIZONTAL_BOTTOMBORDER,CURLY_BORDER,GRADIENT,GRADIENT_UP,BRICKS,GLOBE,CREEPER,SKULL,FLOWER,MOJANG,PIGLIN
Complete Example
Enchanted Book Metadata
Discriminator: enchant-storage Compatible Materials: ENCHANTED_BOOK Purpose: Store enchantments in books
Configuration
Complete Example
Advanced Metadata Types
Tool Metadata
Discriminator: tool Compatible Materials: Any tool Purpose: Configure tool properties (damage on block break, default mining speed)
Block State Metadata
Discriminator: block-state Compatible Materials: Block items Purpose: Store block state data
Can Break / Can Place On Metadata
Discriminator: can-break / can-place-on Compatible Materials: Any item Purpose: Adventure mode block restrictions
Using Multiple Metadata Types
You can apply multiple metadata types to a single item:
Creating Custom Metadata Types
Developers can create custom metadata types using the API:
Step 1: Implement ItemMetadata
Step 2: Register Package
Step 3: Use in Configuration
Metadata vs Properties
When to Use Metadata
Use metadata for:
Item-specific properties (food, potions, armor colors)
Complex nested data structures
Type-specific configurations
When to Use Item Properties
Use regular properties for:
Basic item settings (display name, lore, material)
Universal item attributes (unbreakable, enchantments, flags)
Simple key-value pairs
Example Comparison:
Best Practices
1. Only Use Compatible Metadata
2. Validate Configuration
Test your metadata configurations:
3. Check Paper vs Spigot
Some metadata is Paper-only:
On Spigot, these fields will be ignored.
4. Document Your Metadata
Troubleshooting
Metadata Not Applied
Symptoms: Item doesn't have expected properties
Checklist:
Is the material compatible? (e.g., leather-armor only works on leather armor)
Is the metadata type spelled correctly?
Check console for errors when loading
Validate YAML syntax
Debug:
Wrong Colors
Problem: Leather armor or potion has wrong color
Solutions:
Check hex format:
#RRGGBBUse uppercase for hex
Verify color value is valid
Effects Not Working
Problem: Food or potion effects not applying
Solutions:
Duration is in ticks (20 ticks = 1 second)
Amplifier starts at 0 (0 = Level I, 1 = Level II, etc.)
Check effect type is valid
Performance Considerations
Metadata is Applied on Build
Metadata is applied when an item is built (ZItem.build()), not on every use. This means:
✅ Efficient - no runtime overhead
✅ Cached - item meta is stored
❌ Not dynamic - cannot change based on runtime conditions
Use Metadata for Static Properties
Next Steps
Creating Items Guide - Complete item configuration
Effect System - Dynamic item behaviors
Need help? Join our Discord or check GitHub Issues!
Last updated