Search in sources :

Example 1 with ParticleHoldPosition

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

the class TileEntityAstralBarrier method updateEntity.

@Override
public void updateEntity() {
    super.updateEntity();
    int radius = getRadius();
    if (IsActive()) {
        PowerNodeRegistry.For(this.worldObj).consumePower(this, PowerNodeRegistry.For(worldObj).getHighestPowerType(this), 0.35f * radius);
    }
    if (worldObj.isRemote) {
        if (IsActive()) {
            if (displayAura) {
                AMParticle effect = (AMParticle) AMCore.instance.proxy.particleManager.spawn(worldObj, "symbols", xCoord, yCoord + 0.5, zCoord);
                if (effect != null) {
                    effect.setIgnoreMaxAge(false);
                    effect.setMaxAge(100);
                    effect.setParticleScale(0.5f);
                    effect.AddParticleController(new ParticleOrbitPoint(effect, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, 1, false).SetOrbitSpeed(0.03).SetTargetDistance(radius));
                }
            }
            particleTickCounter++;
            if (particleTickCounter >= 15) {
                particleTickCounter = 0;
                String particleName = "";
                AMParticle effect = (AMParticle) AMCore.instance.proxy.particleManager.spawn(worldObj, "sparkle", xCoord + 0.5, yCoord + 0.1 + worldObj.rand.nextDouble() * 0.5, zCoord + 0.5);
                if (effect != null) {
                    effect.setIgnoreMaxAge(false);
                    effect.setMaxAge(100);
                    effect.setParticleScale(0.5f);
                    float color = worldObj.rand.nextFloat() * 0.2f + 0.8f;
                    effect.AddParticleController(new ParticleOrbitPoint(effect, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, 1, false).SetOrbitSpeed(0.005).SetTargetDistance(worldObj.rand.nextDouble() * 0.6 - 0.3));
                    effect.AddParticleController(new ParticleHoldPosition(effect, 80, 2, true));
                    effect.AddParticleController(new ParticleFadeOut(effect, 3, false).setFadeSpeed(0.05f));
                }
            }
        }
    }
}
Also used : AMParticle(am2.particles.AMParticle) ParticleHoldPosition(am2.particles.ParticleHoldPosition) ParticleOrbitPoint(am2.particles.ParticleOrbitPoint) ParticleFadeOut(am2.particles.ParticleFadeOut) ParticleOrbitPoint(am2.particles.ParticleOrbitPoint)

Example 2 with ParticleHoldPosition

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

the class EntityLightningGuardian method onUpdate.

@Override
public void onUpdate() {
    super.onUpdate();
    if (this.getAttackTarget() != null) {
        if (this.getCurrentAction() != BossActions.LONG_CASTING) {
            ExtendedProperties.For(getAttackTarget()).setDisableGravity(false);
        }
        if (!this.worldObj.isRemote && this.getDistanceSqToEntity(getAttackTarget()) > 64D && this.getCurrentAction() == BossActions.IDLE) {
            this.getNavigator().tryMoveToEntityLiving(getAttackTarget(), 0.5f);
        }
    }
    if (worldObj.isRemote) {
        int halfDist = 8;
        int dist = 16;
        if (this.getCurrentAction() == BossActions.CHARGE) {
            if (ticksInCurrentAction > 50) {
                for (int i = 0; i < 2 * AMCore.config.getGFXLevel(); ++i) {
                    AMParticle smoke = (AMParticle) AMCore.proxy.particleManager.spawn(worldObj, "smoke", posX, posY + 4, posZ);
                    if (smoke != null) {
                        smoke.addRandomOffset(halfDist, 1, halfDist);
                        smoke.SetParticleAlpha(1f);
                        smoke.setParticleScale(1f);
                        smoke.setMaxAge(20);
                        smoke.AddParticleController(new ParticleHoldPosition(smoke, 10, 1, false));
                    }
                }
            }
            if (ticksInCurrentAction > 66) {
                AMCore.proxy.particleManager.BoltFromPointToPoint(worldObj, posX + rand.nextDouble() - 0.5, posY + rand.nextDouble() - 0.5 + 2, posZ + rand.nextDouble() - 0.5, posX + rand.nextDouble() * dist - halfDist, posY + rand.nextDouble() * dist - halfDist, posZ + rand.nextDouble() * dist - halfDist);
            }
        } else if (this.getCurrentAction() == BossActions.LONG_CASTING) {
            if (ticksInCurrentAction > 25 && ticksInCurrentAction < 150) {
                for (int i = 0; i < 2 * AMCore.config.getGFXLevel(); ++i) {
                    AMParticle smoke = (AMParticle) AMCore.proxy.particleManager.spawn(worldObj, "smoke", posX, posY + 4, posZ);
                    if (smoke != null) {
                        smoke.addRandomOffset(halfDist, 1, halfDist);
                        smoke.SetParticleAlpha(1f);
                        smoke.setParticleScale(1f);
                        smoke.setRGBColorI(ticksInCurrentAction < 85 ? 0xFFFFFF - 0x111111 * ((ticksInCurrentAction - 25) / 4) : 0x222222);
                        smoke.setMaxAge(20);
                        smoke.AddParticleController(new ParticleHoldPosition(smoke, 10, 1, false));
                    }
                }
            }
        }
    }
}
Also used : AMParticle(am2.particles.AMParticle) ParticleHoldPosition(am2.particles.ParticleHoldPosition)

