Skip to content

TONI's Magic Lib

Magic engine for TONI's mods: spell registry, wands with mana, spell tomes, spell projectiles, ready-made spell effects, light and dark sides, spellcaster mobs and cast events.

6k downloads Updated
26.3 26.2

No ratings yet

Be the first to rate it.

Rate it

Community listing page

Community listing page, reviews may not be monitored by the author.

About

Description

TONI'S MAGIC LIB

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 spells lists every registered spell. /tonimagic fill and /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.
  • 12 languages: English, Spanish, French, German, Italian, Polish, Portuguese, Russian, Turkish, Simplified Chinese, Japanese and Korean.

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
  • Forge 1.7.10 - 26.3, Fabric 1.14 - 26.3 and NeoForge 1.20.2 - 26.3 (126 versions)

Built on it

TONI's Magic: Wizardry TONI's Magic: Wizardry
Become a wizard: 13 spells from tomes (Arcane Ray, meteor, blizzard...), an Inscription Table and spell hotkeys, good and dark wizards, the Ancient Mage, Dark Towers and the Arcane Bunker dungeon.

Join the Discord: discord.com/invite/4YAxqzxgBd