API

Spellbook Plus v2 provides a developer API for integrating with the spell system. The API uses record-based models and service interfaces accessed via SpellbookPlugin.getInstance().

Plugin Instance

Access the main plugin and all services:

SpellbookPlugin plugin = SpellbookPlugin.getInstance();

// Core services
CooldownService cooldowns = plugin.getCooldownService();
SpellService spells = plugin.getSpellService();
NodeRegistry nodes = plugin.getNodeRegistry();
SpellbookEventBus eventBus = plugin.getEventBus();
DamageService damage = plugin.getDamageService();

// Enchantment & Passive services
EnchantmentRegistry enchantments = plugin.getEnchantmentRegistry();
EnchantmentService enchantmentService = plugin.getEnchantmentService();
PassiveRegistry passives = plugin.getPassiveRegistry();
PassiveService passiveService = plugin.getPassiveService();

SpellService

Manage spell definitions and player spell knowledge.

CooldownService

Manage spell cooldowns per player.

DamageService

Calculate spell damage and track hits.

NodeRegistry

Register and look up node handlers. Used by the spell execution engine.

SpellbookEventBus

Publish/subscribe event system for spell-related events.

Data Models

SpellDefinition (Record)

SpellMetadata (Record)

SpellGraph (Record)

SpellNode (Record)

EnchantmentDefinition (Record)

PassiveDefinition (Record)

Creating Custom Node Handlers

Implement the NodeHandler functional interface:

Register in NodeRegistry:

Enums

SpellCategory

TriggerType

EnchantmentTier

PassiveTier

NodeType

ECS Components

The mod uses Hytale's ECS system with these components:

Component
Purpose

SpellCasterComponent

Player spell state and hotbar

ProjectileDataComponent

Projectile metadata (damage, caster, spell ID)

ShieldComponent

Active damage shield tracking

PlayerPassiveComponent

Active passive abilities

StaffEnchantmentComponent

Staff enchantment slots

PlayerEnchantingComponent

Enchanting XP and progress

Example: Check Cooldown and Cast

Event Types

Event
Trigger
Key Fields

SpellCastEvent

Spell cast

playerId, spellId

ProjectileHitEvent

Spell projectile hits target

casterId, hitEntityId, damage, spellId

EntityKillEvent

Entity killed by spell

casterId, killedEntityId, spellId

DamageTakenEvent

Entity takes damage

casterId, sourceId, amount

HealEvent

Entity healed

casterId, healedId, amount

Example: Subscribe to Events

Last updated