Search in sources :

Example 1 with BuffEffect

use of am2.buffs.BuffEffect in project ArsMagica2 by Mithion.

the class Dispel method applyEffectEntity.

@Override
public boolean applyEffectEntity(ItemStack stack, World world, EntityLivingBase caster, Entity target) {
    if (!(target instanceof EntityLivingBase) || target instanceof IBossDisplayData)
        return false;
    if (EntityUtilities.isSummon((EntityLivingBase) target)) {
        if (EntityUtilities.getOwner((EntityLivingBase) target) == caster.getEntityId()) {
            target.attackEntityFrom(DamageSource.magic, 50000);
            return true;
        }
    }
    List<Integer> effectsToRemove = new ArrayList<Integer>();
    Iterator iter = ((EntityLivingBase) target).getActivePotionEffects().iterator();
    int magnitudeLeft = 6;
    while (iter.hasNext()) {
        Integer potionID = ((PotionEffect) iter.next()).getPotionID();
        if (BuffList.instance.isDispelBlacklisted(potionID)) {
            continue;
        }
        PotionEffect pe = ((EntityLivingBase) target).getActivePotionEffect(Potion.potionTypes[potionID]);
        int magnitudeCost = pe.getAmplifier();
        if (magnitudeLeft >= magnitudeCost) {
            magnitudeLeft -= magnitudeCost;
            effectsToRemove.add(potionID);
            if (pe instanceof BuffEffect && !world.isRemote) {
                ((BuffEffect) pe).stopEffect((EntityLivingBase) target);
            }
        }
    }
    if (effectsToRemove.size() == 0 && ExtendedProperties.For((EntityLivingBase) target).getNumSummons() == 0) {
        return false;
    }
    if (!world.isRemote) {
        removePotionEffects((EntityLivingBase) target, effectsToRemove);
    }
    /*if (ExtendedProperties.For((EntityLivingBase)target).getNumSummons() > 0){
			if (!world.isRemote){
				Iterator it = world.loadedEntityList.iterator();
				while (it.hasNext()){
					Entity ent = (Entity)it.next();
					if (ent instanceof EntitySummonedCreature && ((EntitySummonedCreature)ent).GetOwningEntity() == target){
						ent.attackEntityFrom(DamageSource.outOfWorld, 5000);
						break;
					}
				}
			}
		}*/
    return true;
}
Also used : BuffEffect(am2.buffs.BuffEffect) PotionEffect(net.minecraft.potion.PotionEffect) EntityLivingBase(net.minecraft.entity.EntityLivingBase) IBossDisplayData(net.minecraft.entity.boss.IBossDisplayData)

Aggregations

BuffEffect (am2.buffs.BuffEffect)1 EntityLivingBase (net.minecraft.entity.EntityLivingBase)1 IBossDisplayData (net.minecraft.entity.boss.IBossDisplayData)1 PotionEffect (net.minecraft.potion.PotionEffect)1