Search in sources :

Example 1 with ParticleFloatUpward

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

the class BlockDesertNova method randomDisplayTick.

@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World world, int x, int y, int z, Random par5Random) {
    if (par5Random.nextInt(10) != 0)
        return;
    int increment = AMCore.config.getGFXLevel() * 15;
    if (increment <= 0)
        return;
    for (int i = 0; i < 360; i += increment) {
        int angle = i;
        double posX = x + 0.5 + Math.cos(angle) * 3;
        double posZ = z + 0.5 + Math.sin(angle) * 3;
        double posY = y + 0.6 + par5Random.nextFloat() * 0.2f;
        AMParticle effect = (AMParticle) AMCore.instance.proxy.particleManager.spawn(world, "explosion_2", x + 0.5, posY, z + 0.5);
        if (effect != null) {
            effect.setIgnoreMaxAge(true);
            effect.AddParticleController(new ParticleExpandingCollapsingRingAtPoint(effect, posX, posY, posZ, 0.3, 3, 0.2, 1, false).setExpanding());
            // effect.AddParticleController(new ParticleOrbitPoint(effect, x+0.5, y, z+0.5, 1, false).SetTargetDistance(0.35f + par5Random.nextFloat() * 0.2f).SetOrbitSpeed(0.5f).setIgnoreYCoordinate(true));
            // effect.AddParticleController(new ParticleFloatUpward(effect, 0, 0.035f, 1, false));
            effect.AddParticleController(new ParticleFadeOut(effect, 2, false).setFadeSpeed(0.05f).setKillParticleOnFinish(true));
            effect.setParticleScale(0.05f);
        }
    }
}
Also used : AMParticle(am2.particles.AMParticle) ParticleExpandingCollapsingRingAtPoint(am2.particles.ParticleExpandingCollapsingRingAtPoint) ParticleFadeOut(am2.particles.ParticleFadeOut) ParticleExpandingCollapsingRingAtPoint(am2.particles.ParticleExpandingCollapsingRingAtPoint) SideOnly(cpw.mods.fml.relauncher.SideOnly)

Example 2 with ParticleFloatUpward

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

the class EntityWaterElemental method spawnLivingParticles.

private void spawnLivingParticles() {
    if (rand.nextBoolean()) {
        double yPos = this.posY + 1.1;
        AMParticle effect = (AMParticle) AMCore.instance.proxy.particleManager.spawn(worldObj, "water_ball", this.posX + ((rand.nextFloat() * 0.2) - 0.1f), yPos, this.posZ + ((rand.nextFloat() * 0.4) - 0.2f));
        if (effect != null) {
            effect.AddParticleController(new ParticleFloatUpward(effect, 0.1f, -0.06f, 1, false));
            effect.AddParticleController(new ParticleFadeOut(effect, 2, false).setFadeSpeed(0.04f));
            effect.setMaxAge(25);
            effect.setIgnoreMaxAge(false);
            effect.setParticleScale(0.1f);
        }
    }
}
Also used : AMParticle(am2.particles.AMParticle) ParticleFadeOut(am2.particles.ParticleFadeOut) ParticleFloatUpward(am2.particles.ParticleFloatUpward)

Example 3 with ParticleFloatUpward

use of am2.particles.ParticleFloatUpward 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 4 with ParticleFloatUpward

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

the class EntitySpellEffect method wallUpdate.

