Search in sources :

Example 6 with ParticleMoveOnHeading

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

the class Repel 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, "sparkle", x, y, z);
    if (particle != null) {
        particle.addRandomOffset(1, 2, 1);
        double dx = caster.posX - target.posX;
        double dz = caster.posZ - target.posZ;
        double angle = Math.toDegrees(Math.atan2(-dz, -dx));
        particle.AddParticleController(new ParticleMoveOnHeading(particle, angle, 0, 0.1 + rand.nextDouble() * 0.5, 1, false));
        particle.AddParticleController(new ParticleFadeOut(particle, 1, false).setFadeSpeed(0.05f));
        particle.setMaxAge(20);
        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) ParticleFadeOut(am2.particles.ParticleFadeOut) ParticleMoveOnHeading(am2.particles.ParticleMoveOnHeading)

Example 7 with ParticleMoveOnHeading

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

the class TileEntityLectern method updateEntity.

@Override
public void updateEntity() {
    if (worldObj.isRemote) {
        updateBookRender();
        if (tooltipStack != null && field_145926_a % 2 == 0) {
            AMParticle particle = (AMParticle) AMCore.proxy.particleManager.spawn(worldObj, "sparkle", xCoord + 0.5 + ((worldObj.rand.nextDouble() * 0.2) - 0.1), yCoord + 1, zCoord + 0.5 + ((worldObj.rand.nextDouble() * 0.2) - 0.1));
            if (particle != null) {
                particle.AddParticleController(new ParticleMoveOnHeading(particle, worldObj.rand.nextDouble() * 360, -45 - worldObj.rand.nextInt(90), 0.05f, 1, false));
                particle.AddParticleController(new ParticleFadeOut(particle, 2, false).setFadeSpeed(0.05f).setKillParticleOnFinish(true));
                particle.setIgnoreMaxAge(true);
                if (getOverpowered()) {
                    particle.setRGBColorF(1.0f, 0.2f, 0.2f);
                }
            }
        }
    }
}
Also used : AMParticle(am2.particles.AMParticle) ParticleFadeOut(am2.particles.ParticleFadeOut) ParticleMoveOnHeading(am2.particles.ParticleMoveOnHeading)

Example 8 with ParticleMoveOnHeading

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

the class TileEntitySeerStone method updateEntity.

@Override
public void updateEntity() {
    super.updateEntity();
    if (!worldObj.isRemote && isActive()) {
        if (hasSight)
            PowerNodeRegistry.For(worldObj).consumePower(this, PowerTypes.LIGHT, 0.25f);
        else
            PowerNodeRegistry.For(worldObj).consumePower(this, PowerTypes.LIGHT, 0.125f);
    }
    ticksToNextCheck--;
    if (ticksToNextCheck <= 0 && isActive()) {
        ticksToNextCheck = maxTicksToCheck;
        long key = KeystoneUtilities.instance.getKeyFromRunes(getRunesInKey());
        int radius = GetSearchRadius();
        Class searchClass = GetSearchClass();
        ArrayList<Entity> nearbyMobs = new ArrayList<Entity>();
        if (searchClass != null) {
            nearbyMobs = (ArrayList<Entity>) this.worldObj.getEntitiesWithinAABB(searchClass, AxisAlignedBB.getBoundingBox(xCoord - radius, yCoord - radius, zCoord - radius, xCoord + radius, yCoord + radius, zCoord + radius));
            if (key > 0) {
                ArrayList<Entity> mobsToIgnore = new ArrayList<Entity>();
                for (Entity e : nearbyMobs) {
                    if (swapDetectionMode) {
                        if (!(e instanceof EntityPlayer)) {
                            mobsToIgnore.add(e);
                            continue;
                        }
                        if (!KeystoneUtilities.instance.GetKeysInInvenory((EntityLivingBase) e).contains(key)) {
                            mobsToIgnore.add(e);
                        }
                    } else {
                        if (!(e instanceof EntityPlayer))
                            continue;
                        if (KeystoneUtilities.instance.GetKeysInInvenory((EntityLivingBase) e).contains(key)) {
                            mobsToIgnore.add(e);
                        }
                    }
                }
                for (Entity e : mobsToIgnore) nearbyMobs.remove(e);
            }
        }
        if (nearbyMobs.size() > 0) {
            if (!hasSight) {
                hasSight = true;
                notifyNeighborsOfPowerChange();
                if (worldObj.isRemote) {
                    currentAnimation.reset(false);
                    currentAnimation = animations.get(0);
                    currentAnimation.reset(true);
                }
            }
        } else {
            if (hasSight) {
                hasSight = false;
                notifyNeighborsOfPowerChange();
                if (worldObj.isRemote) {
                    currentAnimation.reset(false);
                    currentAnimation = animations.get(0);
                    currentAnimation.reset(false);
                }
            }
        }
    } else {
        if (hasSight && !isActive()) {
            hasSight = false;
            notifyNeighborsOfPowerChange();
            if (worldObj.isRemote) {
                currentAnimation.reset(false);
                currentAnimation = animations.get(0);
                currentAnimation.reset(false);
            }
        }
    }
    //animations
    if (worldObj.isRemote) {
        if (!currentAnimation.isDone) {
            tickCounter++;
            if (tickCounter == currentAnimation.speed) {
                tickCounter = 0;
                currentAnimation.incrementIndex();
            }
        } else {
            if (isActive() && hasSight) {
                currentAnimation = GetWeightedRandomAnimation();
            }
        }
        if (isActive() && hasSight) {
            int meta = worldObj.getBlockMetadata(xCoord, yCoord, zCoord);
            double yaw = 0;
            double y = yCoord + 0.5;
            double x = xCoord + 0.5;
            double z = zCoord + 0.5;
            switch(meta) {
                case 1:
                    y += 0.3;
                    break;
                case 2:
                    y -= 0.3;
                    break;
                case 3:
                    yaw = 270;
                    z += 0.3;
                    break;
                case 4:
                    yaw = 90;
                    z -= 0.3;
                    break;
                case 5:
                    yaw = 180;
                    x += 0.3;
                    break;
                case 6:
                    yaw = 0;
                    x -= 0.3;
                    break;
            }
            AMParticle effect = (AMParticle) AMCore.instance.proxy.particleManager.spawn(worldObj, "sparkle2", x, y, z);
            if (effect != null) {
                effect.setIgnoreMaxAge(false);
                effect.setMaxAge(35);
                switch(meta) {
                    case 1:
                        effect.AddParticleController(new ParticleFloatUpward(effect, 0.1f, -0.01f, 1, false));
                        break;
                    case 2:
                        effect.AddParticleController(new ParticleFloatUpward(effect, 0.1f, 0.01f, 1, false));
                        break;
                    case 3:
                    case 4:
                    case 5:
                    case 6:
                        effect.AddParticleController(new ParticleMoveOnHeading(effect, yaw, 0, 0.01f, 1, false));
                        effect.AddParticleController(new ParticleFloatUpward(effect, 0.1f, 0, 1, false));
                }
            }
        }
    }
}
Also used : S35PacketUpdateTileEntity(net.minecraft.network.play.server.S35PacketUpdateTileEntity) Entity(net.minecraft.entity.Entity) AMParticle(am2.particles.AMParticle) ArrayList(java.util.ArrayList) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ParticleFloatUpward(am2.particles.ParticleFloatUpward) ParticleMoveOnHeading(am2.particles.ParticleMoveOnHeading)

