TONI's Magic Lib is the magic engine behind TONI's Wizardry. It adds nothing to the game on its own: install it when a mod asks for it.
It gives magic mods one shared system for spells, mana, wands, tomes, spell projectiles, sides and spellcasting mobs, so every TONI's magic mod plays the same way and works together.
What it provides
- Spell registry: spells are registered with an id (
mymod:fireball), mana cost, cooldown, colour, minimum wand tier, and a cast action. Mob-only spells are supported too. - Wands and staffs (
WandItem): a tier (spell power), their own mana pool that refills while carried (shown as a blue bar), the spells inscribed in them, and the selected spell. Right-click casts, sneak + right-click switches spell. - Spell tomes (
SpellTomeItem): used with a wand in the other hand, they inscribe their spell into it. - Mana potions (
ManaPotionItem): refill every wand the player carries. - Spell orbs: one glowing projectile entity for every projectile spell, with pluggable behaviours. Ready-made: a homing arcane bolt, a fireball and an explosive meteor.
- Ready-made spell effects: projectile, frost nova, lightning, blink, heal, shield, life drain, meteor rain and raise dead. A whole spell is one line.
- Sides: a light side (players, villagers, iron golems, pets, good casters) and a dark side (dark casters and their minions). Spells never hurt allies, and area spells only hit foes, never animals.
- Spellcaster mobs (
SpellcasterMob): a base mob with a side, variants, a staff in hand and a synced "casting" state with coloured sparks. It comes with AI goals: keep distance and cast (CastSpellGoal) and heal hurt allies (HealAlliesGoal). - Cast events: listeners before every cast (they can cancel it) and after it.
- Commands:
/tonimagic spellslists every registered spell./tonimagic filland/tonimagic learnall(op) refill or teach the wand in your hand. - Config
config/tonimagic.properties: mana refill speed and spell damage multipliers for players and for mobs. They apply to every mod that uses the lib. - English and Spanish.
For modders
A spell is one statement:
Spell FIREBALL = Spell.builder("mymod:fireball").mana(15).cooldown(16).color(0xFF7A1A)
.orb(OrbBehaviors.fire(6, null))
.cast(c -> SpellEffects.projectile(c, 1.3, 0, 1))
.register();
REG.item("fire_tome", p -> new SpellTomeItem(p, FIREBALL));
REG.item("oak_wand", p -> new WandItem(p, 1, 100, 4, FIREBALL.id()));
Names come from the lang keys spell.mymod.fireball and spell.mymod.fireball.desc. Packages: api (Spell, Spells, SpellContext, OrbBehavior, Factions, MagicEvents), cast (Casting, SpellEffects, OrbBehaviors), entity (SpellOrb, SpellcasterMob, ai), item.
Requirements
- TONI's Core Lib
- NeoForge 1.21.1 (more versions coming)
Join the Discord: discord.com/invite/4YAxqzxgBd