Skip to content

Instantly share code, notes, and snippets.

View thegalaxydev's full-sized avatar

Galaxy thegalaxydev

View GitHub Profile

Spellbook: Full Breakdown and Usage Guide

Spellbook is a utility library (developed by Darkhax) designed to simplify common Hytale modding tasks. It provides helper methods for world manipulation, entity state checking, flexible item generation, and a lightweight testing framework.

Below is a breakdown of the core components with examples of how to use them in your plugin.


1. Entity Utilities (EntityHelper)

EntityHelper provides shortcuts for checking complex entity states that usually require multiple ECS (Entity Component System) lookups.

To hook into events like block breaking in Hytale, you use the EventRegistry provided by the PluginBase (the class your JavaPlugin extends). Unlike some other platforms that use annotations, Hytale uses a functional registration pattern.

1. The Core Pattern

You register a listener by calling getEventRegistry().register(EventClass.class, consumer).

// Inside your plugin or a listener class
getEventRegistry().register(BreakBlockEvent.class, event -> {
    // Your logic here
    System.out.println("Block broken at: " + event.getTargetBlock());