Search in sources :

Example 1 with ParticleMoveOnHeading

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

the class EntityHecate method spawnLivingParticles.

private void spawnLivingParticles() {
    if (rand.nextInt(3) == 0) {
        double yPos = this.posY + 1.1;
        if (this.currentForwardRotation >= 0.24) {
            yPos += 0.3;
        }
        AMParticle effect = (AMParticle) AMCore.instance.proxy.particleManager.spawn(worldObj, "smoke", this.posX + ((rand.nextFloat() * 0.2) - 0.1f), yPos, this.posZ + ((rand.nextFloat() * 0.4) - 0.2f));
        if (effect != null) {
            if (this.currentForwardRotation < 0.24) {
                effect.AddParticleController(new ParticleFloatUpward(effect, 0.1f, -0.06f, 1, false));
            } else {
                effect.AddParticleController(new ParticleMoveOnHeading(effect, this.rotationYaw - 90, this.rotationPitch, 0.01f, 1, false));
            }
            effect.AddParticleController(new ParticleFadeOut(effect, 2, false).setFadeSpeed(0.04f));
            effect.setMaxAge(25);
            effect.setIgnoreMaxAge(false);
            effect.setRGBColorF(0.3f, 0.3f, 0.3f);
        }
    }
}
Also used : AMParticle(am2.particles.AMParticle) ParticleFadeOut(am2.particles.ParticleFadeOut) ParticleFloatUpward(am2.particles.ParticleFloatUpward) ParticleMoveOnHeading(am2.particles.ParticleMoveOnHeading)

Example 2 with ParticleMoveOnHeading

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

the class ItemCrystalWrench method spawnLinkParticles.

private void spawnLinkParticles(World world, double hitX, double hitY, double hitZ, boolean disconnect) {
    for (int i = 0; i < 10; ++i) {
        AMParticle particle = (AMParticle) AMCore.proxy.particleManager.spawn(world, "none_hand", hitX, hitY, hitZ);
        if (particle != null) {
            if (disconnect) {
                particle.setRGBColorF(1, 0, 0);
                particle.addRandomOffset(0.5f, 0.5f, 0.5f);
            }
            particle.setMaxAge(10);
            particle.setParticleScale(0.1f);
            particle.AddParticleController(new ParticleMoveOnHeading(particle, world.rand.nextInt(360), world.rand.nextInt(360), world.rand.nextDouble() * 0.2, 1, false));
            particle.AddParticleController(new ParticleFadeOut(particle, 1, false).setFadeSpeed(0.1f));
        }
    }
}
Also used : AMParticle(am2.particles.AMParticle) ParticleFadeOut(am2.particles.ParticleFadeOut) ParticleMoveOnHeading(am2.particles.ParticleMoveOnHeading)

Example 3 with ParticleMoveOnHeading

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

the class EntityWinterGuardianArm method onUpdate.

