Search in sources :

Example 1 with BuffEffectFrostSlowed

use of am2.buffs.BuffEffectFrostSlowed in project ArsMagica2 by Mithion.

the class EntitySpellEffect method blizzardUpdate.

private void blizzardUpdate() {
    float radius = this.dataWatcher.getWatchableObjectFloat(WATCHER_RADIUS);
    if (worldObj.isRemote) {
        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);
                }
            }
        }
        for (int i = 0; i < 20; ++i) {
            double x = this.posX - radius + (rand.nextDouble() * radius * 2);
            double z = this.posZ - radius + (rand.nextDouble() * radius * 2);
            double y = this.posY + 10;
            AMParticle particle = (AMParticle) AMCore.proxy.particleManager.spawn(worldObj, "snowflakes", x, y, z);
            if (particle != null) {
                particle.setMaxAge(20);
                particle.setParticleScale(0.1f);
                particle.addVelocity(rand.nextDouble() * 0.2f - 0.1f, 0, rand.nextDouble() * 0.2f - 0.1f);
                particle.setAffectedByGravity();
                particle.setRGBColorI(color);
                particle.setDontRequireControllers();
                particle.noClip = false;
            }
        }
        double x = this.posX - radius + (rand.nextDouble() * radius * 2);
        double z = this.posZ - radius + (rand.nextDouble() * radius * 2);
        double y = this.posY + rand.nextDouble();
        AMParticle particle = (AMParticle) AMCore.proxy.particleManager.spawn(worldObj, "smoke", x, y, z);
        if (particle != null) {
            particle.setParticleScale(2.0f);
            particle.setMaxAge(20);
            //particle.setRGBColorF(0.5f, 0.92f, 0.92f);
            particle.setRGBColorF(0.5098f, 0.7843f, 0.7843f);
            particle.SetParticleAlpha(0.6f);
            particle.AddParticleController(new ParticleFleePoint(particle, new AMVector3(x, y, z), 0.1f, 3f, 1, false));
        }
    //TODO: SoundHelper.instance.loopSound(worldObj, (float)posX, (float)posY, (float)posZ, "arsmagica2:spell.loop.air", 1.0f);
    } else {
        List<Entity> possibleTargets = worldObj.getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.getBoundingBox(posX - radius, posY - 1, posZ - radius, posX + radius, posY + 3, posZ + radius));
        for (Entity e : possibleTargets) {
            if (e != dummycaster) {
                if (e instanceof EntityDragonPart && ((EntityDragonPart) e).entityDragonObj instanceof EntityLivingBase)
                    e = (EntityLivingBase) ((EntityDragonPart) e).entityDragonObj;
                if (e instanceof EntityLivingBase)
                    ((EntityLivingBase) e).addPotionEffect(new BuffEffectFrostSlowed(80, 3));
                float damage = 1 * this.dataWatcher.getWatchableObjectFloat(WATCHER_DAMAGEBONUS);
                double lastVelX = e.motionX;
                double lastVelY = e.motionY;
                double lastVelZ = e.motionZ;
                if (SpellHelper.instance.attackTargetSpecial(null, e, DamageSources.causeEntityFrostDamage(dummycaster), damage) && !(e instanceof EntityPlayer))
                    e.hurtResistantTime = 15;
                e.addVelocity(-(e.motionX - lastVelX), -(e.motionY - lastVelY), -(e.motionZ - lastVelZ));
            }
        }
        if (rand.nextInt(10) < 2) {
            int pX = (int) (posX - radius + rand.nextInt((int) Math.ceil(radius) * 2));
            int pY = (int) posY + rand.nextInt(2);
            int pZ = (int) (posZ - radius + rand.nextInt((int) Math.ceil(radius) * 2));
            if (worldObj.isAirBlock(pX, pY, pZ) && !worldObj.isAirBlock(pX, pY - 1, pZ) && worldObj.getBlock(pX, pY, pZ).isOpaqueCube())
                worldObj.setBlock(pX, pY, pZ, Blocks.snow);
        }
    }
}
Also used : 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) BuffEffectFrostSlowed(am2.buffs.BuffEffectFrostSlowed) EntityLivingBase(net.minecraft.entity.EntityLivingBase) DummyEntityPlayer(am2.utility.DummyEntityPlayer) EntityPlayer(net.minecraft.entity.player.EntityPlayer)

Example 2 with BuffEffectFrostSlowed

use of am2.buffs.BuffEffectFrostSlowed in project ArsMagica2 by Mithion.

the class AffinityHelper method onEntityHurt.

@SubscribeEvent
public void onEntityHurt(LivingHurtEvent event) {
    EntityLivingBase ent = event.entityLiving;
    AffinityData affinityData = AffinityData.For(ent);
    if (event.source.getSourceOfDamage() instanceof EntityPlayer) {
        float attackerFireDepth = AffinityData.For((EntityLivingBase) event.source.getSourceOfDamage()).getAffinityDepth(Affinity.FIRE);
        if (attackerFireDepth > 0.8f && ((EntityPlayer) event.source.getSourceOfDamage()).getCurrentEquippedItem() == null) {
            ent.setFire(4);
            event.ammount += 3;
        }
        float attackerLightningDepth = AffinityData.For((EntityLivingBase) event.source.getSourceOfDamage()).getAffinityDepth(Affinity.LIGHTNING);
        if (attackerLightningDepth > 0.75f && !ent.worldObj.isRemote && ((EntityPlayer) event.source.getSourceOfDamage()).getCurrentEquippedItem() == null) {
            EntityLightningBolt elb = new EntityLightningBolt(ent.worldObj, ent.posX, ent.posY, ent.posZ);
            elb.setPosition(ent.posX, ent.posY, ent.posZ);
            ent.worldObj.addWeatherEffect(elb);
        }
    }
    if (!(ent instanceof EntityPlayer))
        return;
    float earthDepth = affinityData.getAffinityDepth(Affinity.EARTH);
    if (earthDepth > 0.25f) {
        float reduction = 0.1f * earthDepth;
        event.ammount -= event.ammount * reduction;
    }
    float arcaneDepth = affinityData.getAffinityDepth(Affinity.ARCANE);
    if (arcaneDepth > 0.25f) {
        event.ammount *= 1.1f;
    }
    float waterDepth = affinityData.getAffinityDepth(Affinity.WATER);
    if (waterDepth > 0.9f && event.source.getSourceOfDamage() instanceof EntityEnderman) {
        event.source.getSourceOfDamage().attackEntityFrom(DamageSource.drown, 2);
    }
    float fireDepth = affinityData.getAffinityDepth(Affinity.FIRE);
    if (event.source.isFireDamage()) {
        float reduction = 1 - (0.6f * fireDepth);
        event.ammount = event.ammount * reduction;
    }
    float enderDepth = affinityData.getAffinityDepth(Affinity.ENDER);
    if (event.source == DamageSource.magic || event.source == DamageSource.wither) {
        float reduction = 1 - (0.75f * enderDepth);
        event.ammount = event.ammount * reduction;
    }
    if (event.source.getSourceOfDamage() instanceof EntityLivingBase) {
        float natureDepth = affinityData.getAffinityDepth(Affinity.NATURE);
        if (natureDepth == 1.0f) {
            ((EntityLivingBase) event.source.getSourceOfDamage()).attackEntityFrom(DamageSource.cactus, 3);
        } else if (natureDepth >= 0.75f) {
            ((EntityLivingBase) event.source.getSourceOfDamage()).attackEntityFrom(DamageSource.cactus, 2);
        } else if (natureDepth >= 0.5f) {
            ((EntityLivingBase) event.source.getSourceOfDamage()).attackEntityFrom(DamageSource.cactus, 1);
        }
        float iceDepth = affinityData.getAffinityDepth(Affinity.ICE);
        BuffEffectFrostSlowed effect = null;
        if (iceDepth == 1.0f) {
            effect = new BuffEffectFrostSlowed(200, 2);
        } else if (iceDepth >= 0.75f) {
            effect = new BuffEffectFrostSlowed(160, 1);
        } else if (iceDepth >= 0.5f) {
            effect = new BuffEffectFrostSlowed(100, 0);
        }
        if (effect != null) {
            ((EntityLivingBase) event.source.getSourceOfDamage()).addPotionEffect(effect);
        }
    }
    if (event.ammount == 0)
        event.setCanceled(true);
}
Also used : EntityLivingBase(net.minecraft.entity.EntityLivingBase) AffinityData(am2.playerextensions.AffinityData) EntityPlayer(net.minecraft.entity.player.EntityPlayer) EntityLightningBolt(net.minecraft.entity.effect.EntityLightningBolt) EntityEnderman(net.minecraft.entity.monster.EntityEnderman) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 3 with BuffEffectFrostSlowed

use of am2.buffs.BuffEffectFrostSlowed in project ArsMagica2 by Mithion.

the class EntityWinterGuardian method onUpdate.

@Override
public void onUpdate() {
    if (worldObj.getBiomeGenForCoords((int) posX, (int) posZ).getEnableSnow() && worldObj.getWorldInfo().isRaining()) {
        if (worldObj.isRemote) {
            AMParticle particle = (AMParticle) AMCore.proxy.particleManager.spawn(worldObj, "ember", posX + (rand.nextFloat() * 6 - 3), posY + 2 + (rand.nextFloat() * 2 - 1), posZ + (rand.nextFloat() * 6 - 3));
            if (particle != null) {
                particle.AddParticleController(new ParticleApproachEntity(particle, this, 0.15f, 0.1, 1, false));
                particle.setIgnoreMaxAge(false);
                particle.setMaxAge(30);
                particle.setParticleScale(0.35f);
                particle.setRGBColorF(0.7843f, 0.5098f, 0.5098f);
            }
        } else {
            this.heal(0.1f);
        }
    }
    if (worldObj.isRemote) {
        updateRotations();
        spawnParticles();
    } else {
        if (this.ticksExisted % 100 == 0) {
            List<EntityLivingBase> entities = worldObj.getEntitiesWithinAABB(EntityLivingBase.class, this.boundingBox.expand(2, 2, 2));
            for (EntityLivingBase entity : entities) {
                if (entity == this)
                    continue;
                entity.addPotionEffect(new BuffEffectFrostSlowed(220, 1));
                entity.addPotionEffect(new PotionEffect(Potion.digSlowdown.id, 220, 3));
            }
        }
    }
    super.onUpdate();
}
Also used : BuffEffectFrostSlowed(am2.buffs.BuffEffectFrostSlowed) PotionEffect(net.minecraft.potion.PotionEffect) EntityLivingBase(net.minecraft.entity.EntityLivingBase)

