Finish implementing SpellAreaEffect and retrofit various spell classes to extend it
This commit is contained in:
@@ -1,47 +1,41 @@
|
||||
package electroblob.wizardry.spell;
|
||||
|
||||
import electroblob.wizardry.item.SpellActions;
|
||||
import electroblob.wizardry.registry.WizardryItems;
|
||||
import electroblob.wizardry.util.*;
|
||||
import electroblob.wizardry.util.ParticleBuilder;
|
||||
import electroblob.wizardry.util.SpellModifiers;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.List;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class GroupHeal extends Spell {
|
||||
public class GroupHeal extends SpellAreaEffect {
|
||||
|
||||
public GroupHeal(){
|
||||
super("group_heal", SpellActions.POINT_UP, false);
|
||||
this.soundValues(0.7f, 1.2f, 0.4f);
|
||||
addProperties(EFFECT_RADIUS, HEALTH);
|
||||
this.targetAllies(true);
|
||||
addProperties(HEALTH);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
|
||||
protected boolean affectEntity(World world, Vec3d origin, @Nullable EntityLivingBase caster, EntityLivingBase target, int targetCount, int ticksInUse, SpellModifiers modifiers){
|
||||
|
||||
boolean flag = false;
|
||||
if(target.getHealth() < target.getMaxHealth() && target.getHealth() > 0){
|
||||
|
||||
List<EntityLivingBase> targets = EntityUtils.getLivingWithinRadius(getProperty(EFFECT_RADIUS).floatValue()
|
||||
* modifiers.get(WizardryItems.blast_upgrade), caster.posX, caster.posY, caster.posZ, world);
|
||||
Heal.heal(target, getProperty(HEALTH).floatValue() * modifiers.get(SpellModifiers.POTENCY));
|
||||
|
||||
for(EntityLivingBase target : targets){
|
||||
|
||||
if(target == caster || AllyDesignationSystem.isAllied(caster, target)){
|
||||
|
||||
if(target.getHealth() < target.getMaxHealth() && target.getHealth() > 0){
|
||||
|
||||
Heal.heal(target, getProperty(HEALTH).floatValue() * modifiers.get(SpellModifiers.POTENCY));
|
||||
|
||||
if(world.isRemote) ParticleBuilder.spawnHealParticles(world, target);
|
||||
playSound(world, target, ticksInUse, -1, modifiers);
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
if(world.isRemote) ParticleBuilder.spawnHealParticles(world, target);
|
||||
playSound(world, target, ticksInUse, -1, modifiers);
|
||||
return true;
|
||||
}
|
||||
|
||||
return flag;
|
||||
return false; // Only succeeds if something was healed
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void spawnParticleEffect(World world, Vec3d origin, double radius, @Nullable EntityLivingBase caster, SpellModifiers modifiers){
|
||||
// We're spawning particles above so don't bother with this method
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user