What are Definitions?
Definitions are the core content files in Minecraft add-ons that describe:- Entity Behaviors: How mobs and entities behave (EntityTypeDefinition)
- Entity Resources: Visual appearance of entities (EntityTypeResourceDefinition)
- Block Definitions: Custom block types and their properties (BlockTypeDefinition)
- Item Definitions: Custom items in both behavior and resource packs (ItemTypeDefinition, ItemTypeResourceDefinition)
- Animations: Entity animations for both behavior and visuals (AnimationBehaviorDefinition, AnimationResourceDefinition)
- Particle Effects: Visual effects (ParticleEffectResourceDefinition)
- Sound Definitions: Audio configuration (SoundDefinitionCatalogDefinition)
Definition File Structure
All Minecraft definition files follow a common pattern:format_version: Version of the definition format- Type-specific key (e.g.,
minecraft:entity,minecraft:block,minecraft:item) - Inner structure with
description,components, and optional features
Common Definition Features
All definition classes in the library implement theIDefinition interface and provide:
Loading and Persistence
Component Management
Definitions that support components (entities, blocks, items) provide:getComponent(id): Get a component by IDaddComponent(id, data): Add a new componentremoveComponent(id): Remove a componentgetComponents(): Get all components
Format Version Management
Event Handling
Definitions emit events when they’re loaded or modified:Working with Project Items
Definitions integrate with the project system to manage relationships between files:Definition Types
The library provides definition classes for all major Minecraft content types:| Class | Purpose | File Type |
|---|---|---|
| EntityTypeDefinition | Entity behavior pack definitions | entities/*.json |
| EntityTypeResourceDefinition | Entity resource pack definitions | entity/*.json |
| BlockTypeDefinition | Block definitions | blocks/*.json |
| ItemTypeDefinition | Item behavior definitions | items/*.json |
| ItemTypeResourceDefinition | Item resource definitions (legacy) | items/*.json |
| AnimationBehaviorDefinition | Animation behavior logic | animations/*.json |
| AnimationResourceDefinition | Visual animations | animations/*.json |
| ParticleEffectResourceDefinition | Particle effects | particles/*.json |
| SoundDefinitionCatalogDefinition | Sound definitions catalog | sounds.json |
Best Practices
Always Check Loading State
Use ensureOnFile Pattern
TheensureOnFile static method ensures proper file manager setup:
Persist Changes
Always callpersist() after making modifications:
Handle Undefined Values
Definition properties may be undefined if not loaded:Next Steps
- Entity Definitions - Learn about entity behavior and resource definitions
- Block Definitions - Working with custom blocks
- Item Definitions - Creating custom items
- Animation Definitions - Managing animations
- Particle Definitions - Configuring particle effects
- Sound Definitions - Managing sound files