Search in sources :

Example 6 with IBossDisplayData

use of net.minecraft.entity.boss.IBossDisplayData 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

IBossDisplayData (net.minecraft.entity.boss.IBossDisplayData)6 EntityPlayer (net.minecraft.entity.player.EntityPlayer)4 ArrayList (java.util.ArrayList)3 EntityLivingBase (net.minecraft.entity.EntityLivingBase)3 EntityAIHurtByTarget (net.minecraft.entity.ai.EntityAIHurtByTarget)2 EntityAINearestAttackableTarget (net.minecraft.entity.ai.EntityAINearestAttackableTarget)2 EntityMob (net.minecraft.entity.monster.EntityMob)2 BuffEffect (am2.buffs.BuffEffect)1 DummyEntityPlayer (am2.utility.DummyEntityPlayer)1 EntityCreature (net.minecraft.entity.EntityCreature)1 EntityEggInfo (net.minecraft.entity.EntityList.EntityEggInfo)1 EntityAIAttackOnCollide (net.minecraft.entity.ai.EntityAIAttackOnCollide)1 EntityAITaskEntry (net.minecraft.entity.ai.EntityAITasks.EntityAITaskEntry)1 EntityGhast (net.minecraft.entity.monster.EntityGhast)1 EntitySlime (net.minecraft.entity.monster.EntitySlime)1 IMob (net.minecraft.entity.monster.IMob)1 EntityTameable (net.minecraft.entity.passive.EntityTameable)1 ItemStack (net.minecraft.item.ItemStack)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1 PotionEffect (net.minecraft.potion.PotionEffect)1