@Override
public void onUpdate() {
    if (!worldObj.isRemote && (getThrowingEntity() == null || getThrowingEntity().isDead)) {
        setDead();
        return;
    } else {
        ticksExisted++;
        if (ticksExisted >= maxTicksToExist && !worldObj.isRemote) {
            setDead();
            return;
        }
    }
    if (!takenArm && getThrowingEntity() != null && getThrowingEntity() instanceof EntityWinterGuardian) {
        ((EntityWinterGuardian) getThrowingEntity()).launchOneArm();
        takenArm = true;
    }
    Vec3 vec3d = Vec3.createVectorHelper(posX, posY, posZ);
    Vec3 vec3d1 = Vec3.createVectorHelper(posX + motionX, posY + motionY, posZ + motionZ);
    MovingObjectPosition movingobjectposition = worldObj.rayTraceBlocks(vec3d, vec3d1);
    vec3d = Vec3.createVectorHelper(posX, posY, posZ);
    vec3d1 = Vec3.createVectorHelper(posX + motionX, posY + motionY, posZ + motionZ);
    if (movingobjectposition != null) {
        vec3d1 = Vec3.createVectorHelper(movingobjectposition.hitVec.xCoord, movingobjectposition.hitVec.yCoord, movingobjectposition.hitVec.zCoord);
    }
    Entity entity = null;
    List list = worldObj.getEntitiesWithinAABBExcludingEntity(this, boundingBox.addCoord(motionX, motionY, motionZ).expand(1.0D, 1.0D, 1.0D));
    double d = 0.0D;
    for (int j = 0; j < list.size(); j++) {
        Entity entity1 = (Entity) list.get(j);
        if (!entity1.canBeCollidedWith() || entity1.isEntityEqual(getThrowingEntity()) && ticksExisted < 25) {
            continue;
        }
        float f2 = 0.3F;
        AxisAlignedBB axisalignedbb = entity1.boundingBox.expand(f2, f2, f2);
        MovingObjectPosition movingobjectposition1 = axisalignedbb.calculateIntercept(vec3d, vec3d1);
        if (movingobjectposition1 == null) {
            continue;
        }
        double d1 = vec3d.distanceTo(movingobjectposition1.hitVec);
        if (d1 < d || d == 0.0D) {
            entity = entity1;
            d = d1;
        }
    }
    if (entity != null) {
        movingobjectposition = new MovingObjectPosition(entity);
    }
    if (movingobjectposition != null) {
        HitObject(movingobjectposition);
    }
    posX += motionX;
    posY += motionY;
    posZ += motionZ;
    float f = MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ);
    rotationYaw = (float) ((Math.atan2(motionX, motionZ) * 180D) / 3.1415927410125732D);
    for (rotationPitch = (float) ((Math.atan2(motionY, f) * 180D) / 3.1415927410125732D); rotationPitch - prevRotationPitch < -180F; prevRotationPitch -= 360F) {
    }
    for (; rotationPitch - prevRotationPitch >= 180F; prevRotationPitch += 360F) {
    }
    for (; rotationYaw - prevRotationYaw < -180F; prevRotationYaw -= 360F) {
    }
    for (; rotationYaw - prevRotationYaw >= 180F; prevRotationYaw += 360F) {
    }
    rotationPitch = prevRotationPitch + (rotationPitch - prevRotationPitch) * 0.4F;
    rotationYaw = prevRotationYaw + (rotationYaw - prevRotationYaw) * 0.4F;
    float f1 = 0.95F;
    if (isInWater()) {
        for (int k = 0; k < 4; k++) {
            float f3 = 0.25F;
            worldObj.spawnParticle("bubble", posX - motionX * f3, posY - motionY * f3, posZ - motionZ * f3, motionX, motionY, motionZ);
        }
        f1 = 0.8F;
    } else {
        for (int i = 0; i < 2; ++i) {
            AMParticle particle = (AMParticle) AMCore.proxy.particleManager.spawn(worldObj, "ember", posX + rand.nextFloat() * 0.2 - 0.1, posY + 1.2, posZ + rand.nextFloat() * 0.2 - 0.1);
            if (particle != null) {
                particle.setIgnoreMaxAge(false);
                particle.setMaxAge(15);
                particle.setParticleScale(0.35f);
                particle.setRGBColorF(0.5098f, 0.7843f, 0.7843f);
                particle.AddParticleController(new ParticleMoveOnHeading(particle, Math.toDegrees(this.rotationPitch), Math.toDegrees(this.rotationYaw), 0.2f, 1, false));
            }
        }
    }
    setPosition(posX, posY, posZ);
    int halflife = 80;
    if (this.ticksExisted > 30 && this.ticksExisted < halflife) {
        this.motionX *= 0.8f;
        this.motionY *= 0.8f;
        this.motionZ *= 0.8f;
    } else if (this.ticksExisted > halflife && getThrowingEntity() != null) {
        double deltaX = this.posX - getThrowingEntity().posX;
        double deltaZ = this.posZ - getThrowingEntity().posZ;
        double deltaY = this.posY - (getThrowingEntity().posY + getThrowingEntity().getEyeHeight());
        double angle = Math.atan2(deltaZ, deltaX);
        double speed = Math.min((this.ticksExisted - halflife) / 10f, this.getProjectileSpeed());
        double horizontalDistance = MathHelper.sqrt_double(deltaX * deltaX + deltaZ * deltaZ);
        float pitchRotation = (float) (-Math.atan2(deltaY, horizontalDistance));
        this.motionX = -Math.cos(angle) * speed;
        this.motionZ = -Math.sin(angle) * speed;
        this.motionY = Math.sin(pitchRotation) * speed;
        if (this.entityHit != null) {
            Entity entityhit = worldObj.getEntityByID(this.entityHit);
            if (entityhit != null) {
                entityhit.posX = this.posX;
                entityhit.posY = this.posY - entityhit.height / 2 + 1.2;
                entityhit.posZ = this.posZ;
                entityhit.motionX = this.motionX;
                entityhit.motionY = this.motionY;
                entityhit.motionZ = this.motionZ;
                entityhit.lastTickPosX = this.lastTickPosX;
                entityhit.lastTickPosY = this.lastTickPosY - entityhit.height / 2 + 1.2;
                entityhit.lastTickPosZ = this.lastTickPosZ;
                entityhit.fallDistance = 0;
            }
        }
        if (this.getDistanceSqToEntity(getThrowingEntity()) < 9 && !worldObj.isRemote) {
            this.setDead();
        }
    }
}
Also used : Entity(net.minecraft.entity.Entity) AMParticle(am2.particles.AMParticle) List(java.util.List) EntityWinterGuardian(am2.bosses.EntityWinterGuardian) ParticleMoveOnHeading(am2.particles.ParticleMoveOnHeading)

