diff --git a/src/main/java/com/minelittlepony/unicopia/entity/EntityProjectile.java b/src/main/java/com/minelittlepony/unicopia/entity/EntityProjectile.java index cf552a0c..49cfb8d1 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/EntityProjectile.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/EntityProjectile.java @@ -23,6 +23,11 @@ import net.minecraft.util.EnumParticleTypes; import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.World; +/** + * A generalised version of Mojang's projectile entity class with added support for a custom appearance and water phobia. + * + * Can also carry a spell if needed. + */ public class EntityProjectile extends EntitySnowball implements IMagicals, ICaster { private static final DataParameter ITEM = EntityDataManager diff --git a/src/main/java/com/minelittlepony/unicopia/entity/IMagicals.java b/src/main/java/com/minelittlepony/unicopia/entity/IMagicals.java index ca27aaa7..af62721b 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/IMagicals.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/IMagicals.java @@ -2,6 +2,10 @@ package com.minelittlepony.unicopia.entity; import net.minecraft.entity.passive.IAnimals; +/** + * Any entities with magical abilities. + * Casters are automatically considered magic, for obvious reasons. + */ public interface IMagicals extends IAnimals { } diff --git a/src/main/java/com/minelittlepony/unicopia/player/IOwned.java b/src/main/java/com/minelittlepony/unicopia/player/IOwned.java index d5984890..ae964eb4 100644 --- a/src/main/java/com/minelittlepony/unicopia/player/IOwned.java +++ b/src/main/java/com/minelittlepony/unicopia/player/IOwned.java @@ -1,9 +1,20 @@ package com.minelittlepony.unicopia.player; +/** + * Interface for things that can be owned. + * + * @param The type of object that owns us. + */ public interface IOwned { + /** + * Updates the owner of this object. + */ void setOwner(E owner); + /** + * Gets the owner that holds this object. + */ E getOwner(); diff --git a/src/main/java/com/minelittlepony/unicopia/spell/IHeldEffect.java b/src/main/java/com/minelittlepony/unicopia/spell/IHeldEffect.java index f9a0f75d..67bb0846 100644 --- a/src/main/java/com/minelittlepony/unicopia/spell/IHeldEffect.java +++ b/src/main/java/com/minelittlepony/unicopia/spell/IHeldEffect.java @@ -2,6 +2,9 @@ package com.minelittlepony.unicopia.spell; import com.minelittlepony.unicopia.player.IPlayer; +/** + * Represents a passive spell that does something when held in the player's hand. + */ public interface IHeldEffect extends IMagicEffect { /** * Called every tick when held in a player's inventory. diff --git a/src/main/java/com/minelittlepony/unicopia/spell/ILevelled.java b/src/main/java/com/minelittlepony/unicopia/spell/ILevelled.java index 99af16a1..bb451028 100644 --- a/src/main/java/com/minelittlepony/unicopia/spell/ILevelled.java +++ b/src/main/java/com/minelittlepony/unicopia/spell/ILevelled.java @@ -1,5 +1,8 @@ package com.minelittlepony.unicopia.spell; +/** + * Object with levelling capabilities. + */ public interface ILevelled { /** diff --git a/src/main/java/com/minelittlepony/unicopia/spell/IRangedEffect.java b/src/main/java/com/minelittlepony/unicopia/spell/IRangedEffect.java deleted file mode 100644 index 2eea5293..00000000 --- a/src/main/java/com/minelittlepony/unicopia/spell/IRangedEffect.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.minelittlepony.unicopia.spell; - -import net.minecraft.block.state.IBlockState; -import net.minecraft.init.SoundEvents; -import net.minecraft.item.ItemStack; -import net.minecraft.util.SoundEvent; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; - -public interface IRangedEffect extends IMagicEffect { - void onImpact(World world, BlockPos pos, IBlockState state); - - default SoundEvent getThrowSound(ItemStack stack) { - return SoundEvents.ENTITY_SNOWBALL_THROW; - } -} diff --git a/src/main/java/com/minelittlepony/unicopia/spell/ISuppressable.java b/src/main/java/com/minelittlepony/unicopia/spell/ISuppressable.java index 382bdae9..9c40f42b 100644 --- a/src/main/java/com/minelittlepony/unicopia/spell/ISuppressable.java +++ b/src/main/java/com/minelittlepony/unicopia/spell/ISuppressable.java @@ -1,10 +1,22 @@ package com.minelittlepony.unicopia.spell; +/** + * Magic effects that can be suppressed by other nearby effects. + */ public interface ISuppressable extends IMagicEffect { + /** + * Returns true if this spell is currently still suppressed. + */ boolean getSuppressed(); + /** + * Returns true if this spell can be suppressed by the given other spell and caster. + */ boolean isVulnerable(ICaster otherSource, IMagicEffect other); + /** + * Event triggered when this effect is suppressed. + */ void onSuppressed(ICaster otherSource); } diff --git a/src/main/java/com/minelittlepony/unicopia/spell/ITossedEffect.java b/src/main/java/com/minelittlepony/unicopia/spell/ITossedEffect.java index c39cf7ec..588859c4 100644 --- a/src/main/java/com/minelittlepony/unicopia/spell/ITossedEffect.java +++ b/src/main/java/com/minelittlepony/unicopia/spell/ITossedEffect.java @@ -14,18 +14,29 @@ import net.minecraft.util.SoundCategory; import net.minecraft.util.SoundEvent; import net.minecraft.world.World; +/** + * Magic effects that can be thrown. + */ public interface ITossedEffect extends IMagicEffect, ITossable> { default SoundEvent getThrowSound(ICaster caster) { return SoundEvents.ITEM_CHORUS_FRUIT_TELEPORT; } + /** + * Gets the appearance to be used when projecting this spell. + */ default ItemStack getCastAppearance(ICaster caster) { - Item item = this.getAffinity() == SpellAffinity.BAD ? UItems.curse : UItems.spell; + Item item = getAffinity() == SpellAffinity.BAD ? UItems.curse : UItems.spell; return SpellRegistry.instance().enchantStack(new ItemStack(item), getName()); } + /** + * Projects this spell. + * + * Returns the resulting projectile entity for customization (or null if on the client). + */ @Nullable default EntityProjectile toss(ICaster caster) { World world = caster.getWorld(); @@ -34,7 +45,7 @@ public interface ITossedEffect extends IMagicEffect, ITossable> { world.playSound(null, entity.posX, entity.posY, entity.posZ, getThrowSound(caster), SoundCategory.NEUTRAL, 0.7F, 0.4F / (world.rand.nextFloat() * 0.4F + 0.8F)); - if (!world.isRemote) { + if (caster.isLocal()) { EntityProjectile projectile = new EntityProjectile(world, caster.getOwner()); projectile.setItem(getCastAppearance(caster)); diff --git a/src/main/java/com/minelittlepony/unicopia/tossable/ITossable.java b/src/main/java/com/minelittlepony/unicopia/tossable/ITossable.java index 15b24194..913f6e8f 100644 --- a/src/main/java/com/minelittlepony/unicopia/tossable/ITossable.java +++ b/src/main/java/com/minelittlepony/unicopia/tossable/ITossable.java @@ -8,12 +8,22 @@ import net.minecraft.util.SoundEvent; import net.minecraft.util.math.BlockPos; public interface ITossable { + + /** + * Called once the projectile lands either hitting the ground or an entity. + */ void onImpact(ICaster caster, BlockPos pos, IBlockState state); + /** + * The sound made when thrown. + */ default SoundEvent getThrowSound(T stack) { return SoundEvents.ENTITY_SNOWBALL_THROW; } + /** + * The amount of damage to be dealt when the projectile collides with an entity. + */ default int getThrowDamage(T stack) { return 0; }