Home Developers
Developers
Cancel

Developers

General

With the 2.0.0 release of Iron’s Spells N Spellbooks you can now register your own spells and schools! There is also an API to compile against. If you are interested in developing using us as a dependency you can help shape the roadmap by joining our discord and asking questions or providing feedback/suggestions.

API vs Full Mod Dependency

Anything inside the io.redspace.ironsspellbooks.api namespace should be fairly stable. If you use anything outside of this you may experience breaking changes when we release. You can request items moved into API by pinging Iron or Smalls in the discord. If you want it done fast you can always submit a pull request to our main repo, https://github.com/iron431/Irons-Spells-n-Spellbooks

Example Repo

Here is an example mod that shows you how to register a spell and get started.

https://github.com/iron431/Irons-Example-Mod

The example mod is setup to use our SNAPSHOT builds. https://code.redspace.io/#/snapshots/io/redspace/ironsspellbooks/irons_spellbooks

Spell Registration

To register spells you will need to create your own registry using a DeferredRegister

1
2
3
4
5
6
7
8
9
10
11
12
13
public class ExampleSpellRegistry {
    public static final DeferredRegister<AbstractSpell> SPELLS = DeferredRegister.create(SpellRegistry.SPELL_REGISTRY_KEY, IronsExampleMod.MODID);

    public static void register(IEventBus eventBus) {
        SPELLS.register(eventBus);
    }

    public static RegistryObject<AbstractSpell> registerSpell(AbstractSpell spell) {
        return SPELLS.register(spell.getSpellName(), () -> spell);
    }

    public static final RegistryObject<AbstractSpell> SUPER_HEAL_SPELL = registerSpell(new SuperHealSpell());
}

Configuration

In order have your spells configuration injected into the server config file for Iron’s Spells n Spellbooks just add the @AutoSpellConfig annotation to the class for your spell.

The default values for the configuration are set by overriding the getDefaultConfig() method.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import io.redspace.ironsspellbooks.api.spells.*;

@AutoSpellConfig
public class YourNewSpell extends AbstractSpell {
    
    //Default configuration values
    private final DefaultConfig defaultConfig = new DefaultConfig()
      .setMinRarity(SpellRarity.RARE)
      .setSchoolResource(SchoolRegistry.HOLY_RESOURCE)
      .setMaxLevel(10)
      .setCooldownSeconds(20)
      .build();

    @Override
    public DefaultConfig getDefaultConfig() {
        return defaultConfig;
    }
  
    //Your code here
}

@AutoSpellConfig public class SuperHealSpell extends AbstractSpell {

You can now create spells the same way we do in the core mod. For examples of spells you can look at any of the spells here.

https://github.com/iron431/Irons-Spells-n-Spellbooks/tree/1.19.2/src/main/java/io/redspace/ironsspellbooks/spells

Contents