Example 4 with ParticleMoveOnHeading

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

the class AMPacketProcessorClient method handleStarFall.

private void handleStarFall(byte[] data) {
    AMDataReader rdr = new AMDataReader(data, false);
    double x = rdr.getDouble();
    double y = rdr.getDouble();
    double z = rdr.getDouble();
    ItemStack spellStack = null;
    if (rdr.getBoolean())
        spellStack = rdr.getItemStack();
    int color = -1;
    if (spellStack != null) {
        if (SpellUtils.instance.modifierIsPresent(SpellModifiers.COLOR, spellStack, 0)) {
            ISpellModifier[] mods = SpellUtils.instance.getModifiersForStage(spellStack, 0);
            int ordinalCount = 0;
            for (ISpellModifier mod : mods) {
                if (mod instanceof Colour) {
                    byte[] meta = SpellUtils.instance.getModifierMetadataFromStack(spellStack, mod, 0, ordinalCount++);
                    color = (int) mod.getModifier(SpellModifiers.COLOR, null, null, null, meta);
                }
            }
        }
    }
    for (int i = 0; i < 360; i += AMCore.config.FullGFX() ? 5 : AMCore.config.LowGFX() ? 10 : 20) {
        AMParticle effect = (AMParticle) AMCore.instance.proxy.particleManager.spawn(Minecraft.getMinecraft().theWorld, "sparkle2", x, y + 1.5, z);
        if (effect != null) {
            effect.setIgnoreMaxAge(true);
            effect.AddParticleController(new ParticleMoveOnHeading(effect, i, 0, 0.7f, 1, false));
            float clrMod = Minecraft.getMinecraft().theWorld.rand.nextFloat();
            int finalColor = -1;
            if (color == -1)
                finalColor = MathUtilities.colorFloatsToInt(0.24f * clrMod, 0.58f * clrMod, 0.71f * clrMod);
            else {
                float[] colors = MathUtilities.colorIntToFloats(color);
                for (int c = 0; c < colors.length; ++c) colors[c] = colors[c] * clrMod;
                finalColor = MathUtilities.colorFloatsToInt(colors[0], colors[1], colors[2]);
            }
            effect.setParticleScale(1.2f);
            effect.noClip = false;
            effect.setRGBColorI(finalColor);
            effect.AddParticleController(new ParticleFadeOut(effect, 1, false).setFadeSpeed(0.05f).setKillParticleOnFinish(true));
            effect.AddParticleController(new ParticleLeaveParticleTrail(effect, "sparkle2", false, 15, 1, false).addControllerToParticleList(new ParticleChangeSize(effect, 1.2f, 0.01f, 15, 1, false)).setParticleRGB_I(finalColor).setChildAffectedByGravity().addRandomOffset(0.2f, 0.2f, 0.2f));
        }
    }
    Minecraft.getMinecraft().theWorld.playSound(x, y, z, "arsmagica2:spell.special.starfall", 2.0f, 1.0f, false);
}
Also used : ISpellModifier(am2.api.spell.component.interfaces.ISpellModifier) Colour(am2.spell.modifiers.Colour) ItemStack(net.minecraft.item.ItemStack)

