Code Patterns
Copy-paste examples for common plugin tasks. Commands, events, ECS, GUI, and more.
All
225
Command
60
Damage
2
Ecs
27
Entity
5
Gui
75
Interaction
2
Inventory
4
Moderation
3
Permission
2
Player
9
Plugin
4
Storage
2
Teleport
3
Ui
22
Util
5
← Back to Patterns
java
ecs
ecs-overview
Entity Component System (ECS) architecture overview for Hytale modding. ECS separates data (Components) from logic (Systems), with Entities being just IDs that group components together.
Example Code
// Three Pillars of ECS:
// 1. ENTITY - Just an ID (like a UUID or reference)
// 2. COMPONENT - Pure data containers (no logic)
// 3. SYSTEM - Contains all the logic, processes components
// Why ECS over OOP?
// - Avoids deep inheritance hierarchies
// - No diamond problem (multiple inheritance)
// - No class explosion (enemy types * abilities * states)
// - Components are modular and reusable
// - Better performance through data locality
// Hytale Hierarchy:
// Universe -> World -> EntityStore -> Entities
//
// Universe: Contains all worlds (main world, dungeons, etc.)
// World: A single game world with its EntityStore
// EntityStore: The ECS database holding all entity components
// Entity: Referenced via Ref<EntityStore>
Thread Safety
Always use world.execute() when accessing components from outside a system context to ensure thread safety.
Common Mistakes
Trying to access components without proper Store/Ref pattern. Confusing Entity with its components - an Entity is just an ID.