Search in sources :

Example 21 with ISpellModifier

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

Example 22 with ISpellModifier

use of am2.api.spell.component.interfaces.ISpellModifier in project ArsMagica2 by Mithion.

the class SpellUtils method getModifiedDouble_Add.

public double getModifiedDouble_Add(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.ADD);
    MinecraftForge.EVENT_BUS.post(event);
    return event.modifiedValue;
}
Also used : EntityPlayer(net.minecraft.entity.player.EntityPlayer) ModifierCalculatedEvent(am2.api.events.ModifierCalculatedEvent)

Example 23 with ISpellModifier

use of am2.api.spell.component.interfaces.ISpellModifier in project ArsMagica2 by Mithion.

the class ItemSpellPart method registerIcons.

@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister IIconRegister) {
    ArrayList<Integer> parts = SkillManager.instance.getAllShapes();
    parts.addAll(SkillManager.instance.getAllComponents());
    parts.addAll(SkillManager.instance.getAllModifiers());
    parts.addAll(SkillManager.instance.getAllTalents());
    int count = 0;
    for (Integer i : parts) {
        if (i == null)
            continue;
        ISkillTreeEntry entry = SkillManager.instance.getSkill(i);
        String subfolder = "";
        if (entry instanceof ISpellShape)
            subfolder = "shapes";
        else if (entry instanceof ISpellComponent)
            subfolder = "components";
        else if (entry instanceof ISpellModifier)
            subfolder = "modifiers";
        else
            subfolder = "skills";
        String skillName = SkillManager.instance.getSkillName(entry);
        IIcon IIcon = ResourceManager.RegisterTexture(String.format("spells/%s/%s.png", subfolder, skillName), IIconRegister);
        SpellIconManager.instance.registerIcon(skillName, IIcon);
    }
}
Also used : ISpellComponent(am2.api.spell.component.interfaces.ISpellComponent) IIcon(net.minecraft.util.IIcon) ISkillTreeEntry(am2.api.spell.component.interfaces.ISkillTreeEntry) ISpellModifier(am2.api.spell.component.interfaces.ISpellModifier) ISpellShape(am2.api.spell.component.interfaces.ISpellShape) SideOnly(cpw.mods.fml.relauncher.SideOnly)

Example 24 with ISpellModifier

use of am2.api.spell.component.interfaces.ISpellModifier in project ArsMagica2 by Mithion.

the class Light method getColorMeta.

private int getColorMeta(ItemStack spell) {
    int meta = 15;
    int color = 0xFFFFFF;
    if (SpellUtils.instance.modifierIsPresent(SpellModifiers.COLOR, spell, 0)) {
        ISpellModifier[] mods = SpellUtils.instance.getModifiersForStage(spell, 0);
        int ordinalCount = 0;
        for (ISpellModifier mod : mods) {
            if (mod instanceof Colour) {
                byte[] data = SpellUtils.instance.getModifierMetadataFromStack(spell, mod, 0, ordinalCount++);
                color = (int) mod.getModifier(SpellModifiers.COLOR, null, null, null, data);
            }
        }
    }
    for (int i = 0; i < 16; ++i) {
        if (((ItemDye) Items.dye).field_150922_c[i] == color) {
            meta = i;
            break;
        }
    }
    return meta;
}
Also used : ISpellModifier(am2.api.spell.component.interfaces.ISpellModifier) ItemDye(net.minecraft.item.ItemDye) Colour(am2.spell.modifiers.Colour)

Example 25 with ISpellModifier

use of am2.api.spell.component.interfaces.ISpellModifier in project ArsMagica2 by Mithion.

the class Beam method beginStackStage.

