Add API Docs
SorceryCraft/pipeline/head This commit looks good Details

This commit is contained in:
TheBrokenRail 2020-03-08 11:10:50 -04:00
parent 07d1d44f52
commit cf3376ec90
1 changed files with 66 additions and 1 deletions

View File

@ -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 <player> <spell-id>```
This removes the specified spell from the item in the player's main hand.
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()```