Example 5 with ParticleMoveOnHeading

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

the class AoE method spawnAoEParticles.

private void spawnAoEParticles(ItemStack stack, EntityLivingBase caster, World world, double x, double y, double z, int radius) {
    String pfxName = AMParticleIcons.instance.getParticleForAffinity(SpellUtils.instance.mainAffinityFor(stack));
    float speed = 0.08f * radius;
    int color = 0xFFFFFF;
    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);
            }
        }
    }
    for (int i = 0; i < 360; i += AMCore.config.FullGFX() ? 20 : AMCore.config.LowGFX() ? 40 : 60) {
        AMParticle effect = (AMParticle) AMCore.instance.proxy.particleManager.spawn(world, pfxName, x, y + 1.5f, z);
        if (effect != null) {
            effect.setIgnoreMaxAge(true);
            effect.AddParticleController(new ParticleMoveOnHeading(effect, i, 0, speed, 1, false));
            effect.noClip = false;
            effect.setRGBColorI(color);
            effect.AddParticleController(new ParticleFadeOut(effect, 1, false).setFadeSpeed(0.05f).setKillParticleOnFinish(true));
            effect.AddParticleController(new ParticleLeaveParticleTrail(effect, pfxName, false, 5, 1, false).addControllerToParticleList(new ParticleFadeOut(effect, 1, false).setFadeSpeed(0.1f).setKillParticleOnFinish(true)).setParticleRGB_I(color).addRandomOffset(0.2f, 0.2f, 0.2f));
        }
    }
}
Also used : ISpellModifier(am2.api.spell.component.interfaces.ISpellModifier) Colour(am2.spell.modifiers.Colour)

Aggregations

AMParticle (am2.particles.AMParticle)13 ParticleMoveOnHeading (am2.particles.ParticleMoveOnHeading)13 ParticleFadeOut (am2.particles.ParticleFadeOut)10 EntityLivingBase (net.minecraft.entity.EntityLivingBase)6 ISpellModifier (am2.api.spell.component.interfaces.ISpellModifier)3 Colour (am2.spell.modifiers.Colour)3 Entity (net.minecraft.entity.Entity)3 ItemStack (net.minecraft.item.ItemStack)3 ParticleFloatUpward (am2.particles.ParticleFloatUpward)2 List (java.util.List)2 EntityPlayer (net.minecraft.entity.player.EntityPlayer)2 MovingObjectPosition (net.minecraft.util.MovingObjectPosition)2 Vec3 (net.minecraft.util.Vec3)2 AMVector3 (am2.api.math.AMVector3)1 Affinity (am2.api.spell.enums.Affinity)1 SpellCastResult (am2.api.spell.enums.SpellCastResult)1 EntityWinterGuardian (am2.bosses.EntityWinterGuardian)1 AMBeam (am2.particles.AMBeam)1 ExtendedProperties (am2.playerextensions.ExtendedProperties)1 ArrayList (java.util.ArrayList)1