@Override
public SpellCastResult beginStackStage(ItemSpellBase item, ItemStack stack, EntityLivingBase caster, EntityLivingBase target, World world, double x, double y, double z, int side, boolean giveXP, int useCount) {
    boolean shouldApplyEffect = useCount % 10 == 0;
    double range = SpellUtils.instance.getModifiedDouble_Add(SpellModifiers.RANGE, stack, caster, target, world, 0);
    boolean targetWater = SpellUtils.instance.modifierIsPresent(SpellModifiers.TARGET_NONSOLID_BLOCKS, stack, 0);
    MovingObjectPosition mop = item.getMovingObjectPosition(caster, world, range, true, targetWater);
    SpellCastResult result = null;
    Vec3 beamHitVec = null;
    Vec3 spellVec = null;
    if (mop == null) {
        beamHitVec = MathUtilities.extrapolateEntityLook(world, caster, range);
        spellVec = beamHitVec;
    } else if (mop.typeOfHit == MovingObjectType.ENTITY) {
        if (shouldApplyEffect) {
            Entity e = mop.entityHit;
            if (e instanceof EntityDragonPart && ((EntityDragonPart) e).entityDragonObj instanceof EntityLivingBase)
                e = (EntityLivingBase) ((EntityDragonPart) e).entityDragonObj;
            result = SpellHelper.instance.applyStageToEntity(stack, caster, world, e, 0, giveXP);
            if (result != SpellCastResult.SUCCESS) {
                return result;
            }
        }
        float rng = (float) mop.hitVec.distanceTo(Vec3.createVectorHelper(caster.posX, caster.posY, caster.posZ));
        beamHitVec = MathUtilities.extrapolateEntityLook(world, caster, rng);
        spellVec = beamHitVec;
    } else {
        if (shouldApplyEffect) {
            result = SpellHelper.instance.applyStageToGround(stack, caster, world, mop.blockX, mop.blockY, mop.blockZ, mop.sideHit, mop.hitVec.xCoord, mop.hitVec.yCoord, mop.hitVec.zCoord, 0, giveXP);
            if (result != SpellCastResult.SUCCESS) {
                return result;
            }
        }
        beamHitVec = mop.hitVec;
        spellVec = Vec3.createVectorHelper(mop.blockX, mop.blockY, mop.blockZ);
    }
    if (world.isRemote && beamHitVec != null) {
        AMBeam beam = (AMBeam) beams.get(caster.getEntityId());
        double startX = caster.posX;
        double startY = caster.posY + caster.getEyeHeight() - 0.2f;
        double startZ = caster.posZ;
        Affinity affinity = SpellUtils.instance.mainAffinityFor(stack);
        int color = -1;
        if (SpellUtils.instance.modifierIsPresent(SpellModifiers.COLOR, stack, 0)) {
            ISpellModifier[] mods = SpellUtils.instance.getModifiersForStage(stack, 0);
            int ordinalCount = 0;
            for (ISpellModifier mod : mods) {
                if (mod instanceof Colour) {
                    byte[] meta = SpellUtils.instance.getModifierMetadataFromStack(stack, mod, 0, ordinalCount++);
                    color = (int) mod.getModifier(SpellModifiers.COLOR, null, null, null, meta);
                }
            }
        }
        if (beam != null) {
            if (beam.isDead || beam.getDistanceSqToEntity(caster) > 4) {
                beams.remove(caster.getEntityId());
            } else {
                beam.setBeamLocationAndTarget(startX, startY, startZ, beamHitVec.xCoord, beamHitVec.yCoord, beamHitVec.zCoord);
            }
        } else {
            if (affinity == Affinity.LIGHTNING) {
                AMCore.instance.proxy.particleManager.BoltFromEntityToPoint(world, caster, beamHitVec.xCoord, beamHitVec.yCoord, beamHitVec.zCoord, 1, color == -1 ? affinity.color : color);
            } else {
                beam = (AMBeam) AMCore.instance.proxy.particleManager.BeamFromEntityToPoint(world, caster, beamHitVec.xCoord, beamHitVec.yCoord, beamHitVec.zCoord, color == -1 ? affinity.color : color);
                if (beam != null) {
                    if (AMCore.instance.proxy.getProxyUtils().isLocalPlayerInFirstPerson())
                        beam.setFirstPersonPlayerCast();
                    beams.put(caster.getEntityId(), beam);
                }
            }
        }
        for (int i = 0; i < AMCore.config.getGFXLevel() + 1; ++i) {
            AMParticle particle = (AMParticle) AMCore.proxy.particleManager.spawn(world, AMParticleIcons.instance.getParticleForAffinity(affinity), beamHitVec.xCoord, beamHitVec.yCoord, beamHitVec.zCoord);
            if (particle != null) {
                particle.setMaxAge(2);
                particle.setParticleScale(0.1f);
                particle.setIgnoreMaxAge(false);
                if (color != -1)
                    particle.setRGBColorI(color);
                particle.AddParticleController(new ParticleMoveOnHeading(particle, world.rand.nextDouble() * 360, world.rand.nextDouble() * 360, world.rand.nextDouble() * 0.2 + 0.02f, 1, false));
            }
        }
    }
    if (result != null && spellVec != null && shouldApplyEffect) {
        ItemStack newItemStack = SpellUtils.instance.popStackStage(stack);
        return SpellHelper.instance.applyStackStage(newItemStack, caster, target, spellVec.xCoord, spellVec.yCoord, spellVec.zCoord, mop != null ? mop.sideHit : 0, world, true, giveXP, 0);
    } else {
        return SpellCastResult.SUCCESS_REDUCE_MANA;
    }
}
Also used : Entity(net.minecraft.entity.Entity) AMParticle(am2.particles.AMParticle) ISpellModifier(am2.api.spell.component.interfaces.ISpellModifier) Colour(am2.spell.modifiers.Colour) MovingObjectPosition(net.minecraft.util.MovingObjectPosition) EntityDragonPart(net.minecraft.entity.boss.EntityDragonPart) Vec3(net.minecraft.util.Vec3) EntityLivingBase(net.minecraft.entity.EntityLivingBase) SpellCastResult(am2.api.spell.enums.SpellCastResult) Affinity(am2.api.spell.enums.Affinity) AMBeam(am2.particles.AMBeam) ItemStack(net.minecraft.item.ItemStack) ParticleMoveOnHeading(am2.particles.ParticleMoveOnHeading)

Aggregations

ISpellModifier (am2.api.spell.component.interfaces.ISpellModifier)17 Colour (am2.spell.modifiers.Colour)13 EntityPlayer (net.minecraft.entity.player.EntityPlayer)8 ModifierCalculatedEvent (am2.api.events.ModifierCalculatedEvent)6 Entity (net.minecraft.entity.Entity)6 EntityLivingBase (net.minecraft.entity.EntityLivingBase)5 EntityDragonPart (net.minecraft.entity.boss.EntityDragonPart)5 ISpellComponent (am2.api.spell.component.interfaces.ISpellComponent)4 ISpellShape (am2.api.spell.component.interfaces.ISpellShape)4 ItemStack (net.minecraft.item.ItemStack)4 AMVector3 (am2.api.math.AMVector3)2 Affinity (am2.api.spell.enums.Affinity)2 AMDataWriter (am2.network.AMDataWriter)2 AMParticle (am2.particles.AMParticle)2 Summon (am2.spell.components.Summon)2 DummyEntityPlayer (am2.utility.DummyEntityPlayer)2 KeyValuePair (am2.utility.KeyValuePair)2 SkillLearnedEvent (am2.api.events.SkillLearnedEvent)1 AMLineSegment (am2.api.math.AMLineSegment)1 ISkillTreeEntry (am2.api.spell.component.interfaces.ISkillTreeEntry)1