diff --git a/CHANGELOG.md b/CHANGELOG.md index feccb58..024805c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ ### Changelog +**1.1** +* API is now stable +* Fix ```/spell``` suggestions + **1.0.14** * Update Spell API diff --git a/README.md b/README.md index 164450a..c8df36c 100644 --- a/README.md +++ b/README.md @@ -93,11 +93,11 @@ This removes the specified spell from the item in the player's main hand. ```json { "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 public class ExampleSpell extends Spell { public ExampleSpell(Identifier id, int level) { diff --git a/gradle.properties b/gradle.properties index e489bc5..3b3572c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -10,7 +10,7 @@ org.gradle.jvmargs = -Xmx1G loader_version = 0.7.8+build.186 # Mod Properties - mod_version = 1.0.14 + mod_version = 1.1 maven_group = com.thebrokenrail archives_base_name = sorcerycraft diff --git a/src/main/java/com/thebrokenrail/sorcerycraft/block/CastingTableContainer.java b/src/main/java/com/thebrokenrail/sorcerycraft/block/CastingTableContainer.java index 6efe4bf..3e9d84e 100644 --- a/src/main/java/com/thebrokenrail/sorcerycraft/block/CastingTableContainer.java +++ b/src/main/java/com/thebrokenrail/sorcerycraft/block/CastingTableContainer.java @@ -1,7 +1,7 @@ package com.thebrokenrail.sorcerycraft.block; 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.registry.SpellRegistry; import com.thebrokenrail.sorcerycraft.spell.util.SpellTag; diff --git a/src/main/java/com/thebrokenrail/sorcerycraft/client/block/CastingTableScreen.java b/src/main/java/com/thebrokenrail/sorcerycraft/client/block/CastingTableScreen.java index 9558661..6ccf277 100644 --- a/src/main/java/com/thebrokenrail/sorcerycraft/client/block/CastingTableScreen.java +++ b/src/main/java/com/thebrokenrail/sorcerycraft/client/block/CastingTableScreen.java @@ -4,7 +4,7 @@ import com.mojang.blaze3d.systems.RenderSystem; import com.thebrokenrail.sorcerycraft.SorceryCraft; import com.thebrokenrail.sorcerycraft.block.CastingTableContainer; 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 net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; diff --git a/src/main/java/com/thebrokenrail/sorcerycraft/command/SpellArgumentType.java b/src/main/java/com/thebrokenrail/sorcerycraft/command/SpellArgumentType.java index bcaaa72..61f91df 100644 --- a/src/main/java/com/thebrokenrail/sorcerycraft/command/SpellArgumentType.java +++ b/src/main/java/com/thebrokenrail/sorcerycraft/command/SpellArgumentType.java @@ -12,8 +12,9 @@ import java.util.concurrent.CompletableFuture; import com.mojang.brigadier.suggestion.Suggestions; import com.mojang.brigadier.suggestion.SuggestionsBuilder; 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 net.minecraft.server.command.CommandSource; import net.minecraft.server.command.ServerCommandSource; import net.minecraft.text.TranslatableText; import net.minecraft.util.Identifier; @@ -43,11 +44,7 @@ public class SpellArgumentType implements ArgumentType { @Override public CompletableFuture listSuggestions(CommandContext context, SuggestionsBuilder builder) { - Identifier[] spells = SpellRegistry.getSpellsID(); - for (Identifier spell : spells) { - builder.suggest(spell.toString()); - } - return builder.buildFuture(); + return CommandSource.suggestIdentifiers(Arrays.asList(SpellRegistry.getSpellsID()), builder); } public Identifier parse(StringReader stringReader) throws CommandSyntaxException { diff --git a/src/main/java/com/thebrokenrail/sorcerycraft/entity/SpellEntity.java b/src/main/java/com/thebrokenrail/sorcerycraft/entity/SpellEntity.java index e7f9a35..bc1be7d 100644 --- a/src/main/java/com/thebrokenrail/sorcerycraft/entity/SpellEntity.java +++ b/src/main/java/com/thebrokenrail/sorcerycraft/entity/SpellEntity.java @@ -1,7 +1,7 @@ package com.thebrokenrail.sorcerycraft.entity; 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.util.SpellTag; import com.thebrokenrail.sorcerycraft.spell.registry.Spells; diff --git a/src/main/java/com/thebrokenrail/sorcerycraft/item/SpellItem.java b/src/main/java/com/thebrokenrail/sorcerycraft/item/SpellItem.java index e934361..5b81d80 100644 --- a/src/main/java/com/thebrokenrail/sorcerycraft/item/SpellItem.java +++ b/src/main/java/com/thebrokenrail/sorcerycraft/item/SpellItem.java @@ -2,7 +2,7 @@ package com.thebrokenrail.sorcerycraft.item; import com.thebrokenrail.sorcerycraft.SorceryCraft; 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.util.SpellTag; import net.minecraft.client.item.TooltipContext; diff --git a/src/main/java/com/thebrokenrail/sorcerycraft/spell/CoolingSpell.java b/src/main/java/com/thebrokenrail/sorcerycraft/spell/CoolingSpell.java index b2bb0cf..64be36d 100644 --- a/src/main/java/com/thebrokenrail/sorcerycraft/spell/CoolingSpell.java +++ b/src/main/java/com/thebrokenrail/sorcerycraft/spell/CoolingSpell.java @@ -1,6 +1,6 @@ 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.item.ItemStack; import net.minecraft.item.Items; diff --git a/src/main/java/com/thebrokenrail/sorcerycraft/spell/DamageSpell.java b/src/main/java/com/thebrokenrail/sorcerycraft/spell/DamageSpell.java index f6c8976..eb8a6f4 100644 --- a/src/main/java/com/thebrokenrail/sorcerycraft/spell/DamageSpell.java +++ b/src/main/java/com/thebrokenrail/sorcerycraft/spell/DamageSpell.java @@ -1,6 +1,6 @@ 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.LivingEntity; import net.minecraft.entity.effect.StatusEffects; diff --git a/src/main/java/com/thebrokenrail/sorcerycraft/spell/DissolveSpell.java b/src/main/java/com/thebrokenrail/sorcerycraft/spell/DissolveSpell.java index b032140..077cf24 100644 --- a/src/main/java/com/thebrokenrail/sorcerycraft/spell/DissolveSpell.java +++ b/src/main/java/com/thebrokenrail/sorcerycraft/spell/DissolveSpell.java @@ -1,6 +1,6 @@ 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.LivingEntity; import net.minecraft.item.ItemStack; diff --git a/src/main/java/com/thebrokenrail/sorcerycraft/spell/FlameSpell.java b/src/main/java/com/thebrokenrail/sorcerycraft/spell/FlameSpell.java index 0f78ff6..534c711 100644 --- a/src/main/java/com/thebrokenrail/sorcerycraft/spell/FlameSpell.java +++ b/src/main/java/com/thebrokenrail/sorcerycraft/spell/FlameSpell.java @@ -1,6 +1,6 @@ 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.entity.Entity; import net.minecraft.item.ItemStack; diff --git a/src/main/java/com/thebrokenrail/sorcerycraft/spell/HealSpell.java b/src/main/java/com/thebrokenrail/sorcerycraft/spell/HealSpell.java index d0a5862..feaf8f7 100644 --- a/src/main/java/com/thebrokenrail/sorcerycraft/spell/HealSpell.java +++ b/src/main/java/com/thebrokenrail/sorcerycraft/spell/HealSpell.java @@ -1,6 +1,6 @@ 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.LivingEntity; import net.minecraft.entity.effect.StatusEffects; diff --git a/src/main/java/com/thebrokenrail/sorcerycraft/spell/InwardSpell.java b/src/main/java/com/thebrokenrail/sorcerycraft/spell/InwardSpell.java index 11750d9..06a727d 100644 --- a/src/main/java/com/thebrokenrail/sorcerycraft/spell/InwardSpell.java +++ b/src/main/java/com/thebrokenrail/sorcerycraft/spell/InwardSpell.java @@ -1,6 +1,6 @@ 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.Items; import net.minecraft.util.Identifier; diff --git a/src/main/java/com/thebrokenrail/sorcerycraft/spell/LevitateSpell.java b/src/main/java/com/thebrokenrail/sorcerycraft/spell/LevitateSpell.java index 25b131c..e57782b 100644 --- a/src/main/java/com/thebrokenrail/sorcerycraft/spell/LevitateSpell.java +++ b/src/main/java/com/thebrokenrail/sorcerycraft/spell/LevitateSpell.java @@ -1,6 +1,6 @@ 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.LivingEntity; import net.minecraft.entity.effect.StatusEffectInstance; diff --git a/src/main/java/com/thebrokenrail/sorcerycraft/spell/SteadfastSpell.java b/src/main/java/com/thebrokenrail/sorcerycraft/spell/SteadfastSpell.java index c63e0d2..be0e162 100644 --- a/src/main/java/com/thebrokenrail/sorcerycraft/spell/SteadfastSpell.java +++ b/src/main/java/com/thebrokenrail/sorcerycraft/spell/SteadfastSpell.java @@ -1,6 +1,6 @@ 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.Items; import net.minecraft.util.Identifier; diff --git a/src/main/java/com/thebrokenrail/sorcerycraft/spell/TeleportSpell.java b/src/main/java/com/thebrokenrail/sorcerycraft/spell/TeleportSpell.java index 0f10a94..bdeec39 100644 --- a/src/main/java/com/thebrokenrail/sorcerycraft/spell/TeleportSpell.java +++ b/src/main/java/com/thebrokenrail/sorcerycraft/spell/TeleportSpell.java @@ -1,6 +1,6 @@ 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.LivingEntity; import net.minecraft.item.ItemStack; diff --git a/src/main/java/com/thebrokenrail/sorcerycraft/spell/api/Spell.java b/src/main/java/com/thebrokenrail/sorcerycraft/spell/api/Spell.java new file mode 100644 index 0000000..2cf93b1 --- /dev/null +++ b/src/main/java/com/thebrokenrail/sorcerycraft/spell/api/Spell.java @@ -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(); +} diff --git a/src/main/java/com/thebrokenrail/sorcerycraft/spell/registry/Spell.java b/src/main/java/com/thebrokenrail/sorcerycraft/spell/registry/Spell.java deleted file mode 100644 index c565487..0000000 --- a/src/main/java/com/thebrokenrail/sorcerycraft/spell/registry/Spell.java +++ /dev/null @@ -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(); -} diff --git a/src/main/java/com/thebrokenrail/sorcerycraft/spell/registry/SpellRegistry.java b/src/main/java/com/thebrokenrail/sorcerycraft/spell/registry/SpellRegistry.java index 9e8f30d..a3a02f4 100644 --- a/src/main/java/com/thebrokenrail/sorcerycraft/spell/registry/SpellRegistry.java +++ b/src/main/java/com/thebrokenrail/sorcerycraft/spell/registry/SpellRegistry.java @@ -1,5 +1,6 @@ package com.thebrokenrail.sorcerycraft.spell.registry; +import com.thebrokenrail.sorcerycraft.spell.api.Spell; import net.minecraft.util.Identifier; import java.lang.reflect.InvocationTargetException; diff --git a/src/main/java/com/thebrokenrail/sorcerycraft/spell/util/RandomSpellLootTableFunction.java b/src/main/java/com/thebrokenrail/sorcerycraft/spell/util/RandomSpellLootTableFunction.java index 0b8d1e7..015ad96 100644 --- a/src/main/java/com/thebrokenrail/sorcerycraft/spell/util/RandomSpellLootTableFunction.java +++ b/src/main/java/com/thebrokenrail/sorcerycraft/spell/util/RandomSpellLootTableFunction.java @@ -1,6 +1,6 @@ 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 net.minecraft.item.ItemStack; import net.minecraft.loot.condition.LootCondition; diff --git a/src/main/java/com/thebrokenrail/sorcerycraft/spell/util/SpellTag.java b/src/main/java/com/thebrokenrail/sorcerycraft/spell/util/SpellTag.java index 582ccd5..242aa84 100644 --- a/src/main/java/com/thebrokenrail/sorcerycraft/spell/util/SpellTag.java +++ b/src/main/java/com/thebrokenrail/sorcerycraft/spell/util/SpellTag.java @@ -1,7 +1,7 @@ package com.thebrokenrail.sorcerycraft.spell.util; 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 net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack;