Search in sources :

Example 6 with ParticleArcToEntity

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

the class EntityManaVortex method onUpdate.

@Override
public void onUpdate() {
    this.ticksExisted++;
    this.rotation += 5;
    if (!this.worldObj.isRemote && (this.isDead || this.ticksExisted >= getTicksToExist())) {
        this.setDead();
        return;
    }
    if (this.getTicksToExist() - this.ticksExisted <= 20) {
        this.scale -= 1f / 20f;
    } else if (this.scale < 0.99f) {
        this.scale = (float) (Math.sin((float) this.ticksExisted / 50));
    }
    if (getTicksToExist() - this.ticksExisted <= 5 && !hasGoneBoom) {
        hasGoneBoom = true;
        if (!worldObj.isRemote) {
            List players = worldObj.getEntitiesWithinAABB(EntityLivingBase.class, this.boundingBox.expand(3 + Math.floor(this.ticksExisted / 50), 2, 3 + Math.floor(this.ticksExisted / 50)));
            float damage = this.dataWatcher.getWatchableObjectFloat(DW_MANA_STOLEN) * 0.005f;
            if (damage > 100)
                damage = 100;
            Object[] playerArray = players.toArray();
            for (Object o : playerArray) {
                EntityLivingBase e = (EntityLivingBase) o;
                MovingObjectPosition mop = this.worldObj.rayTraceBlocks(Vec3.createVectorHelper(this.posX, this.posY, this.posZ), Vec3.createVectorHelper(e.posX, e.posY + e.getEyeHeight(), e.posZ), false);
                if (mop == null)
                    e.attackEntityFrom(DamageSources.causeEntityPhysicalDamage(this), damage);
            }
        } else {
            for (int i = 0; i < 360; i += AMCore.config.FullGFX() ? 5 : AMCore.config.LowGFX() ? 10 : 20) {
                AMParticle effect = (AMParticle) AMCore.instance.proxy.particleManager.spawn(worldObj, "ember", this.posX, this.posY, this.posZ);
                if (effect != null) {
                    effect.setIgnoreMaxAge(true);
                    effect.AddParticleController(new ParticleMoveOnHeading(effect, i, 0, 0.7f, 1, false));
                    effect.setRGBColorF(0.24f, 0.24f, 0.8f);
                    effect.noClip = false;
                    effect.AddParticleController(new ParticleFadeOut(effect, 1, false).setFadeSpeed(0.05f).setKillParticleOnFinish(true));
                    effect.AddParticleController(new ParticleLeaveParticleTrail(effect, "ember", false, 5, 1, false).addControllerToParticleList(new ParticleMoveOnHeading(effect, i, 0, 0.1f, 1, false)).addControllerToParticleList(new ParticleFadeOut(effect, 1, false).setFadeSpeed(0.1f).setKillParticleOnFinish(true)).setParticleRGB_F(0.24f, 0.24f, 0.8f).addRandomOffset(0.2f, 0.2f, 0.2f));
                }
            }
        }
    }
    if (getTicksToExist() - this.ticksExisted > 30) {
        //get all players within 5 blocks
        List<EntityLivingBase> players = worldObj.getEntitiesWithinAABB(EntityLivingBase.class, this.boundingBox.expand(3 + Math.floor(this.ticksExisted / 50), 2, 3 + Math.floor(this.ticksExisted / 50)));
        Object[] playerArray = players.toArray();
        Vec3 thisPos = Vec3.createVectorHelper(this.posX, this.posY, this.posZ);
        for (Object o : playerArray) {
            EntityLivingBase e = (EntityLivingBase) o;
            MovingObjectPosition mop = this.worldObj.rayTraceBlocks(Vec3.createVectorHelper(this.posX, this.posY, this.posZ), Vec3.createVectorHelper(e.posX, e.posY + e.getEyeHeight(), e.posZ), false);
            if (mop != null)
                continue;
            Vec3 playerPos = Vec3.createVectorHelper(e.posX, e.posY + e.getEyeHeight(), e.posZ);
            if (worldObj.isRemote) {
                if (AMCore.config.NoGFX()) {
                    break;
                }
                if (AMCore.config.LowGFX() && (this.ticksExisted % 4) != 0) {
                    break;
                }
                AMParticle effect = (AMParticle) AMCore.instance.proxy.particleManager.spawn(worldObj, "ember", e.posX, e.posY + (e.getEyeHeight() / 2), e.posZ);
                if (effect != null) {
                    effect.AddParticleController(new ParticleArcToEntity(effect, 1, this, false).generateControlPoints().setKillParticleOnFinish(true));
                    effect.setRGBColorF(0.24f, 0.24f, 0.8f);
                    effect.setIgnoreMaxAge(true);
                }
            }
            float manaStolen = ExtendedProperties.For(e).getMaxMana() * 0.01f;
            float curMana = ExtendedProperties.For(e).getCurrentMana();
            if (manaStolen > curMana)
                manaStolen = curMana;
            this.dataWatcher.updateObject(DW_MANA_STOLEN, this.dataWatcher.getWatchableObjectFloat(DW_MANA_STOLEN) + manaStolen);
            ExtendedProperties.For(e).setCurrentMana(ExtendedProperties.For(e).getCurrentMana() - manaStolen);
            AMVector3 movement = MathUtilities.GetMovementVectorBetweenEntities(e, this);
            float speed = -0.075f;
            e.addVelocity(movement.x * speed, movement.y * speed, movement.z * speed);
        }
    }
}
Also used : AMVector3(am2.api.math.AMVector3) MovingObjectPosition(net.minecraft.util.MovingObjectPosition) Vec3(net.minecraft.util.Vec3) EntityLivingBase(net.minecraft.entity.EntityLivingBase) List(java.util.List)

Aggregations

AMParticle (am2.particles.AMParticle)3 ParticleArcToEntity (am2.particles.ParticleArcToEntity)3 AMVector3 (am2.api.math.AMVector3)2 ExtendedProperties (am2.playerextensions.ExtendedProperties)1 SideOnly (cpw.mods.fml.relauncher.SideOnly)1 List (java.util.List)1 EntityLivingBase (net.minecraft.entity.EntityLivingBase)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 MovingObjectPosition (net.minecraft.util.MovingObjectPosition)1 Vec3 (net.minecraft.util.Vec3)1