Search in sources :

Example 11 with IAttributeInstance

use of net.minecraft.entity.ai.attributes.IAttributeInstance in project ArsMagica2 by Mithion.

the class EntityLightMage method getCanSpawnHere.

@Override
public boolean getCanSpawnHere() {
    if (!SpawnBlacklists.entityCanSpawnHere(this.posX, this.posZ, worldObj, this))
        return false;
    if (getAverageNearbyPlayerMagicLevel() < 8) {
        return false;
    }
    int avgLevel = getAverageNearbyPlayerMagicLevel();
    IAttributeInstance attributeinstance = this.getEntityAttribute(SharedMonsterAttributes.maxHealth);
    if (avgLevel == 0) {
        ExtendedProperties.For(this).setMagicLevelWithMana(10);
        if (rand.nextInt(100) < 10) {
            this.tasks.addTask(3, new EntityAIRangedAttackSpell(this, MovementSpeed(), 40, NPCSpells.instance.lightMage_NormalAttack));
            this.dataWatcher.updateObject(DW_MAGE_BOOK, 1);
        }
    } else {
        ExtendedProperties.For(this).setMagicLevelWithMana(10 + rand.nextInt(avgLevel));
        int levelRand = rand.nextInt(avgLevel * 2);
        if (levelRand > 60) {
            this.tasks.addTask(2, new EntityAIRangedAttackSpell(this, MovementSpeed(), 100, NPCSpells.instance.lightMage_AugmentedAttack));
            this.dataWatcher.updateObject(DW_MAGE_BOOK, 2);
        }
        if (levelRand > 30) {
            this.tasks.addTask(3, new EntityAIRangedAttackSpell(this, MovementSpeed(), 40, NPCSpells.instance.lightMage_NormalAttack));
            this.dataWatcher.updateObject(DW_MAGE_BOOK, 1);
        }
    }
    if (!worldObj.isRemote)
        ExtendedProperties.For(this).setFullSync();
    hasUpdated = true;
    return isValidLightLevel() && super.getCanSpawnHere();
}
Also used : IAttributeInstance(net.minecraft.entity.ai.attributes.IAttributeInstance) EntityAIRangedAttackSpell(am2.entities.ai.EntityAIRangedAttackSpell)

Example 12 with IAttributeInstance

use of net.minecraft.entity.ai.attributes.IAttributeInstance in project ArsMagica2 by Mithion.

the class BuffStatModifiers method applyAllModifiers.

private void applyAllModifiers(EntityLivingBase entity, KeyValuePair<IAttribute, AttributeModifier>... modifiers) {
    for (KeyValuePair<IAttribute, AttributeModifier> entry : modifiers) {
        IAttributeInstance inst = entity.getEntityAttribute(entry.getKey());
        if (inst == null)
            continue;
        AttributeModifier currentModifier = inst.getModifier(entry.getValue().getID());
        if (currentModifier != entry.getValue()) {
            if (currentModifier != null) {
                inst.removeModifier(currentModifier);
            }
            inst.applyModifier(entry.getValue());
        }
    }
}
Also used : IAttribute(net.minecraft.entity.ai.attributes.IAttribute) IAttributeInstance(net.minecraft.entity.ai.attributes.IAttributeInstance) AttributeModifier(net.minecraft.entity.ai.attributes.AttributeModifier)

Example 13 with IAttributeInstance

use of net.minecraft.entity.ai.attributes.IAttributeInstance in project ArsMagica2 by Mithion.

the class BuffEffectFrostSlowed method stopEffect.

@Override
public void stopEffect(EntityLivingBase entityliving) {
    IAttributeInstance attributeinstance = entityliving.getEntityAttribute(SharedMonsterAttributes.movementSpeed);
    if (attributeinstance.getModifier(frostSlowID) != null) {
        attributeinstance.removeModifier(frostSlow_Diminished);
        attributeinstance.removeModifier(frostSlow_Normal);
        attributeinstance.removeModifier(frostSlow_Augmented);
    }
}
Also used : IAttributeInstance(net.minecraft.entity.ai.attributes.IAttributeInstance)

Example 14 with IAttributeInstance

use of net.minecraft.entity.ai.attributes.IAttributeInstance in project ArsMagica2 by Mithion.

the class BuffEffectHaste method stopEffect.

@Override
public void stopEffect(EntityLivingBase entityliving) {
    IAttributeInstance attributeinstance = entityliving.getEntityAttribute(SharedMonsterAttributes.movementSpeed);
    if (attributeinstance.getModifier(hasteID) != null) {
        attributeinstance.removeModifier(hasteSpeedBoost_Diminished);
        attributeinstance.removeModifier(hasteSpeedBoost_Normal);
        attributeinstance.removeModifier(hasteSpeedBoost_Augmented);
    }
}
Also used : IAttributeInstance(net.minecraft.entity.ai.attributes.IAttributeInstance)

Aggregations

IAttributeInstance (net.minecraft.entity.ai.attributes.IAttributeInstance)14 AttributeModifier (net.minecraft.entity.ai.attributes.AttributeModifier)3 IAttribute (net.minecraft.entity.ai.attributes.IAttribute)2 EntityPlayer (net.minecraft.entity.player.EntityPlayer)2 World (net.minecraft.world.World)2 EntityAIRangedAttackSpell (am2.entities.ai.EntityAIRangedAttackSpell)1 ExtendedProperties (am2.playerextensions.ExtendedProperties)1 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)1 Method (java.lang.reflect.Method)1 DimensionInformation (mcjty.rftoolsdim.dimensions.DimensionInformation)1 DimensionStorage (mcjty.rftoolsdim.dimensions.DimensionStorage)1 RfToolsDimensionManager (mcjty.rftoolsdim.dimensions.RfToolsDimensionManager)1 EntityLivingBase (net.minecraft.entity.EntityLivingBase)1 IMob (net.minecraft.entity.monster.IMob)1 IAnimals (net.minecraft.entity.passive.IAnimals)1 BlockPos (net.minecraft.util.math.BlockPos)1 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1