private void wallUpdate() {
    if (worldObj.isRemote) {
        if (spellStack == null) {
            spellStack = this.dataWatcher.getWatchableObjectItemStack(22);
            if (spellStack == null) {
                return;
            }
        }
        double dist = this.dataWatcher.getWatchableObjectFloat(WATCHER_RADIUS);
        int color = 0xFFFFFF;
        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);
                }
            }
        }
        double px = Math.cos(3.141 / 180 * (rotationYaw + 90)) * 0.1f;
        double pz = Math.sin(3.141 / 180 * (rotationYaw + 90)) * 0.1f;
        double py = 0.1f;
        for (float i = 0; i < dist; i += 0.5f) {
            double x = this.posX - Math.cos(3.141 / 180 * (rotationYaw)) * i;
            double z = this.posZ - Math.sin(3.141 / 180 * (rotationYaw)) * i;
            AMParticle effect = (AMParticle) AMCore.instance.proxy.particleManager.spawn(worldObj, AMParticleIcons.instance.getParticleForAffinity(SpellUtils.instance.mainAffinityFor(spellStack)), x, posY, z);
            if (effect != null) {
                effect.setIgnoreMaxAge(false);
                effect.setMaxAge(20);
                effect.addRandomOffset(1, 1, 1);
                effect.setParticleScale(0.15f);
                effect.setRGBColorI(color);
                if (dataWatcher.getWatchableObjectInt(WATCHER_TYPE) == TYPE_WALL) {
                    effect.AddParticleController(new ParticleFloatUpward(effect, 0, 0.07f, 1, false));
                } else {
                    effect.setAffectedByGravity();
                    effect.setDontRequireControllers();
                    effect.addVelocity(px, py, pz);
                }
            }
            x = this.posX - Math.cos(Math.toRadians(rotationYaw)) * -i;
            z = this.posZ - Math.sin(Math.toRadians(rotationYaw)) * -i;
            effect = (AMParticle) AMCore.instance.proxy.particleManager.spawn(worldObj, AMParticleIcons.instance.getParticleForAffinity(SpellUtils.instance.mainAffinityFor(spellStack)), x, posY, z);
            if (effect != null) {
                effect.setIgnoreMaxAge(false);
                effect.addRandomOffset(1, 1, 1);
                effect.setMaxAge(20);
                effect.setParticleScale(0.15f);
                effect.setRGBColorI(color);
                if (dataWatcher.getWatchableObjectInt(WATCHER_TYPE) == TYPE_WALL) {
                    effect.AddParticleController(new ParticleFloatUpward(effect, 0, 0.07f, 1, false));
                } else {
                    effect.setAffectedByGravity();
                    effect.setDontRequireControllers();
                    effect.addVelocity(px, py, pz);
                }
            }
        }
    } else {
        ticksToEffect--;
        if (spellStack == null) {
            if (!worldObj.isRemote) {
                this.setDead();
            }
            return;
        }
        if (dummycaster == null) {
            dummycaster = DummyEntityPlayer.fromEntityLiving(new EntityDummyCaster(worldObj));
        }
        if (ticksToEffect <= 0) {
            ticksToEffect = maxTicksToEffect_wall;
            float radius = this.dataWatcher.getWatchableObjectFloat(WATCHER_RADIUS);
            List<Entity> possibleTargets = worldObj.getEntitiesWithinAABB(Entity.class, AxisAlignedBB.getBoundingBox(posX - radius, posY - 1, posZ - radius, posX + radius, posY + 3, posZ + radius));
            ItemStack newStack = SpellUtils.instance.popStackStage(spellStack);
            for (Entity e : possibleTargets) {
                if (e == this || e == dummycaster || e.getEntityId() == casterEntityID)
                    continue;
                if (e instanceof EntityDragonPart && ((EntityDragonPart) e).entityDragonObj instanceof EntityLivingBase)
                    e = (EntityLivingBase) ((EntityDragonPart) e).entityDragonObj;
                AMVector3 target = new AMVector3(e);
                double dirX = Math.cos(3.141 / 180 * (rotationYaw));
                double dirZ = Math.sin(3.141 / 180 * (rotationYaw));
                AMVector3 a = new AMVector3(this.posX - dirX * radius, this.posY, this.posZ - dirZ * radius);
                AMVector3 b = new AMVector3(this.posX - dirX * -radius, this.posY, this.posZ - dirZ * -radius);
                AMVector3 closest = new AMLineSegment(a, b).closestPointOnLine(target);
                closest.y = 0;
                target.y = 0;
                double hDistance = closest.distanceTo(target);
                double vDistance = Math.abs(this.posY - e.posY);
                if (e instanceof EntityLivingBase && hDistance < 0.75f && vDistance < 2) {
                    // commented out in favor of line below so as to apply subsequent shapes as well
                    // uncomment and comment out below line to revert to direct target only, but mark wave/wall as terminus
                    // SpellHelper.instance.applyStageToEntity(spellStack, dummycaster, worldObj, e, 0, false);
                    SpellHelper.instance.applyStackStage(spellStack, dummycaster, (EntityLivingBase) e, this.posX, this.posY, this.posZ, 0, worldObj, false, false, 0);
                }
            }
        }
    }
}
Also used : AMLineSegment(am2.api.math.AMLineSegment) Entity(net.minecraft.entity.Entity) ISpellModifier(am2.api.spell.component.interfaces.ISpellModifier) Colour(am2.spell.modifiers.Colour) AMVector3(am2.api.math.AMVector3) EntityDragonPart(net.minecraft.entity.boss.EntityDragonPart) EntityLivingBase(net.minecraft.entity.EntityLivingBase) ItemStack(net.minecraft.item.ItemStack)