Example 4 with BuffEffectFrostSlowed

use of am2.buffs.BuffEffectFrostSlowed in project ArsMagica2 by Mithion.

the class EntityWinterGuardianArm method HitObject.

protected void HitObject(MovingObjectPosition movingobjectposition) {
    if (movingobjectposition.entityHit != null && movingobjectposition.entityHit instanceof EntityLivingBase) {
        if (movingobjectposition.entityHit == getThrowingEntity() || getThrowingEntity() == null)
            return;
        if (getThrowingEntity() != null && this.entityHit == null) {
            movingobjectposition.entityHit.attackEntityFrom(DamageSource.causeMobDamage(getThrowingEntity()), 3);
            this.entityHit = movingobjectposition.entityHit.getEntityId();
            this.ticksExisted = 80;
            if (movingobjectposition.entityHit instanceof EntityLivingBase) {
                ExtendedProperties.For((EntityLivingBase) movingobjectposition.entityHit).deductMana(ExtendedProperties.For((EntityLivingBase) movingobjectposition.entityHit).getMaxMana() * 0.1f);
                ((EntityLivingBase) movingobjectposition.entityHit).addPotionEffect(new PotionEffect(Potion.weakness.id, 60, 2));
                ((EntityLivingBase) movingobjectposition.entityHit).addPotionEffect(new PotionEffect(Potion.digSlowdown.id, 60, 2));
                ((EntityLivingBase) movingobjectposition.entityHit).addPotionEffect(new BuffEffectFrostSlowed(60, 2));
            }
        }
    }
}
Also used : BuffEffectFrostSlowed(am2.buffs.BuffEffectFrostSlowed) PotionEffect(net.minecraft.potion.PotionEffect) EntityLivingBase(net.minecraft.entity.EntityLivingBase)

Example 5 with BuffEffectFrostSlowed

use of am2.buffs.BuffEffectFrostSlowed in project ArsMagica2 by Mithion.

the class ItemWinterGuardianArm method onLeftClickEntity.

@Override
public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) {
    if (entity instanceof EntityLivingBase) {
        ((EntityLivingBase) entity).addPotionEffect(new BuffEffectFrostSlowed(60, 3));
        if (player.worldObj.isRemote) {
            for (int i = 0; i < 5; ++i) {
                AMParticle particle = (AMParticle) AMCore.proxy.particleManager.spawn(player.worldObj, "snowflakes", entity.posX + 0.5, entity.posY + 0.5, entity.posZ + 0.5);
                if (particle != null) {
                    particle.addRandomOffset(1, 0.5, 1);
                    particle.addVelocity(player.worldObj.rand.nextDouble() * 0.2 - 0.1, 0.3, player.worldObj.rand.nextDouble() * 0.2 - 0.1);
                    particle.setAffectedByGravity();
                    particle.setDontRequireControllers();
                    particle.setMaxAge(10);
                    particle.setParticleScale(0.1f);
                }
            }
        }
    }
    return super.onLeftClickEntity(stack, player, entity);
}
Also used : BuffEffectFrostSlowed(am2.buffs.BuffEffectFrostSlowed) AMParticle(am2.particles.AMParticle) EntityLivingBase(net.minecraft.entity.EntityLivingBase)

Aggregations

EntityLivingBase (net.minecraft.entity.EntityLivingBase)6 BuffEffectFrostSlowed (am2.buffs.BuffEffectFrostSlowed)5 EntityPlayer (net.minecraft.entity.player.EntityPlayer)2 PotionEffect (net.minecraft.potion.PotionEffect)2 AMVector3 (am2.api.math.AMVector3)1 ISpellModifier (am2.api.spell.component.interfaces.ISpellModifier)1 AMParticle (am2.particles.AMParticle)1 AffinityData (am2.playerextensions.AffinityData)1 Colour (am2.spell.modifiers.Colour)1 DummyEntityPlayer (am2.utility.DummyEntityPlayer)1 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)1 Entity (net.minecraft.entity.Entity)1 EntityDragonPart (net.minecraft.entity.boss.EntityDragonPart)1 EntityLightningBolt (net.minecraft.entity.effect.EntityLightningBolt)1 EntityEnderman (net.minecraft.entity.monster.EntityEnderman)1