Search in sources :

Example 26 with ParticleFloatUpward

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

the class EntitySpellProjectile method onUpdate.

@Override
public void onUpdate() {
    // super.onUpdate();
    if (!worldObj.isRemote && (getShootingEntity() == null || getShootingEntity().isDead)) {
        setDead();
    } else {
        ticksExisted++;
        int maxTicksToLive = maxTicksToExist > -1 ? maxTicksToExist : 100;
        if (ticksExisted >= maxTicksToLive && !worldObj.isRemote) {
            setDead();
            return;
        }
    }
    // TODO Fix homing
    if (this.dataWatcher.getWatchableObjectByte(DW_HOMING) != (byte) 0 && this.ticksExisted > 10) {
        if (this.dataWatcher.getWatchableObjectInt(DW_HOMING_TARGET) == -1) {
            findHomingTarget();
        } else {
            EntityLivingBase homingTarget = getHomingEntity();
            // AMCore.log.info("%.2f, %.2f, %.2f", posX, posY, posZ);
            LogHelper.trace("Homing Target: " + getHomingEntity());
            if (homingTarget != null && new AMVector3(this).distanceSqTo(new AMVector3(homingTarget)) > 2) {
                this.moveTowards(homingTarget, 60, 60);
            }
        }
    }
    Vec3 vec3d = Vec3.createVectorHelper(posX, posY, posZ);
    Vec3 vec3d1 = Vec3.createVectorHelper(posX + motionX, posY + motionY, posZ + motionZ);
    MovingObjectPosition movingobjectposition = null;
    movingobjectposition = worldObj.rayTraceBlocks(vec3d, vec3d1, true);
    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(getShootingEntity())) {
            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) {
        if (entity instanceof EntityDragonPart && ((EntityDragonPart) entity).entityDragonObj != null && ((EntityDragonPart) entity).entityDragonObj instanceof EntityLivingBase) {
            entity = (EntityLivingBase) ((EntityDragonPart) entity).entityDragonObj;
        }
        movingobjectposition = new MovingObjectPosition(entity);
    }
    if (movingobjectposition != null) {
        boolean doHit = true;
        boolean pierce = this.getNumPierces() > 0;
        if (movingobjectposition.typeOfHit == MovingObjectType.ENTITY && movingobjectposition.entityHit != null && movingobjectposition.entityHit instanceof EntityLivingBase) {
            EntityLivingBase ent = (EntityLivingBase) movingobjectposition.entityHit;
            if (ent.isPotionActive(BuffList.spellReflect.id) && !pierce) {
                doHit = false;
                this.setShootingEntity(ent);
                this.motionX = -this.motionX;
                this.motionY = -this.motionY;
                this.motionZ = -this.motionZ;
                if (!worldObj.isRemote)
                    ent.removePotionEffect(BuffList.spellReflect.id);
                setBounces(originalBounceCount);
                if (worldObj.isRemote) {
                    for (int i = 0; i < 13; ++i) {
                        AMParticle effect = (AMParticle) AMCore.instance.proxy.particleManager.spawn(worldObj, "hr_lensflare", ent.posX + rand.nextDouble() - 0.5, ent.posY + ent.getEyeHeight() + rand.nextDouble() - 0.5, ent.posZ + rand.nextDouble() - 0.5);
                        if (effect != null) {
                            EntityPlayer player = AMCore.instance.proxy.getLocalPlayer();
                            effect.setIgnoreMaxAge(true);
                            if (player != null && ent != player) {
                                effect.setParticleScale(1.5f);
                            }
                            effect.setRGBColorF(0.5f + rand.nextFloat() * 0.5f, 0.2f, 0.5f + rand.nextFloat() * 0.5f);
                            effect.AddParticleController(new ParticleHoldPosition(effect, 100, 1, false));
                        }
                    }
                }
            }
        } else if (movingobjectposition.typeOfHit == MovingObjectType.BLOCK && getBounces() > 0) {
            doHit = false;
            switch(movingobjectposition.sideHit) {
                case 0:
                case 1:
                    motionY = motionY * friction_coefficient * -1;
                    break;
                case 2:
                case 3:
                    motionZ = motionZ * friction_coefficient * -1;
                    break;
                case 4:
                case 5:
                    motionX = motionX * friction_coefficient * -1;
                    break;
            }
            this.setBounces(getBounces() - 1);
        }
        if (movingobjectposition.typeOfHit == MovingObjectType.BLOCK) {
            Block block = worldObj.getBlock(movingobjectposition.blockX, movingobjectposition.blockY, movingobjectposition.blockZ);
            AxisAlignedBB bb = block.getCollisionBoundingBoxFromPool(worldObj, movingobjectposition.blockX, movingobjectposition.blockY, movingobjectposition.blockZ);
            if (bb == null && !SpellUtils.instance.modifierIsPresent(SpellModifiers.TARGET_NONSOLID_BLOCKS, getEffectStack(), 0))
                doHit = false;
        }
        if (doHit)
            HitObject(movingobjectposition, pierce);
    }
    if (getGravity() < 0 && motionY > GRAVITY_TERMINAL_VELOCITY) {
        this.motionY += getGravity();
    } else if (getGravity() > 0 && motionY < -GRAVITY_TERMINAL_VELOCITY) {
        this.motionY -= getGravity();
    }
    posX += motionX;
    posY += motionY;
    posZ += motionZ;
    float f = MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ);
    rotationYaw = (float) (Math.atan2(motionX, motionZ));
    for (rotationPitch = (float) (Math.atan2(motionY, f)); 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;
    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;
    }
    if (!AMCore.config.NoGFX() && worldObj.isRemote && this.getShootingEntity() instanceof EntityPlayer) {
        if (this.particleType == null || this.particleType.isEmpty())
            particleType = AMParticleIcons.instance.getSecondaryParticleForAffinity(SpellUtils.instance.mainAffinityFor(getEffectStack()));
        AMParticle particle = (AMParticle) AMCore.proxy.particleManager.spawn(worldObj, particleType, this.posX, this.posY, this.posZ);
        if (particle != null) {
            particle.addRandomOffset(0.3f, 0.3f, 0.3f);
            particle.AddParticleController(new ParticleFloatUpward(particle, 0.1f, 0, 1, false));
            particle.setMaxAge(10);
            particle.setParticleScale(0.05f);
        }
    }
    setPosition(posX, posY, posZ);
}
Also used : Entity(net.minecraft.entity.Entity) AMParticle(am2.particles.AMParticle) ParticleHoldPosition(am2.particles.ParticleHoldPosition) ParticleFloatUpward(am2.particles.ParticleFloatUpward) AMVector3(am2.api.math.AMVector3) EntityDragonPart(net.minecraft.entity.boss.EntityDragonPart) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer) Block(net.minecraft.block.Block) ArrayList(java.util.ArrayList) BuffList(am2.buffs.BuffList) List(java.util.List)

