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();
}
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());
}
}
}
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);
}
}
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);
}
}
Aggregations