Example 5 with ParticleFloatUpward

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

the class EntityBroom method interact.

@Override
protected boolean interact(EntityPlayer par1EntityPlayer) {
    if (par1EntityPlayer.getCurrentEquippedItem() != null && par1EntityPlayer.getCurrentEquippedItem().getItem() == ItemsCommonProxy.spellStaffMagitech) {
        if (this.worldObj.isRemote) {
            for (int i = 0; i < AMCore.config.getGFXLevel() * 2; ++i) {
                AMParticle particle = (AMParticle) AMCore.proxy.particleManager.spawn(worldObj, "smoke", posX, posY, posZ);
                if (particle != null) {
                    particle.AddParticleController(new ParticleFloatUpward(particle, 0.1f, 0.3f, 1, false));
                    particle.addRandomOffset(0.3, 1, 0.3);
                    particle.setMaxAge(10);
                }
            }
        } else {
            this.entityDropItem(new ItemStack(ItemsCommonProxy.magicBroom), 0);
            dropInventoryItems();
            this.setDead();
        }
        return true;
    }
    return false;
}
Also used : AMParticle(am2.particles.AMParticle) ParticleFloatUpward(am2.particles.ParticleFloatUpward) ItemStack(net.minecraft.item.ItemStack)

Aggregations

AMParticle (am2.particles.AMParticle)39 ParticleFloatUpward (am2.particles.ParticleFloatUpward)38 ParticleFadeOut (am2.particles.ParticleFadeOut)11 ParticleOrbitEntity (am2.particles.ParticleOrbitEntity)7 AMVector3 (am2.api.math.AMVector3)4 Entity (net.minecraft.entity.Entity)4 EntityLivingBase (net.minecraft.entity.EntityLivingBase)4 TileEntity (net.minecraft.tileentity.TileEntity)4 ParticleOrbitPoint (am2.particles.ParticleOrbitPoint)3 SideOnly (cpw.mods.fml.relauncher.SideOnly)3 EntityDragonPart (net.minecraft.entity.boss.EntityDragonPart)3 EntityPlayer (net.minecraft.entity.player.EntityPlayer)3 ISpellModifier (am2.api.spell.component.interfaces.ISpellModifier)2 ParticleHoldPosition (am2.particles.ParticleHoldPosition)2 ParticleMoveOnHeading (am2.particles.ParticleMoveOnHeading)2 Colour (am2.spell.modifiers.Colour)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Block (net.minecraft.block.Block)2 EntityAnimal (net.minecraft.entity.passive.EntityAnimal)2