1.1
All checks were successful
SorceryCraft/pipeline/head This commit looks good

API is now stable
Fix /spell suggestions
This commit is contained in:
TheBrokenRail 2020-03-08 13:45:15 -04:00
parent f106b485fb
commit e431ddb057
22 changed files with 94 additions and 63 deletions

View File

@ -1,5 +1,9 @@
### Changelog ### Changelog
**1.1**
* API is now stable
* Fix ```/spell``` suggestions
**1.0.14** **1.0.14**
* Update Spell API * Update Spell API

View File

@ -93,11 +93,11 @@ This removes the specified spell from the item in the player's main hand.
```json ```json
{ {
"depends": { "depends": {
"sorcerycraft": ">=VERSION" "sorcerycraft": "1.1.x"
} }
} }
``` ```
3. Create a class extending ```com.thebrokenrail.sorcerycraft.spell.registry.Spell``` 3. Create a class extending ```com.thebrokenrail.sorcerycraft.spell.api.Spell```
```java ```java
public class ExampleSpell extends Spell { public class ExampleSpell extends Spell {
public ExampleSpell(Identifier id, int level) { public ExampleSpell(Identifier id, int level) {

View File

@ -10,7 +10,7 @@ org.gradle.jvmargs = -Xmx1G
loader_version = 0.7.8+build.186 loader_version = 0.7.8+build.186
# Mod Properties # Mod Properties
mod_version = 1.0.14 mod_version = 1.1
maven_group = com.thebrokenrail maven_group = com.thebrokenrail
archives_base_name = sorcerycraft archives_base_name = sorcerycraft

View File

@ -1,7 +1,7 @@
package com.thebrokenrail.sorcerycraft.block; package com.thebrokenrail.sorcerycraft.block;
import com.thebrokenrail.sorcerycraft.SorceryCraft; import com.thebrokenrail.sorcerycraft.SorceryCraft;
import com.thebrokenrail.sorcerycraft.spell.registry.Spell; import com.thebrokenrail.sorcerycraft.spell.api.Spell;
import com.thebrokenrail.sorcerycraft.spell.util.SpellPlayerEntity; import com.thebrokenrail.sorcerycraft.spell.util.SpellPlayerEntity;
import com.thebrokenrail.sorcerycraft.spell.registry.SpellRegistry; import com.thebrokenrail.sorcerycraft.spell.registry.SpellRegistry;
import com.thebrokenrail.sorcerycraft.spell.util.SpellTag; import com.thebrokenrail.sorcerycraft.spell.util.SpellTag;

View File

@ -4,7 +4,7 @@ import com.mojang.blaze3d.systems.RenderSystem;
import com.thebrokenrail.sorcerycraft.SorceryCraft; import com.thebrokenrail.sorcerycraft.SorceryCraft;
import com.thebrokenrail.sorcerycraft.block.CastingTableContainer; import com.thebrokenrail.sorcerycraft.block.CastingTableContainer;
import com.thebrokenrail.sorcerycraft.packet.SelectSpellC2SPacket; import com.thebrokenrail.sorcerycraft.packet.SelectSpellC2SPacket;
import com.thebrokenrail.sorcerycraft.spell.registry.Spell; import com.thebrokenrail.sorcerycraft.spell.api.Spell;
import com.thebrokenrail.sorcerycraft.spell.util.SpellTag; import com.thebrokenrail.sorcerycraft.spell.util.SpellTag;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment; import net.fabricmc.api.Environment;

View File

@ -12,8 +12,9 @@ import java.util.concurrent.CompletableFuture;
import com.mojang.brigadier.suggestion.Suggestions; import com.mojang.brigadier.suggestion.Suggestions;
import com.mojang.brigadier.suggestion.SuggestionsBuilder; import com.mojang.brigadier.suggestion.SuggestionsBuilder;
import com.thebrokenrail.sorcerycraft.SorceryCraft; import com.thebrokenrail.sorcerycraft.SorceryCraft;
import com.thebrokenrail.sorcerycraft.spell.registry.Spell; import com.thebrokenrail.sorcerycraft.spell.api.Spell;
import com.thebrokenrail.sorcerycraft.spell.registry.SpellRegistry; import com.thebrokenrail.sorcerycraft.spell.registry.SpellRegistry;
import net.minecraft.server.command.CommandSource;
import net.minecraft.server.command.ServerCommandSource; import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.text.TranslatableText; import net.minecraft.text.TranslatableText;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
@ -43,11 +44,7 @@ public class SpellArgumentType implements ArgumentType<Identifier> {
@Override @Override
public <S> CompletableFuture<Suggestions> listSuggestions(CommandContext<S> context, SuggestionsBuilder builder) { public <S> CompletableFuture<Suggestions> listSuggestions(CommandContext<S> context, SuggestionsBuilder builder) {
Identifier[] spells = SpellRegistry.getSpellsID(); return CommandSource.suggestIdentifiers(Arrays.asList(SpellRegistry.getSpellsID()), builder);
for (Identifier spell : spells) {
builder.suggest(spell.toString());
}
return builder.buildFuture();
} }
public Identifier parse(StringReader stringReader) throws CommandSyntaxException { public Identifier parse(StringReader stringReader) throws CommandSyntaxException {

View File

@ -1,7 +1,7 @@
package com.thebrokenrail.sorcerycraft.entity; package com.thebrokenrail.sorcerycraft.entity;
import com.thebrokenrail.sorcerycraft.SorceryCraft; import com.thebrokenrail.sorcerycraft.SorceryCraft;
import com.thebrokenrail.sorcerycraft.spell.registry.Spell; import com.thebrokenrail.sorcerycraft.spell.api.Spell;
import com.thebrokenrail.sorcerycraft.spell.registry.SpellRegistry; import com.thebrokenrail.sorcerycraft.spell.registry.SpellRegistry;
import com.thebrokenrail.sorcerycraft.spell.util.SpellTag; import com.thebrokenrail.sorcerycraft.spell.util.SpellTag;
import com.thebrokenrail.sorcerycraft.spell.registry.Spells; import com.thebrokenrail.sorcerycraft.spell.registry.Spells;

View File

@ -2,7 +2,7 @@ package com.thebrokenrail.sorcerycraft.item;
import com.thebrokenrail.sorcerycraft.SorceryCraft; import com.thebrokenrail.sorcerycraft.SorceryCraft;
import com.thebrokenrail.sorcerycraft.entity.SpellEntity; import com.thebrokenrail.sorcerycraft.entity.SpellEntity;
import com.thebrokenrail.sorcerycraft.spell.registry.Spell; import com.thebrokenrail.sorcerycraft.spell.api.Spell;
import com.thebrokenrail.sorcerycraft.spell.registry.SpellRegistry; import com.thebrokenrail.sorcerycraft.spell.registry.SpellRegistry;
import com.thebrokenrail.sorcerycraft.spell.util.SpellTag; import com.thebrokenrail.sorcerycraft.spell.util.SpellTag;
import net.minecraft.client.item.TooltipContext; import net.minecraft.client.item.TooltipContext;

View File

@ -1,6 +1,6 @@
package com.thebrokenrail.sorcerycraft.spell; package com.thebrokenrail.sorcerycraft.spell;
import com.thebrokenrail.sorcerycraft.spell.registry.Spell; import com.thebrokenrail.sorcerycraft.spell.api.Spell;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.item.Items; import net.minecraft.item.Items;

View File

@ -1,6 +1,6 @@
package com.thebrokenrail.sorcerycraft.spell; package com.thebrokenrail.sorcerycraft.spell;
import com.thebrokenrail.sorcerycraft.spell.registry.Spell; import com.thebrokenrail.sorcerycraft.spell.api.Spell;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity; import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.effect.StatusEffects; import net.minecraft.entity.effect.StatusEffects;

View File

@ -1,6 +1,6 @@
package com.thebrokenrail.sorcerycraft.spell; package com.thebrokenrail.sorcerycraft.spell;
import com.thebrokenrail.sorcerycraft.spell.registry.Spell; import com.thebrokenrail.sorcerycraft.spell.api.Spell;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity; import net.minecraft.entity.LivingEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;

View File

@ -1,6 +1,6 @@
package com.thebrokenrail.sorcerycraft.spell; package com.thebrokenrail.sorcerycraft.spell;
import com.thebrokenrail.sorcerycraft.spell.registry.Spell; import com.thebrokenrail.sorcerycraft.spell.api.Spell;
import net.minecraft.block.AbstractFireBlock; import net.minecraft.block.AbstractFireBlock;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;

View File

@ -1,6 +1,6 @@
package com.thebrokenrail.sorcerycraft.spell; package com.thebrokenrail.sorcerycraft.spell;
import com.thebrokenrail.sorcerycraft.spell.registry.Spell; import com.thebrokenrail.sorcerycraft.spell.api.Spell;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity; import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.effect.StatusEffects; import net.minecraft.entity.effect.StatusEffects;

View File

@ -1,6 +1,6 @@
package com.thebrokenrail.sorcerycraft.spell; package com.thebrokenrail.sorcerycraft.spell;
import com.thebrokenrail.sorcerycraft.spell.registry.Spell; import com.thebrokenrail.sorcerycraft.spell.api.Spell;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.item.Items; import net.minecraft.item.Items;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;

View File

@ -1,6 +1,6 @@
package com.thebrokenrail.sorcerycraft.spell; package com.thebrokenrail.sorcerycraft.spell;
import com.thebrokenrail.sorcerycraft.spell.registry.Spell; import com.thebrokenrail.sorcerycraft.spell.api.Spell;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity; import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.effect.StatusEffectInstance; import net.minecraft.entity.effect.StatusEffectInstance;

View File

@ -1,6 +1,6 @@
package com.thebrokenrail.sorcerycraft.spell; package com.thebrokenrail.sorcerycraft.spell;
import com.thebrokenrail.sorcerycraft.spell.registry.Spell; import com.thebrokenrail.sorcerycraft.spell.api.Spell;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.item.Items; import net.minecraft.item.Items;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;

View File

@ -1,6 +1,6 @@
package com.thebrokenrail.sorcerycraft.spell; package com.thebrokenrail.sorcerycraft.spell;
import com.thebrokenrail.sorcerycraft.spell.registry.Spell; import com.thebrokenrail.sorcerycraft.spell.api.Spell;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity; import net.minecraft.entity.LivingEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;

View File

@ -0,0 +1,68 @@
package com.thebrokenrail.sorcerycraft.spell.api;
import net.minecraft.entity.Entity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Identifier;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.world.World;
public abstract class Spell {
private final Identifier id;
private final int level;
public Spell(Identifier id, int level) {
this.id = id;
this.level = level;
}
/**
* @return The ID of this Spell
*/
public Identifier getID() {
return id;
}
/**
* @return The level of this Spell
*/
public int getLevel() {
return level;
}
/**
* Execute this Spell on an Entity
* @param world World
* @param source A SpellEntity
* @param attacker The Entity that cast this Spell
* @param target The Target
*/
public void execute(World world, Entity source, Entity attacker, Entity target) {
// NOOP
}
/**
* Cast this Spell on a block
* @param world World
* @param source A SpellEntity
* @param attacker The Entity that cast this Spell
* @param hitResult The block's HitResult
*/
public void execute(World world, Entity source, Entity attacker, BlockHitResult hitResult) {
// NOOP
}
/**
* @return The amount of levels required to make this Spell in a Casting Table
*/
public abstract int getXPCost();
/**
* @return The item(s) required to make ExampleSpell in a Casting Table, or ItemStack.EMPTY if an item is not required
*/
public abstract ItemStack getItemCost();
/**
* @return The maximum level of this Spell
*/
public abstract int getMaxLevel();
}

View File

@ -1,39 +0,0 @@
package com.thebrokenrail.sorcerycraft.spell.registry;
import net.minecraft.entity.Entity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Identifier;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.world.World;
public abstract class Spell {
private final Identifier id;
private final int level;
public Spell(Identifier id, int level) {
this.id = id;
this.level = level;
}
public Identifier getID() {
return id;
}
public int getLevel() {
return level;
}
public void execute(World world, Entity source, Entity attacker, Entity target) {
// NOOP
}
public void execute(World world, Entity source, Entity attacker, BlockHitResult hitResult) {
// NOOP
}
public abstract int getXPCost();
public abstract ItemStack getItemCost();
public abstract int getMaxLevel();
}

View File

@ -1,5 +1,6 @@
package com.thebrokenrail.sorcerycraft.spell.registry; package com.thebrokenrail.sorcerycraft.spell.registry;
import com.thebrokenrail.sorcerycraft.spell.api.Spell;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;

View File

@ -1,6 +1,6 @@
package com.thebrokenrail.sorcerycraft.spell.util; package com.thebrokenrail.sorcerycraft.spell.util;
import com.thebrokenrail.sorcerycraft.spell.registry.Spell; import com.thebrokenrail.sorcerycraft.spell.api.Spell;
import com.thebrokenrail.sorcerycraft.spell.registry.SpellRegistry; import com.thebrokenrail.sorcerycraft.spell.registry.SpellRegistry;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.loot.condition.LootCondition; import net.minecraft.loot.condition.LootCondition;

View File

@ -1,7 +1,7 @@
package com.thebrokenrail.sorcerycraft.spell.util; package com.thebrokenrail.sorcerycraft.spell.util;
import com.thebrokenrail.sorcerycraft.SorceryCraft; import com.thebrokenrail.sorcerycraft.SorceryCraft;
import com.thebrokenrail.sorcerycraft.spell.registry.Spell; import com.thebrokenrail.sorcerycraft.spell.api.Spell;
import com.thebrokenrail.sorcerycraft.spell.registry.SpellRegistry; import com.thebrokenrail.sorcerycraft.spell.registry.SpellRegistry;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;