Example 27 with ParticleFloatUpward

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

the class EntityShadowHelper method spawnParticles.

private void spawnParticles() {
    if (worldObj.isRemote) {
        for (int i = 0; i < 25 * AMCore.config.getGFXLevel() + 1; ++i) {
            AMParticle particle = (AMParticle) AMCore.proxy.particleManager.spawn(worldObj, "arcane", posX, posY, posZ);
            if (particle != null) {
                particle.addRandomOffset(1, 1, 1);
                particle.AddParticleController(new ParticleFloatUpward(particle, 0, 0.02f + getRNG().nextFloat() * 0.2f, 1, false));
                particle.setIgnoreMaxAge(false);
                particle.setMaxAge(20 + getRNG().nextInt(20));
            }
        }
    }
}
Also used : AMParticle(am2.particles.AMParticle) ParticleFloatUpward(am2.particles.ParticleFloatUpward)

Example 28 with ParticleFloatUpward

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

the class EntitySpellEffect method zoneUpdate.

private void zoneUpdate() {
    if (this.worldObj.isRemote) {
        if (!AMCore.config.NoGFX()) {
            this.rotation += this.rotationSpeed;
            this.rotation %= 360;
            double dist = this.dataWatcher.getWatchableObjectFloat(WATCHER_RADIUS);
            double _rotation = rotation;
            if (spellStack == null) {
                spellStack = this.dataWatcher.getWatchableObjectItemStack(22);
                if (spellStack == null) {
                    return;
                }
            }
            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);
                    }
                }
            }
            if ((AMCore.config.FullGFX() && this.ticksExisted % 2 == 0) || this.ticksExisted % 8 == 0) {
                for (int i = 0; i < 4; ++i) {
                    _rotation = (rotation + (90 * i)) % 360;
                    double x = this.posX - Math.cos(3.141 / 180 * (_rotation)) * dist;
                    double z = this.posZ - Math.sin(3.141 / 180 * (_rotation)) * dist;
                    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.setParticleScale(0.15f);
                        effect.setRGBColorI(color);
                        effect.AddParticleController(new ParticleFloatUpward(effect, 0, 0.07f, 1, false));
                        if (AMCore.config.LowGFX()) {
                            effect.AddParticleController(new ParticleOrbitPoint(effect, posX, posY, posZ, 2, false).setIgnoreYCoordinate(true).SetOrbitSpeed(0.05f).SetTargetDistance(dist).setRotateDirection(true));
                        }
                    }
                }
            }
        }
    }
    this.moveEntity(0, this.dataWatcher.getWatchableObjectInt(WATCHER_GRAVITY) / 100.0f, 0);
    ticksToEffect--;
    if (spellStack == null) {
        if (!worldObj.isRemote) {
            this.setDead();
        }
        return;
    }
    if (dummycaster == null) {
        dummycaster = DummyEntityPlayer.fromEntityLiving(new EntityDummyCaster(worldObj));
    }
    if (ticksToEffect <= 0) {
        ticksToEffect = maxTicksToEffect;
        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));
        for (Entity e : possibleTargets) {
            if (e instanceof EntityDragonPart && ((EntityDragonPart) e).entityDragonObj instanceof EntityLivingBase)
                e = (EntityLivingBase) ((EntityDragonPart) e).entityDragonObj;
            if (e instanceof EntityLivingBase)
                SpellHelper.instance.applyStageToEntity(spellStack, dummycaster, worldObj, e, 0, false);
        }
        if (this.dataWatcher.getWatchableObjectInt(WATCHER_GRAVITY) < 0 && !firstApply)
            SpellHelper.instance.applyStackStage(spellStack, dummycaster, null, posX, posY - 1, posZ, 0, worldObj, false, false, this.ticksExisted);
        else
            SpellHelper.instance.applyStackStage(spellStack, dummycaster, null, posX, posY, posZ, 0, worldObj, false, false, this.ticksExisted);
        firstApply = false;
    }
}
Also used : Entity(net.minecraft.entity.Entity) ISpellModifier(am2.api.spell.component.interfaces.ISpellModifier) Colour(am2.spell.modifiers.Colour) EntityDragonPart(net.minecraft.entity.boss.EntityDragonPart) EntityLivingBase(net.minecraft.entity.EntityLivingBase)

