Search in sources :

Example 81 with AMParticle

use of am2.particles.AMParticle in project ArsMagica2 by Mithion.

the class MeltArmor method spawnParticles.

@Override
public void spawnParticles(World world, double x, double y, double z, EntityLivingBase caster, Entity target, Random rand, int colorModifier) {
    AMParticle particle = (AMParticle) AMCore.proxy.particleManager.spawn(world, "radiant", x + 0.5, y + 0.5, z + 0.5);
    if (particle != null) {
        particle.AddParticleController(new ParticleHoldPosition(particle, 20, 1, false));
        particle.setMaxAge(20);
        particle.setParticleScale(0.3f);
        particle.setRGBColorF(0.7f, 0.4f, 0.2f);
        particle.SetParticleAlpha(0.1f);
        if (colorModifier > -1) {
            particle.setRGBColorF(((colorModifier >> 16) & 0xFF) / 255.0f, ((colorModifier >> 8) & 0xFF) / 255.0f, (colorModifier & 0xFF) / 255.0f);
        }
    }
}
Also used : AMParticle(am2.particles.AMParticle) ParticleHoldPosition(am2.particles.ParticleHoldPosition)

Example 82 with AMParticle

use of am2.particles.AMParticle 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)

Example 83 with AMParticle

use of am2.particles.AMParticle in project ArsMagica2 by Mithion.

the class LifeDrain method spawnParticles.

@Override
public void spawnParticles(World world, double x, double y, double z, EntityLivingBase caster, Entity target, Random rand, int colorModifier) {
    for (int i = 0; i < 15; ++i) {
        AMParticle particle = (AMParticle) AMCore.proxy.particleManager.spawn(world, "ember", x, y, z);
        if (particle != null) {
            particle.addRandomOffset(1, 1, 1);
            particle.setIgnoreMaxAge(true);
            particle.AddParticleController(new ParticleArcToEntity(particle, 1, caster, false).SetSpeed(0.03f).generateControlPoints());
            particle.setRGBColorF(1, 0.2f, 0.2f);
            particle.SetParticleAlpha(0.5f);
            if (colorModifier > -1) {
                particle.setRGBColorF(((colorModifier >> 16) & 0xFF) / 255.0f, ((colorModifier >> 8) & 0xFF) / 255.0f, (colorModifier & 0xFF) / 255.0f);
            }
        }
    }
}
Also used : AMParticle(am2.particles.AMParticle) ParticleArcToEntity(am2.particles.ParticleArcToEntity)

Example 84 with AMParticle

use of am2.particles.AMParticle in project ArsMagica2 by Mithion.

the class Light method spawnParticles.

@Override
public void spawnParticles(World world, double x, double y, double z, EntityLivingBase caster, Entity target, Random rand, int colorModifier) {
    for (int i = 0; i < 5; ++i) {
        AMParticle particle = (AMParticle) AMCore.proxy.particleManager.spawn(world, "sparkle2", x, y, z);
        if (particle != null) {
            particle.addRandomOffset(1, 0.5, 1);
            particle.addVelocity(rand.nextDouble() * 0.2 - 0.1, rand.nextDouble() * 0.2, rand.nextDouble() * 0.2 - 0.1);
            particle.setAffectedByGravity();
            particle.setDontRequireControllers();
            particle.setMaxAge(5);
            particle.setParticleScale(0.1f);
            particle.setRGBColorF(0.6f, 0.2f, 0.8f);
            if (colorModifier > -1) {
                particle.setRGBColorF(((colorModifier >> 16) & 0xFF) / 255.0f, ((colorModifier >> 8) & 0xFF) / 255.0f, (colorModifier & 0xFF) / 255.0f);
            }
        }
    }
}
Also used : AMParticle(am2.particles.AMParticle)

Example 85 with AMParticle

use of am2.particles.AMParticle in project ArsMagica2 by Mithion.

the class MagicDamage method spawnParticles.

@Override
public void spawnParticles(World world, double x, double y, double z, EntityLivingBase caster, Entity target, Random rand, int colorModifier) {
    for (int i = 0; i < 5; ++i) {
        AMParticle particle = (AMParticle) AMCore.proxy.particleManager.spawn(world, "arcane", x, y, z);
        if (particle != null) {
            particle.addRandomOffset(1, 0.5, 1);
            particle.addVelocity(rand.nextDouble() * 0.2 - 0.1, rand.nextDouble() * 0.2, rand.nextDouble() * 0.2 - 0.1);
            particle.setAffectedByGravity();
            particle.setDontRequireControllers();
            particle.setMaxAge(5);
            particle.setParticleScale(0.1f);
            if (colorModifier > -1) {
                particle.setRGBColorF(((colorModifier >> 16) & 0xFF) / 255.0f, ((colorModifier >> 8) & 0xFF) / 255.0f, (colorModifier & 0xFF) / 255.0f);
            }
        }
    }
}
Also used : AMParticle(am2.particles.AMParticle)

Aggregations

AMParticle (am2.particles.AMParticle)103 ParticleFloatUpward (am2.particles.ParticleFloatUpward)38 ParticleFadeOut (am2.particles.ParticleFadeOut)25 ParticleOrbitEntity (am2.particles.ParticleOrbitEntity)19 ParticleMoveOnHeading (am2.particles.ParticleMoveOnHeading)13 EntityLivingBase (net.minecraft.entity.EntityLivingBase)13 ParticleHoldPosition (am2.particles.ParticleHoldPosition)11 Entity (net.minecraft.entity.Entity)9 AMVector3 (am2.api.math.AMVector3)8 ISpellModifier (am2.api.spell.component.interfaces.ISpellModifier)8 Colour (am2.spell.modifiers.Colour)8 EntityPlayer (net.minecraft.entity.player.EntityPlayer)7 ItemStack (net.minecraft.item.ItemStack)7 ParticleOrbitPoint (am2.particles.ParticleOrbitPoint)6 SideOnly (cpw.mods.fml.relauncher.SideOnly)6 Block (net.minecraft.block.Block)6 EntityDragonPart (net.minecraft.entity.boss.EntityDragonPart)6 TileEntity (net.minecraft.tileentity.TileEntity)5 List (java.util.List)4 BuffEffectFrostSlowed (am2.buffs.BuffEffectFrostSlowed)3