diff --git a/src/main/java/com/minelittlepony/unicopia/magic/AttachedMagicEffect.java b/src/main/java/com/minelittlepony/unicopia/magic/AttachedMagicEffect.java index bb01edb8..b7d3bb8e 100644 --- a/src/main/java/com/minelittlepony/unicopia/magic/AttachedMagicEffect.java +++ b/src/main/java/com/minelittlepony/unicopia/magic/AttachedMagicEffect.java @@ -1,5 +1,8 @@ package com.minelittlepony.unicopia.magic; +/** + * A magic effect that does something when attached to an entity. + */ public interface AttachedMagicEffect extends MagicEffect { /** * Called every tick when attached to a player. diff --git a/src/main/java/com/minelittlepony/unicopia/magic/spell/AbstractRangedAreaSpell.java b/src/main/java/com/minelittlepony/unicopia/magic/spell/AbstractRangedAreaSpell.java new file mode 100644 index 00000000..863f53ce --- /dev/null +++ b/src/main/java/com/minelittlepony/unicopia/magic/spell/AbstractRangedAreaSpell.java @@ -0,0 +1,45 @@ +package com.minelittlepony.unicopia.magic.spell; + +import com.minelittlepony.unicopia.magic.AttachedMagicEffect; +import com.minelittlepony.unicopia.magic.Caster; + +public abstract class AbstractRangedAreaSpell extends AbstractSpell implements AttachedMagicEffect { + + @Override + public int getMaxLevelCutOff(Caster source) { + return 17; + } + + @Override + public float getMaxExhaustion(Caster caster) { + return 1000; + } + + @Override + public float getExhaustion(Caster caster) { + float max = getMaxLevelCutOff(caster); + float current = caster.getCurrentLevel(); + + if (current > max) { + float maxEc = getMaxExhaustion(caster); + + current -= max; + current /= max; + current /= maxEc; + + return maxEc - current; + } + + return super.getExhaustion(caster); + } + + @Override + public boolean updateOnPerson(Caster caster) { + return update(caster); + } + + @Override + public void renderOnPerson(Caster caster) { + render(caster); + } +} \ No newline at end of file diff --git a/src/main/java/com/minelittlepony/unicopia/magic/spell/AbstractSpell.java b/src/main/java/com/minelittlepony/unicopia/magic/spell/AbstractSpell.java index d12e8152..9335354d 100644 --- a/src/main/java/com/minelittlepony/unicopia/magic/spell/AbstractSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/magic/spell/AbstractSpell.java @@ -60,35 +60,4 @@ public abstract class AbstractSpell implements MagicEffect { setDirty(false); isDead = compound.getBoolean("dead"); } - - public static abstract class RangedAreaSpell extends AbstractSpell { - - @Override - public int getMaxLevelCutOff(Caster source) { - return 17; - } - - @Override - public float getMaxExhaustion(Caster caster) { - return 1000; - } - - @Override - public float getExhaustion(Caster caster) { - float max = getMaxLevelCutOff(caster); - float current = caster.getCurrentLevel(); - - if (current > max) { - float maxEc = getMaxExhaustion(caster); - - current -= max; - current /= max; - current /= maxEc; - - return maxEc - current; - } - - return super.getExhaustion(caster); - } - } } diff --git a/src/main/java/com/minelittlepony/unicopia/magic/spell/FaithfulAssistantSpell.java b/src/main/java/com/minelittlepony/unicopia/magic/spell/FaithfulAssistantSpell.java index 4f626955..4f65e471 100644 --- a/src/main/java/com/minelittlepony/unicopia/magic/spell/FaithfulAssistantSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/magic/spell/FaithfulAssistantSpell.java @@ -16,7 +16,10 @@ import net.minecraft.util.math.Box; * Spike The Dragon, but in rock form. * * It follows you around and can pick up/carry other gems. + * + * @Deprecated Replace with a minion mob */ +@Deprecated public class FaithfulAssistantSpell extends AbstractSpell { private static final Box EFFECT_BOUNDS = new Box(-2, -2, -2, 2, 2, 2); diff --git a/src/main/java/com/minelittlepony/unicopia/magic/spell/FireSpell.java b/src/main/java/com/minelittlepony/unicopia/magic/spell/FireSpell.java index 21d52475..d7cdeb49 100644 --- a/src/main/java/com/minelittlepony/unicopia/magic/spell/FireSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/magic/spell/FireSpell.java @@ -38,14 +38,13 @@ import net.minecraft.util.math.Direction; import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; -public class FireSpell extends AbstractSpell.RangedAreaSpell implements Useable, DispenceableMagicEffect { +/** + * Simple fire spell that triggers an effect when used on a block. + */ +public class FireSpell extends AbstractRangedAreaSpell implements Useable, DispenceableMagicEffect { - private static final Shape visual_effect_region = new Sphere(false, 0.5); - private static final Shape effect_range = new Sphere(false, 4); - - public FireSpell() { - - } + private static final Shape VISUAL_EFFECT_RANGE = new Sphere(false, 0.5); + private static final Shape EFFECT_RANGE = new Sphere(false, 4); @Override public String getName() { @@ -69,12 +68,11 @@ public class FireSpell extends AbstractSpell.RangedAreaSpell implements Useable, @Override public void render(Caster source) { - source.spawnParticles(visual_effect_region, source.getCurrentLevel() * 6, pos -> { + source.spawnParticles(VISUAL_EFFECT_RANGE, source.getCurrentLevel() * 6, pos -> { source.addParticle(ParticleTypes.LARGE_SMOKE, pos, Vec3d.ZERO); }); } - @Override public CastResult onUse(ItemUsageContext context, Affinity affinity) { boolean result = false; @@ -85,7 +83,7 @@ public class FireSpell extends AbstractSpell.RangedAreaSpell implements Useable, if (player == null || player.isSneaking()) { result = applyBlocks(context.getWorld(), pos); } else { - result = PosHelper.getAllInRegionMutable(pos, effect_range).reduce(result, + result = PosHelper.getAllInRegionMutable(pos, EFFECT_RANGE).reduce(result, (r, i) -> applyBlocks(context.getWorld(), i), (a, b) -> a || b); } @@ -110,7 +108,7 @@ public class FireSpell extends AbstractSpell.RangedAreaSpell implements Useable, public CastResult onDispenced(BlockPos pos, Direction facing, BlockPointer source, Affinity affinity) { pos = pos.offset(facing, 4); - return CastResult.cancelled(PosHelper.getAllInRegionMutable(pos, effect_range).reduce(false, + return CastResult.cancelled(PosHelper.getAllInRegionMutable(pos, EFFECT_RANGE).reduce(false, (r, i) -> applyBlocks(source.getWorld(), i), (a, b) -> a || b) || applyEntities(null, source.getWorld(), pos)); @@ -195,7 +193,7 @@ public class FireSpell extends AbstractSpell.RangedAreaSpell implements Useable, } /** - * Transmists power to a piece of redstone + * Transmits power to a piece of redstone */ private void sendPower(World w, BlockPos pos, int power, int max, int i) { BlockState state = w.getBlockState(pos); diff --git a/src/main/java/com/minelittlepony/unicopia/magic/spell/IceSpell.java b/src/main/java/com/minelittlepony/unicopia/magic/spell/IceSpell.java index 1a72791c..aeaab62f 100644 --- a/src/main/java/com/minelittlepony/unicopia/magic/spell/IceSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/magic/spell/IceSpell.java @@ -32,7 +32,7 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; import net.minecraft.world.World; -public class IceSpell extends AbstractSpell.RangedAreaSpell implements Useable, DispenceableMagicEffect { +public class IceSpell extends AbstractRangedAreaSpell implements Useable, DispenceableMagicEffect { private final int rad = 3; private final Shape effect_range = new Sphere(false, rad); diff --git a/src/main/java/com/minelittlepony/unicopia/magic/spell/NecromancySpell.java b/src/main/java/com/minelittlepony/unicopia/magic/spell/NecromancySpell.java index da311cf1..17766996 100644 --- a/src/main/java/com/minelittlepony/unicopia/magic/spell/NecromancySpell.java +++ b/src/main/java/com/minelittlepony/unicopia/magic/spell/NecromancySpell.java @@ -19,7 +19,7 @@ import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Vec3d; import net.minecraft.world.Difficulty; -public class NecromancySpell extends AbstractSpell.RangedAreaSpell { +public class NecromancySpell extends AbstractRangedAreaSpell { private final List> spawns = Lists.newArrayList( EntityType.ZOMBIE, diff --git a/src/main/java/com/minelittlepony/unicopia/magic/spell/PortalSpell.java b/src/main/java/com/minelittlepony/unicopia/magic/spell/PortalSpell.java index bbb369bb..3c2216b9 100644 --- a/src/main/java/com/minelittlepony/unicopia/magic/spell/PortalSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/magic/spell/PortalSpell.java @@ -33,7 +33,7 @@ import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -public class PortalSpell extends AbstractSpell.RangedAreaSpell implements Useable { +public class PortalSpell extends AbstractRangedAreaSpell implements Useable { private static final Shape portalZone_X = new Sphere(true, 1, 0, 2, 1); private static final Shape portalZone_Y = new Sphere(true, 1, 2, 0, 2); diff --git a/src/main/java/com/minelittlepony/unicopia/magic/spell/ShieldSpell.java b/src/main/java/com/minelittlepony/unicopia/magic/spell/ShieldSpell.java index a4ffd180..29a98c15 100644 --- a/src/main/java/com/minelittlepony/unicopia/magic/spell/ShieldSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/magic/spell/ShieldSpell.java @@ -20,7 +20,7 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.sound.SoundEvents; import net.minecraft.util.math.Vec3d; -public class ShieldSpell extends AbstractSpell.RangedAreaSpell implements AttachedMagicEffect { +public class ShieldSpell extends AbstractRangedAreaSpell implements AttachedMagicEffect { private final ParticleHandle particlEffect = new ParticleHandle(); @@ -39,11 +39,6 @@ public class ShieldSpell extends AbstractSpell.RangedAreaSpell implements Attach return 0x66CDAA; } - @Override - public void renderOnPerson(Caster source) { - render(source); - } - @Override public void render(Caster source) { float radius = 4 + (source.getCurrentLevel() * 2); diff --git a/src/main/java/com/minelittlepony/unicopia/magic/spell/SiphoningSpell.java b/src/main/java/com/minelittlepony/unicopia/magic/spell/SiphoningSpell.java index bab200a8..8ad88c0d 100644 --- a/src/main/java/com/minelittlepony/unicopia/magic/spell/SiphoningSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/magic/spell/SiphoningSpell.java @@ -17,7 +17,7 @@ import net.minecraft.particle.ParticleTypes; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; -public class SiphoningSpell extends AbstractSpell.RangedAreaSpell { +public class SiphoningSpell extends AbstractRangedAreaSpell { @Override public String getName() {