Search in sources :

Example 1 with SpellModifiers

use of am2.api.spell.enums.SpellModifiers 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;
}
Also used : EntityPlayer(net.minecraft.entity.player.EntityPlayer) ModifierCalculatedEvent(am2.api.events.ModifierCalculatedEvent)

Example 2 with SpellModifiers

use of am2.api.spell.enums.SpellModifiers 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);
}
Also used : EntityPlayer(net.minecraft.entity.player.EntityPlayer) ModifierCalculatedEvent(am2.api.events.ModifierCalculatedEvent)

Example 3 with SpellModifiers

use of am2.api.spell.enums.SpellModifiers 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;
}
Also used : EntityPlayer(net.minecraft.entity.player.EntityPlayer) ModifierCalculatedEvent(am2.api.events.ModifierCalculatedEvent)

Example 4 with SpellModifiers

use of am2.api.spell.enums.SpellModifiers in project ArsMagica2 by Mithion.

the class TileEntityInscriptionTable method countModifiersInList.

private void countModifiersInList(ArrayList<ISpellPart> currentStage) {
    for (ISpellPart part : currentStage) {
        if (part instanceof ISpellModifier) {
            EnumSet<SpellModifiers> modifiers = ((ISpellModifier) part).getAspectsModified();
            for (SpellModifiers modifier : modifiers) {
                int count = modifierCount.get(modifier) + 1;
                modifierCount.put(modifier, count);
            }
        }
    }
}
Also used : SpellModifiers(am2.api.spell.enums.SpellModifiers)

Example 5 with SpellModifiers

use of am2.api.spell.enums.SpellModifiers in project ArsMagica2 by Mithion.

the class CompendiumEntrySpellComponent method parseEx.

@Override
protected void parseEx(Node node) {
    NodeList childNodes = node.getChildNodes();
    for (int i = 0; i < childNodes.getLength(); ++i) {
        Node child = childNodes.item(i);
        if (child.getNodeName().equals("modifiedBy") && !child.getTextContent().isEmpty()) {
            String[] modifierTypes = child.getTextContent().split(",");
            ArrayList<SpellModifiers> list = new ArrayList<SpellModifiers>();
            for (String s : modifierTypes) {
                try {
                    SpellModifiers modifier = Enum.valueOf(SpellModifiers.class, s);
                    list.add(modifier);
                } catch (Throwable t) {
                    LogHelper.debug("Compendium Parsing Error - No modifiable constant exists with the name '%s'", s);
                }
            }
            this.modifiedBy = list.toArray(new SpellModifiers[list.size()]);
        }
    }
}
Also used : NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node) ArrayList(java.util.ArrayList) SpellModifiers(am2.api.spell.enums.SpellModifiers)

Aggregations

ModifierCalculatedEvent (am2.api.events.ModifierCalculatedEvent)6 EntityPlayer (net.minecraft.entity.player.EntityPlayer)6 SpellModifiers (am2.api.spell.enums.SpellModifiers)2 ArrayList (java.util.ArrayList)1 Node (org.w3c.dom.Node)1 NodeList (org.w3c.dom.NodeList)1