From cf3376ec90491714b3e0903937cd4e074ecb4a09 Mon Sep 17 00:00:00 2001 From: TheBrokenRail Date: Sun, 8 Mar 2020 11:10:50 -0400 Subject: [PATCH] Add API Docs --- README.md | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 66 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index adce772..141b796 100644 --- a/README.md +++ b/README.md @@ -77,4 +77,69 @@ This teaches the specified spell to the specified player. This adds the specified spell to the item in the player's main hand. #### ```/spell remove ``` -This removes the specified spell from the item in the player's main hand. \ No newline at end of file +This removes the specified spell from the item in the player's main hand. + +## API +1. Add Dependency to Gradle + ```gradle + repositories { + maven { url 'https://jitpack.io' } + } + dependencies { + modImplementation 'com.thebrokenrail:sorcerycraft:VERSION' + } + ``` +2. Add Dependency to ```fabric.mod.json``` + ```json + { + "depends": { + "sorcerycraft": "VERSION" + } + } + ``` +3. Create a class extending ```com.thebrokenrail.sorcerycraft.spell.registry.Spell``` + ```java + 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 + } + + @Override + public void execute(World world, BlockHitResult hitResult) { + // Called when ExampleSpell hits a block + } + + @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 + } + + @Override + public int getMaxLevel() { + // Return ExampleSpell's maximum level + } + } + ``` +4. Register the Spell in your ModInitializer + ```java + public class ExampleMod implements ModInitializer { + @Override + public void onInitialize() { + SpellRegistry.registerSpell(new Identifier("modid", "example_spell"), ExampleSpell.class); + } + } + ``` + +#### Useful Methods +- ```Spell.getLevel()``` +- ```Spell.getID()``` \ No newline at end of file