Example 9 with ParticleMoveOnHeading

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

the class ParticleManagerClient method spawnAuraParticles.

@Override
public void spawnAuraParticles(EntityLivingBase ent) {
    if (!ent.worldObj.isRemote)
        return;
    int particleIndex = 15;
    int particleBehaviour = 0;
    float particleScale = 0;
    float particleAlpha = 0;
    boolean particleDefaultColor = true;
    boolean particleRandomColor = true;
    int particleColor = 0xFFFFFF;
    int particleQuantity = 2;
    float particleSpeed = 0.02f;
    if (Minecraft.getMinecraft().thePlayer == ent) {
        particleIndex = AMCore.config.getAuraIndex();
        particleBehaviour = AMCore.config.getAuraBehaviour();
        particleScale = AMCore.config.getAuraScale() / 10;
        particleAlpha = AMCore.config.getAuraAlpha();
        particleDefaultColor = AMCore.config.getAuraColorDefault();
        particleRandomColor = AMCore.config.getAuraColorRandom();
        particleColor = AMCore.config.getAuraColor();
        particleQuantity = AMCore.config.getAuraQuantity();
        particleSpeed = AMCore.config.getAuraSpeed() / 10;
    } else {
        ExtendedProperties entProperties = ExtendedProperties.For(ent);
        particleIndex = entProperties.getAuraIndex();
        particleBehaviour = entProperties.getAuraBehaviour();
        particleScale = entProperties.getAuraScale() / 10;
        particleAlpha = entProperties.getAuraAlpha();
        particleDefaultColor = entProperties.getAuraColorDefault();
        particleRandomColor = entProperties.getAuraColorRandomize();
        particleColor = entProperties.getAuraColor();
        particleQuantity = entProperties.getAuraQuantity();
        particleSpeed = entProperties.getAuraSpeed() / 10;
    }
    if (//fix radiant particle's scaling issues...
    particleIndex == 31)
        particleScale /= 10;
    if (ent.worldObj.isRemote && ent instanceof EntityPlayer && AMCore.proxy.playerTracker.hasAA((EntityPlayer) ent)) {
        if (Minecraft.getMinecraft().thePlayer != ent || Minecraft.getMinecraft().gameSettings.thirdPersonView > 0) {
            if (AMParticle.particleTypes[particleIndex].startsWith("lightning_bolts")) {
                int type = Integer.parseInt(new String(new char[] { AMParticle.particleTypes[particleIndex].charAt(AMParticle.particleTypes[particleIndex].length() - 1) }));
                if (ent.worldObj.rand.nextInt(100) < 90) {
                    BoltFromPointToPoint(ent.worldObj, ent.posX + (ent.worldObj.rand.nextFloat() - 0.5f), ent.posY + ent.getEyeHeight() - ent.height + (ent.worldObj.rand.nextFloat() * ent.height), ent.posZ + (ent.worldObj.rand.nextFloat() - 0.5f), ent.posX + (ent.worldObj.rand.nextFloat() - 0.5f), ent.posY + ent.getEyeHeight() - ent.height + (ent.worldObj.rand.nextFloat() * ent.height), ent.posZ + (ent.worldObj.rand.nextFloat() - 0.5f), type, -1);
                } else {
                    BoltFromPointToPoint(ent.worldObj, ent.posX, ent.posY + ent.getEyeHeight() - 0.4, ent.posZ, ent.posX + (ent.worldObj.rand.nextFloat() * 10 - 5), ent.posY + (ent.worldObj.rand.nextFloat() * 10 - 5), ent.posZ + (ent.worldObj.rand.nextFloat() * 10 - 5), type, -1);
                }
            } else {
                int offset = 0;
                for (int i = 0; i < particleQuantity; ++i) {
                    AMParticle effect = spawn(ent.worldObj, AMParticle.particleTypes[particleIndex], ent.posX + (ent.worldObj.rand.nextFloat() - 0.5f), ent.posY + ent.getEyeHeight() - 0.5f + offset - (ent.worldObj.rand.nextFloat() * 0.5), ent.posZ + (ent.worldObj.rand.nextFloat() - 0.5f));
                    if (effect != null) {
                        effect.setIgnoreMaxAge(false);
                        effect.setMaxAge(40);
                        effect.setParticleScale(particleScale);
                        effect.SetParticleAlpha(particleAlpha);
                        effect.noClip = false;
                        if (!particleDefaultColor) {
                            if (particleRandomColor) {
                                effect.setRGBColorF(ent.worldObj.rand.nextFloat(), ent.worldObj.rand.nextFloat(), ent.worldObj.rand.nextFloat());
                            } else {
                                effect.setRGBColorI(particleColor);
                            }
                        }
                        switch(particleBehaviour) {
                            case //fade
                            0:
                                effect.AddParticleController(new ParticleFadeOut(effect, 1, false).setFadeSpeed(particleSpeed));
                                break;
                            case //float
                            1:
                                effect.AddParticleController(new ParticleFloatUpward(effect, 0.2f, particleSpeed, 1, false));
                                break;
                            case //sink
                            2:
                                effect.AddParticleController(new ParticleFloatUpward(effect, 0.2f, -particleSpeed, 1, false));
                                break;
                            case //orbit
                            3:
                                effect.AddParticleController(new ParticleOrbitEntity(effect, ent, particleSpeed, 1, false));
                                break;
                            case //arc
                            4:
                                effect.AddParticleController(new ParticleArcToEntity(effect, 1, ent, false).generateControlPoints().SetSpeed(particleSpeed));
                                break;
                            case //flee
                            5:
                                effect.AddParticleController(new ParticleFleeEntity(effect, ent, particleSpeed, 2D, 1, false));
                                break;
                            case //forward
                            6:
                                effect.AddParticleController(new ParticleMoveOnHeading(effect, ent.rotationYaw + 90, ent.rotationPitch, particleSpeed, 1, false));
                                break;
                            case //pendulum
                            7:
                                effect.AddParticleController(new ParticlePendulum(effect, 0.2f, particleSpeed, 1, false));
                                break;
                            case //grow
                            8:
                                effect.AddParticleController(new ParticleGrow(effect, particleSpeed, 1, false));
                                break;
                        }
                    }
                }
            }
        }
    }
}
Also used : ExtendedProperties(am2.playerextensions.ExtendedProperties) EntityPlayer(net.minecraft.entity.player.EntityPlayer)

Example 10 with ParticleMoveOnHeading

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

the class Knockback 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 < 25; ++i) {
        AMParticle particle = (AMParticle) AMCore.proxy.particleManager.spawn(world, "sparkle", x, y, z);
        if (particle != null) {
            particle.addRandomOffset(1, 2, 1);
            double dx = caster.posX - target.posX;
            double dz = caster.posZ - target.posZ;
            double angle = Math.toDegrees(Math.atan2(-dz, -dx));
            particle.AddParticleController(new ParticleMoveOnHeading(particle, angle, 0, 0.1 + rand.nextDouble() * 0.5, 1, false));
            particle.AddParticleController(new ParticleFadeOut(particle, 1, false).setFadeSpeed(0.05f));
            particle.setMaxAge(20);
            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) ParticleFadeOut(am2.particles.ParticleFadeOut) ParticleMoveOnHeading(am2.particles.ParticleMoveOnHeading)

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