mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-23 21:38:00 +01:00
Move AbstractRangedAreaSpell to its own file
This commit is contained in:
parent
140ee68ae3
commit
86c7ff2150
10 changed files with 66 additions and 53 deletions
|
@ -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.
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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<EntityType<? extends LivingEntity>> spawns = Lists.newArrayList(
|
||||
EntityType.ZOMBIE,
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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() {
|
||||
|
|
Loading…
Reference in a new issue