Example 3 with ParticleHoldPosition

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

the class EntityThrownRock method onUpdate.

@Override
public void onUpdate() {
    super.onUpdate();
    if (this.target != null && this.posY > this.target.y) {
        double deltaX = this.posX - target.x;
        double deltaY = this.posY - target.y;
        double deltaZ = this.posZ - target.z;
        double angle = Math.atan2(deltaZ, deltaX);
        double hDist = Math.sqrt(deltaX * deltaX + deltaZ * deltaZ);
        double vAngle = Math.atan2(deltaY, hDist);
        motionX = -Math.cos(angle) * 0.2;
        motionZ = -Math.sin(angle) * 0.2;
        motionY = -Math.sin(vAngle) * 2.5;
    }
    if (!getIsMoonstoneMeteor() && !getIsShootingStar()) {
        if (!worldObj.isRemote && (throwingEntity == null || throwingEntity.isDead)) {
            setDead();
        } else {
            ticksExisted++;
            int maxTicksToLive = maxTicksToExist > -1 ? maxTicksToExist : 100;
            if (ticksExisted >= maxTicksToLive && !worldObj.isRemote) {
                setDead();
                return;
            }
        }
    }
    if (getIsShootingStar()) {
        motionY -= 0.1f;
        if (motionY < -2f)
            motionY = -2f;
    }
    if (worldObj.isRemote) {
        if (getIsMoonstoneMeteor()) {
            AMParticle fire = (AMParticle) AMCore.proxy.particleManager.spawn(worldObj, "explosion_2", posX, posY, posZ);
            if (fire != null) {
                fire.setMaxAge(20);
                fire.setRGBColorF(1, 1, 1);
                fire.setParticleScale(2.0f);
                fire.AddParticleController(new ParticleHoldPosition(fire, 20, 1, false));
                fire.AddParticleController(new ParticleColorShift(fire, 1, false).SetShiftSpeed(0.1f).SetColorTarget(0.01f, 0.01f, 0.01f).SetEndOnReachingTargetColor().setKillParticleOnFinish(false));
            }
        } else if (getIsShootingStar()) {
            int color = -1;
            if (getSpellStack() != null) {
                if (SpellUtils.instance.modifierIsPresent(SpellModifiers.COLOR, getSpellStack(), 0)) {
                    ISpellModifier[] mods = SpellUtils.instance.getModifiersForStage(getSpellStack(), 0);
                    int ordinalCount = 0;
                    for (ISpellModifier mod : mods) {
                        if (mod instanceof Colour) {
                            byte[] meta = SpellUtils.instance.getModifierMetadataFromStack(getSpellStack(), mod, 0, ordinalCount++);
                            color = (int) mod.getModifier(SpellModifiers.COLOR, null, null, null, meta);
                        }
                    }
                }
            }
            for (float i = 0; i < Math.abs(motionY); i += 0.1f) {
                AMParticle star = (AMParticle) AMCore.proxy.particleManager.spawn(worldObj, "ember", posX + motionX * i, posY + motionY * i, posZ + motionZ * i);
                if (star != null) {
                    star.setMaxAge(22);
                    float clr = rand.nextFloat();
                    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]);
                    }
                    star.setRGBColorI(finalColor);
                    star.AddParticleController(new ParticleHoldPosition(star, 20, 1, false));
                    star.AddParticleController(new ParticleChangeSize(star, 0.5f, 0.05f, 20, 1, false));
                }
            }
        }
    }
    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(throwingEntity) && 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.2F;
    rotationYaw = prevRotationYaw + (rotationYaw - prevRotationYaw) * 0.2F;
    float f1 = 0.95F;
    setPosition(posX, posY, posZ);
}
Also used : Entity(net.minecraft.entity.Entity) AMParticle(am2.particles.AMParticle) ParticleColorShift(am2.particles.ParticleColorShift) ISpellModifier(am2.api.spell.component.interfaces.ISpellModifier) ParticleHoldPosition(am2.particles.ParticleHoldPosition) Colour(am2.spell.modifiers.Colour) ParticleChangeSize(am2.particles.ParticleChangeSize) List(java.util.List)

