use of am2.api.events.AffinityChangingEvent in project ArsMagica2 by Mithion.
the class SpellUtils method doAffinityShift.
public void doAffinityShift(EntityLivingBase caster, ISpellComponent component, ISpellShape governingShape) {
if (!(caster instanceof EntityPlayer))
return;
AffinityData aff = AffinityData.For(caster);
EnumSet<Affinity> affList = component.getAffinity();
for (Affinity affinity : affList) {
float shift = component.getAffinityShift(affinity) * aff.getDiminishingReturnsFactor() * 5;
float xp = 0.05f * aff.getDiminishingReturnsFactor();
if (governingShape.isChanneled()) {
shift /= 4;
xp /= 4;
}
if (caster instanceof EntityPlayer) {
if (SkillData.For((EntityPlayer) caster).isEntryKnown(SkillTreeManager.instance.getSkillTreeEntry(SkillManager.instance.getSkill("AffinityGains")))) {
shift *= 1.1f;
xp *= 0.9f;
}
ItemStack chestArmor = ((EntityPlayer) caster).getCurrentArmor(2);
if (chestArmor != null && ArmorHelper.isInfusionPreset(chestArmor, GenericImbuement.magicXP))
xp *= 1.25f;
}
if (shift > 0) {
AffinityChangingEvent event = new AffinityChangingEvent((EntityPlayer) caster, affinity, shift);
MinecraftForge.EVENT_BUS.post(event);
if (!event.isCanceled())
aff.incrementAffinity(affinity, event.amount);
}
if (xp > 0) {
xp *= caster.getAttributeMap().getAttributeInstance(ArsMagicaApi.xpGainModifier).getAttributeValue();
ExtendedProperties.For(caster).addMagicXP(xp);
}
}
aff.addDiminishingReturns(governingShape.isChanneled());
}
Aggregations