use of am2.api.events.ModifierCalculatedEvent in project ArsMagica2 by Mithion.
the class SpellUtils method getModifiedDouble_Add.
public double getModifiedDouble_Add(double defaultValue, ItemStack stack, EntityLivingBase caster, Entity target, World world, int stage, SpellModifiers check) {
int ordinalCount = 0;
double modifiedValue = defaultValue;
for (ISpellModifier modifier : getModifiersForStage(stack, stage)) {
if (modifier.getAspectsModified().contains(check)) {
byte[] meta = getModifierMetadataFromStack(stack, modifier, stage, ordinalCount++);
modifiedValue += modifier.getModifier(check, caster, target, world, meta);
}
}
if (caster instanceof EntityPlayer) {
if (SkillData.For((EntityPlayer) caster).isEntryKnown(SkillTreeManager.instance.getSkillTreeEntry(SkillManager.instance.getSkill("AugmentedCasting")))) {
modifiedValue *= 1.1f;
}
}
ModifierCalculatedEvent event = new ModifierCalculatedEvent(stack, caster, check, defaultValue, modifiedValue, OperationType.ADD);
MinecraftForge.EVENT_BUS.post(event);
return event.modifiedValue;
}
use of am2.api.events.ModifierCalculatedEvent in project ArsMagica2 by Mithion.
the class SpellUtils method getModifiedInt_Add.
public int getModifiedInt_Add(int defaultValue, ItemStack stack, EntityLivingBase caster, Entity target, World world, int stage, SpellModifiers check) {
int ordinalCount = 0;
double modifiedValue = defaultValue;
for (ISpellModifier modifier : getModifiersForStage(stack, stage)) {
if (modifier.getAspectsModified().contains(check)) {
byte[] meta = getModifierMetadataFromStack(stack, modifier, stage, ordinalCount++);
modifiedValue += modifier.getModifier(check, caster, target, world, meta);
}
}
if (caster instanceof EntityPlayer) {
if (SkillData.For((EntityPlayer) caster).isEntryKnown(SkillTreeManager.instance.getSkillTreeEntry(SkillManager.instance.getSkill("AugmentedCasting")))) {
modifiedValue *= 1.1f;
}
}
ModifierCalculatedEvent event = new ModifierCalculatedEvent(stack, caster, check, defaultValue, modifiedValue, OperationType.ADD);
MinecraftForge.EVENT_BUS.post(event);
return (int) Math.ceil(event.modifiedValue);
}
use of am2.api.events.ModifierCalculatedEvent in project ArsMagica2 by Mithion.
the class SpellUtils method getModifiedDouble_Mul.
//==============================================================================
// Modifiers
//==============================================================================
public double getModifiedDouble_Mul(double defaultValue, ItemStack stack, EntityLivingBase caster, Entity target, World world, int stage, SpellModifiers check) {
int ordinalCount = 0;
double modifiedValue = defaultValue;
for (ISpellModifier modifier : getModifiersForStage(stack, stage)) {
if (modifier.getAspectsModified().contains(check)) {
byte[] meta = getModifierMetadataFromStack(stack, modifier, stage, ordinalCount++);
modifiedValue *= modifier.getModifier(check, caster, target, world, meta);
}
}
if (caster instanceof EntityPlayer) {
if (SkillData.For((EntityPlayer) caster).isEntryKnown(SkillTreeManager.instance.getSkillTreeEntry(SkillManager.instance.getSkill("AugmentedCasting")))) {
modifiedValue *= 1.1f;
}
}
ModifierCalculatedEvent event = new ModifierCalculatedEvent(stack, caster, check, defaultValue, modifiedValue, OperationType.MULTIPLY);
MinecraftForge.EVENT_BUS.post(event);
return event.modifiedValue;
}
use of am2.api.events.ModifierCalculatedEvent in project ArsMagica2 by Mithion.
the class SpellUtils method getModifiedInt_Mul.
public int getModifiedInt_Mul(int defaultValue, ItemStack stack, EntityLivingBase caster, Entity target, World world, int stage, SpellModifiers check) {
int ordinalCount = 0;
int modifiedValue = defaultValue;
for (ISpellModifier modifier : getModifiersForStage(stack, stage)) {
if (modifier.getAspectsModified().contains(check)) {
byte[] meta = getModifierMetadataFromStack(stack, modifier, stage, ordinalCount++);
modifiedValue *= modifier.getModifier(check, caster, target, world, meta);
}
}
if (caster instanceof EntityPlayer) {
if (SkillData.For((EntityPlayer) caster).isEntryKnown(SkillTreeManager.instance.getSkillTreeEntry(SkillManager.instance.getSkill("AugmentedCasting")))) {
modifiedValue *= 1.1f;
}
}
ModifierCalculatedEvent event = new ModifierCalculatedEvent(stack, caster, check, defaultValue, modifiedValue, OperationType.MULTIPLY);
MinecraftForge.EVENT_BUS.post(event);
return (int) event.modifiedValue;
}
use of am2.api.events.ModifierCalculatedEvent in project ArsMagica2 by Mithion.
the class SpellUtils method getModifiedDouble_Mul.
public double getModifiedDouble_Mul(SpellModifiers check, ItemStack stack, EntityLivingBase caster, Entity target, World world, int stage) {
int ordinalCount = 0;
double modifiedValue = check.defaultValue;
for (ISpellModifier modifier : getModifiersForStage(stack, stage)) {
if (modifier.getAspectsModified().contains(check)) {
byte[] meta = getModifierMetadataFromStack(stack, modifier, stage, ordinalCount++);
modifiedValue *= modifier.getModifier(check, caster, target, world, meta);
}
}
if (caster instanceof EntityPlayer) {
if (SkillData.For((EntityPlayer) caster).isEntryKnown(SkillTreeManager.instance.getSkillTreeEntry(SkillManager.instance.getSkill("AugmentedCasting")))) {
modifiedValue *= 1.1f;
}
}
ModifierCalculatedEvent event = new ModifierCalculatedEvent(stack, caster, check, check.defaultValue, modifiedValue, OperationType.MULTIPLY);
MinecraftForge.EVENT_BUS.post(event);
return event.modifiedValue;
}
Aggregations