Example 4 with ParticleHoldPosition

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

the class TileEntityArcaneDeconstructor method updateEntity.

@Override
public void updateEntity() {
    super.updateEntity();
    if (worldObj.isRemote) {
        if (particleCounter == 0 || particleCounter++ > 1000) {
            particleCounter = 1;
            radiant = (AMParticle) AMCore.proxy.particleManager.spawn(worldObj, "radiant", xCoord + 0.5f, yCoord + 0.5f, zCoord + 0.5f);
            if (radiant != null) {
                radiant.setMaxAge(1000);
                radiant.setRGBColorF(0.1f, 0.1f, 0.1f);
                radiant.setParticleScale(0.1f);
                radiant.AddParticleController(new ParticleHoldPosition(radiant, 1000, 1, false));
            }
        }
    } else {
        if (!isActive()) {
            if (inventory[0] != null) {
                current_deconstruction_time = 1;
            }
        } else {
            if (inventory[0] == null) {
                current_deconstruction_time = 0;
                deconstructionRecipe = null;
                worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
            } else {
                if (PowerNodeRegistry.For(worldObj).checkPower(this, PowerTypes.DARK, DECONSTRUCTION_POWER_COST)) {
                    if (deconstructionRecipe == null) {
                        if (!getDeconstructionRecipe()) {
                            transferOrEjectItem(inventory[0]);
                            setInventorySlotContents(0, null);
                        }
                    } else {
                        if (current_deconstruction_time++ >= DECONSTRUCTION_TIME) {
                            if (getDeconstructionRecipe() == true) {
                                for (ItemStack stack : deconstructionRecipe) {
                                    transferOrEjectItem(stack);
                                }
                            }
                            deconstructionRecipe = null;
                            decrStackSize(0, 1);
                            current_deconstruction_time = 0;
                        }
                        if (current_deconstruction_time % 10 == 0)
                            worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
                    }
                    PowerNodeRegistry.For(worldObj).consumePower(this, PowerTypes.DARK, DECONSTRUCTION_POWER_COST);
                }
            }
        }
    }
}
Also used : ParticleHoldPosition(am2.particles.ParticleHoldPosition) ItemStack(net.minecraft.item.ItemStack)

Example 5 with ParticleHoldPosition

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

the class Reflect 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, "lens_flare", x, y, z);
        if (particle != null) {
            particle.addRandomOffset(1, 2, 1);
            particle.AddParticleController(new ParticleHoldPosition(particle, 20, 1, false));
            particle.setMaxAge(20);
            particle.setParticleScale(0.2f);
            particle.setRGBColorF(0.5f + rand.nextFloat() * 0.5f, 0.1f, 0.5f + rand.nextFloat() * 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) ParticleHoldPosition(am2.particles.ParticleHoldPosition)

Aggregations

ParticleHoldPosition (am2.particles.ParticleHoldPosition)11 AMParticle (am2.particles.AMParticle)10 ParticleColorShift (am2.particles.ParticleColorShift)2 ParticleFloatUpward (am2.particles.ParticleFloatUpward)2 List (java.util.List)2 Block (net.minecraft.block.Block)2 Entity (net.minecraft.entity.Entity)2 AMVector3 (am2.api.math.AMVector3)1 ISpellModifier (am2.api.spell.component.interfaces.ISpellModifier)1 BuffList (am2.buffs.BuffList)1 ParticleChangeSize (am2.particles.ParticleChangeSize)1 ParticleFadeOut (am2.particles.ParticleFadeOut)1 ParticleOrbitPoint (am2.particles.ParticleOrbitPoint)1 Colour (am2.spell.modifiers.Colour)1 SideOnly (cpw.mods.fml.relauncher.SideOnly)1 ArrayList (java.util.ArrayList)1 EntityLivingBase (net.minecraft.entity.EntityLivingBase)1 EntityDragonPart (net.minecraft.entity.boss.EntityDragonPart)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 ItemStack (net.minecraft.item.ItemStack)1