Example 29 with ParticleFloatUpward

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

the class TileEntityInscriptionTable method candleUpdate.

private void candleUpdate() {
    ticksToNextParticle--;
    if (isRenderingLeft()) {
        if (ticksToNextParticle == 0 || ticksToNextParticle == 15) {
            int meta = worldObj.getBlockMetadata(xCoord, yCoord, zCoord) & ~0x8;
            double particleX = 0;
            double particleZ = 0;
            switch(meta) {
                case 1:
                    particleX = this.xCoord + 0.15;
                    particleZ = this.zCoord + 0.22;
                    break;
                case 2:
                    particleX = this.xCoord + 0.22;
                    particleZ = this.zCoord + 0.85;
                    break;
                case 3:
                    particleX = this.xCoord + 0.83;
                    particleZ = this.zCoord + 0.78;
                    break;
                case 4:
                    particleX = this.xCoord + 0.79;
                    particleZ = this.zCoord + 0.15;
                    break;
            }
            ticksToNextParticle = 30;
            AMParticle effect = (AMParticle) AMCore.proxy.particleManager.spawn(worldObj, "fire", particleX, yCoord + 1.32, particleZ);
            if (effect != null) {
                effect.setParticleScale(0.025f, 0.1f, 0.025f);
                effect.AddParticleController(new ParticleHoldPosition(effect, 29, 1, false));
                effect.setIgnoreMaxAge(false);
                effect.setMaxAge(400);
            }
            if (worldObj.rand.nextInt(100) > 80) {
                AMParticle smoke = (AMParticle) AMCore.proxy.particleManager.spawn(worldObj, "smoke", particleX, yCoord + 1.4, particleZ);
                if (smoke != null) {
                    smoke.setParticleScale(0.025f);
                    smoke.AddParticleController(new ParticleFloatUpward(smoke, 0.01f, 0.01f, 1, false));
                    smoke.setIgnoreMaxAge(false);
                    smoke.setMaxAge(20 + worldObj.rand.nextInt(10));
                }
            }
        }
        if (ticksToNextParticle == 10 || ticksToNextParticle == 25) {
            int meta = worldObj.getBlockMetadata(xCoord, yCoord, zCoord) & ~0x8;
            double particleX = 0;
            double particleZ = 0;
            switch(meta) {
                case 1:
                    particleX = this.xCoord + 0.59;
                    particleZ = this.zCoord - 0.72;
                    break;
                case 2:
                    particleX = this.xCoord - 0.72;
                    particleZ = this.zCoord + 0.41;
                    break;
                case 3:
                    particleX = this.xCoord + 0.41;
                    particleZ = this.zCoord + 1.72;
                    break;
                case 4:
                    particleX = this.xCoord + 1.72;
                    particleZ = this.zCoord + 0.60;
                    break;
            }
            AMParticle effect = (AMParticle) AMCore.proxy.particleManager.spawn(worldObj, "fire", particleX, yCoord + 1.26, particleZ);
            if (effect != null) {
                effect.setParticleScale(0.025f, 0.1f, 0.025f);
                effect.AddParticleController(new ParticleHoldPosition(effect, 29, 1, false));
                effect.setIgnoreMaxAge(false);
                effect.setMaxAge(400);
            }
            if (worldObj.rand.nextInt(100) > 80) {
                AMParticle smoke = (AMParticle) AMCore.proxy.particleManager.spawn(worldObj, "smoke", particleX, yCoord + 1.4, particleZ);
                if (smoke != null) {
                    smoke.setParticleScale(0.025f);
                    smoke.AddParticleController(new ParticleFloatUpward(smoke, 0.01f, 0.01f, 1, false));
                    smoke.setIgnoreMaxAge(false);
                    smoke.setMaxAge(20 + worldObj.rand.nextInt(10));
                }
            }
        }
    }
}
Also used : AMParticle(am2.particles.AMParticle) ParticleHoldPosition(am2.particles.ParticleHoldPosition) ParticleFloatUpward(am2.particles.ParticleFloatUpward)

Example 30 with ParticleFloatUpward

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

the class TileEntitySlipstreamGenerator method spawnParticles.

private void spawnParticles(EntityPlayer player) {
    AMParticle wind = (AMParticle) AMCore.proxy.particleManager.spawn(worldObj, "wind", player.posX, player.posY - player.height, player.posZ);
    float pitch = player.rotationPitch;
    float factor = (pitch > 0 ? (pitch - 10) : (pitch + 10)) / -180.0f;
    if (player.isSneaking())
        factor = 0.01f;
    if (wind != null) {
        wind.setMaxAge(10);
        wind.addRandomOffset(1, 1, 1);
        wind.setParticleScale(0.1f);
        wind.AddParticleController(new ParticleFloatUpward(wind, 0, Math.abs(factor) * 2, 1, false));
    }
}
Also used : AMParticle(am2.particles.AMParticle) ParticleFloatUpward(am2.particles.ParticleFloatUpward)

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