This repository has been archived on 2023-11-26. You can view files and clone it, but cannot push or open issues or pull requests.
SorceryCraft/API.md
TheBrokenRail c592b9e9af
All checks were successful
SorceryCraft/pipeline/head This commit looks good
1.1.13
Update Mappings
Improve /spell command
2020-03-17 13:26:10 -04:00

1.9 KiB

API

Getting Started

  1. Add Dependency to Gradle
    repositories {
        maven { url 'https://jitpack.io' }
    }
    dependencies {
        modImplementation 'com.thebrokenrail:sorcerycraft:1.1.+'
    }
    
  2. Add Dependency to fabric.mod.json
    {
        "depends": {
            "sorcerycraft": "1.1.x"
        }
    }
    
  3. Create a class extending com.thebrokenrail.sorcerycraft.spell.api.Spell
    public class ExampleSpell extends Spell {
       public ExampleSpell(Identifier id, int level) {
           super(id, level);
       }
    
       @Override
       public void execute(Entity target, Entity source, Entity attacker) {
           // Called when ExampleSpell hits an entity
           // Not required to override
       }
    
       @Override
       public void execute(World world, BlockHitResult hitResult) {
           // Called when ExampleSpell hits a block
           // Not required to override
       }
    
       @Override
       public int getXPCost() {
           // Return the amount of levels required to make ExampleSpell in a Casting Table
       }
    
       @Override
       public ItemStack getItemCost() {
           // Return the item(s) required to make ExampleSpell in a Casting Table
           // Return ItemStack.EMPTY if an item is not required
       }
    
       @Override
       public int getMaxLevel() {
           // Return ExampleSpell's maximum level
       }
    }
    
  4. Register the spell in your ModInitializer
    public class ExampleMod implements ModInitializer {
        public static final Identifier EXAMPLE_SPELL = SpellRegistry.register(new Identifier("modid", "example_spell"), ExampleSpell.class);
    }
    
  5. Add Spell Translation
    {
        "spell.modid.example_spell": "Example"
    }
    

Useful Methods

  • Spell.getLevel()
  • Spell.getID()