Search in sources :

Example 1 with EntityEnderman

use of net.minecraft.entity.monster.EntityEnderman 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 2 with EntityEnderman

use of net.minecraft.entity.monster.EntityEnderman in project ArsMagica2 by Mithion.

the class AffinityHelper method onEntityLivingBase.

@SubscribeEvent
public void onEntityLivingBase(LivingUpdateEvent event) {
    EntityLivingBase ent = event.entityLiving;
    if (ent instanceof EntityEnderman) {
        if (ent.getLastAttacker() != ent.getAITarget() && ent.getAITarget() instanceof EntityPlayer) {
            AffinityData affinityData = AffinityData.For(ent.getAITarget());
            float enderDepth = affinityData.getAffinityDepth(Affinity.ENDER);
            if (enderDepth == 1.0f) {
                ent.setRevengeTarget(null);
            }
        }
    }
    if (!(ent instanceof EntityPlayer))
        return;
    AffinityData affinityData = AffinityData.For(ent);
    affinityData.tickDiminishingReturns();
    float waterDepth = affinityData.getAffinityDepth(Affinity.WATER);
    float fireDepth = affinityData.getAffinityDepth(Affinity.FIRE);
    float natureDepth = affinityData.getAffinityDepth(Affinity.NATURE);
    float iceDepth = affinityData.getAffinityDepth(Affinity.ICE);
    float lifeDepth = affinityData.getAffinityDepth(Affinity.LIFE);
    float enderDepth = affinityData.getAffinityDepth(Affinity.ENDER);
    float lightningDepth = affinityData.getAffinityDepth(Affinity.LIGHTNING);
    AffinityModifiers.instance.applySpeedModifiersBasedOnDepth((EntityPlayer) ent, natureDepth, iceDepth, lightningDepth);
    AffinityModifiers.instance.applyHealthModifiers((EntityPlayer) ent, enderDepth, waterDepth, fireDepth, lightningDepth);
    applyFulmintion((EntityPlayer) ent, lightningDepth);
    if (lightningDepth >= 0.5f) {
        ent.stepHeight = 1.014f;
    } else if (ent.stepHeight == 1.014f) {
        ent.stepHeight = 0.5f;
    }
    affinityData.accumulatedLifeRegen += 0.025 * lifeDepth;
    if (affinityData.accumulatedLifeRegen > 1.0f) {
        affinityData.accumulatedLifeRegen -= 1.0f;
        ent.heal(1);
    }
    if (natureDepth == 1.0f) {
        if (ent.worldObj.canBlockSeeTheSky((int) ent.posX, (int) ent.posY, (int) ent.posZ) && ent.worldObj.isDaytime()) {
            affinityData.accumulatedHungerRegen += 0.02f;
            if (affinityData.accumulatedHungerRegen > 1.0f) {
                ((EntityPlayer) ent).getFoodStats().addStats(1, 0.025f);
                affinityData.accumulatedHungerRegen -= 1;
            }
        } else {
            ((EntityPlayer) ent).addExhaustion(0.025f);
        }
        if (ent.isCollidedHorizontally) {
            if (!ent.isSneaking()) {
                float movement = ExtendedProperties.For(ent).getIsFlipped() ? -0.25f : 0.25f;
                ent.moveEntity(0, movement, 0);
                ent.motionY = 0;
            } else {
                ent.motionY *= 0.79999999;
            }
            ent.fallDistance = 0;
        }
    }
    //Ender Affinity
    if (enderDepth >= 0.75f && affinityData.hasActivatedNightVision()) {
        if (!ent.worldObj.isRemote && (!ent.isPotionActive(Potion.nightVision.id) || ent.getActivePotionEffect(Potion.nightVision).getDuration() <= 220)) {
            ent.addPotionEffect(new PotionEffect(Potion.nightVision.id, 300, 1));
        }
    }
    if (ent.onGround)
        affinityData.setLastGroundPosition(new AMVector3(ent));
    affinityData.tickCooldown();
    if (ent.isInWater()) {
        float earthDepth = affinityData.getAffinityDepth(Affinity.EARTH);
        if (earthDepth > 0.25f && ent.motionY > -0.3f) {
            ent.addVelocity(0, -0.01f * earthDepth, 0);
        }
        if (waterDepth > 0.5f) {
            if (!ent.isPotionActive(BuffList.swiftSwim.id) || ent.getActivePotionEffect(BuffList.swiftSwim).getDuration() < 10) {
                ent.addPotionEffect(new BuffEffectSwiftSwim(100, waterDepth > 0.75f ? 2 : 1));
            }
        }
        if (waterDepth > 0.4 && ent.worldObj.rand.nextInt(20) < 4)
            ent.setAir(ent.getAir() + 1);
        if (!ent.worldObj.isRemote && ent.worldObj.rand.nextInt(100) < 5) {
            ent.setAir(ent.getAir() + 1);
            byte[] data = new AMDataWriter().add(ent.getEntityId()).add(ent.getAir()).generate();
            AMNetHandler.INSTANCE.sendPacketToClientPlayer((EntityPlayerMP) ent, AMPacketIDs.SYNC_AIR_CHANGE, data);
        }
        boolean waterMovementFlag = false;
        if ((ent instanceof EntityPlayer && ((EntityPlayer) ent).inventory.armorInventory[1] != null && ((EntityPlayer) ent).inventory.armorInventory[1].getItem() == ItemsCommonProxy.waterGuardianOrbs)) {
            waterMovementFlag = true;
            if (!ent.worldObj.isRemote && (!ent.isPotionActive(BuffList.waterBreathing) || ent.getActivePotionEffect(BuffList.waterBreathing).getDuration() <= 200))
                ent.addPotionEffect(new BuffEffectWaterBreathing(400, 2));
        }
        if (waterDepth > 0.5f || waterMovementFlag) {
            applyReverseWaterMovement(ent);
        }
    }
    if (ent.worldObj.isRaining() && !ent.worldObj.isRemote && ent.worldObj.getBiomeGenForCoords((int) Math.floor(ent.posX), (int) Math.floor(ent.posZ)).canSpawnLightningBolt()) {
        float airDepth = affinityData.getAffinityDepth(Affinity.AIR);
        if (airDepth > 0.5f && airDepth < 0.85f && !ent.worldObj.isRemote && ent.worldObj.rand.nextInt(100) < 10) {
            if (!ent.isSneaking() && !ent.isPotionActive(BuffList.gravityWell) && !ent.isInsideOfMaterial(Material.water) && ent.isWet()) {
                double velX = ent.worldObj.rand.nextDouble() - 0.5;
                double velY = ent.worldObj.rand.nextDouble() - 0.5;
                double velZ = ent.worldObj.rand.nextDouble() - 0.5;
                ent.addVelocity(velX, velY, velZ);
                AMNetHandler.INSTANCE.sendVelocityAddPacket(ent.worldObj, ent, velX, velY, velZ);
            }
        }
    }
    if (ent.isSneaking()) {
        if (iceDepth >= 0.5f) {
            makeIceBridge((EntityPlayer) ent, iceDepth);
        }
    }
}
Also used : PotionEffect(net.minecraft.potion.PotionEffect) AffinityData(am2.playerextensions.AffinityData) AMDataWriter(am2.network.AMDataWriter) AMVector3(am2.api.math.AMVector3) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer) EntityEnderman(net.minecraft.entity.monster.EntityEnderman) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 3 with EntityEnderman

use of net.minecraft.entity.monster.EntityEnderman in project BluePower by Qmunity.

the class BPEventHandler method onEntityAttack.

@SubscribeEvent
public void onEntityAttack(LivingAttackEvent event) {
    if (!isAttacking && event.source instanceof EntityDamageSource) {
        // this event will be trigger recursively by EntityLiving#attackEntityFrom,
        // so we need to stop the loop.
        EntityDamageSource entitySource = (EntityDamageSource) event.source;
        if (entitySource.getEntity() instanceof EntityPlayer) {
            EntityPlayer killer = (EntityPlayer) entitySource.getEntity();
            if (killer.inventory.getCurrentItem() != null) {
                if (EnchantmentHelper.getEnchantments(killer.inventory.getCurrentItem()).containsKey(BPEnchantments.disjunction.effectId)) {
                    if (event.entityLiving instanceof EntityEnderman || event.entityLiving instanceof EntityDragon) {
                        int level = EnchantmentHelper.getEnchantmentLevel(BPEnchantments.disjunction.effectId, killer.inventory.getCurrentItem());
                        isAttacking = true;
                        event.entityLiving.attackEntityFrom(event.source, event.ammount * (level * 0.5F + 1));
                        isAttacking = false;
                        event.setCanceled(true);
                    }
                }
            }
        }
    }
}
Also used : EntityDragon(net.minecraft.entity.boss.EntityDragon) EntityPlayer(net.minecraft.entity.player.EntityPlayer) EntityEnderman(net.minecraft.entity.monster.EntityEnderman) EntityDamageSource(net.minecraft.util.EntityDamageSource) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 4 with EntityEnderman

use of net.minecraft.entity.monster.EntityEnderman in project ICBM-Classic by BuiltBrokenModding.

the class BlastEnderman method doPostExplode.

@Override
public void doPostExplode() {
    super.doPostExplode();
    if (!this.world().isRemote) {
        for (int i = 0; i < 8; i++) {
            EntityEnderman enderman = new EntityEnderman(world());
            enderman.setPosition(this.position.x(), this.position.y(), this.position.z());
            this.world().spawnEntityInWorld(enderman);
        }
    }
}
Also used : EntityEnderman(net.minecraft.entity.monster.EntityEnderman)

Example 5 with EntityEnderman

use of net.minecraft.entity.monster.EntityEnderman in project ArsMagica2 by Mithion.

the class AMEventHandler method onEndermanTeleport.

@SubscribeEvent
public void onEndermanTeleport(EnderTeleportEvent event) {
    EntityLivingBase ent = event.entityLiving;
    ArrayList<Long> keystoneKeys = KeystoneUtilities.instance.GetKeysInInvenory(ent);
    TileEntityAstralBarrier blockingBarrier = DimensionUtilities.GetBlockingAstralBarrier(event.entityLiving.worldObj, (int) event.targetX, (int) event.targetY, (int) event.targetZ, keystoneKeys);
    if (ent.isPotionActive(BuffList.astralDistortion.id) || blockingBarrier != null) {
        event.setCanceled(true);
        if (blockingBarrier != null) {
            blockingBarrier.onEntityBlocked(ent);
        }
        return;
    }
    if (!ent.worldObj.isRemote && ent instanceof EntityEnderman && ent.worldObj.rand.nextDouble() < 0.01f) {
        EntityFlicker flicker = new EntityFlicker(ent.worldObj);
        flicker.setPosition(ent.posX, ent.posY, ent.posZ);
        flicker.setFlickerType(Affinity.ENDER);
        ent.worldObj.spawnEntityInWorld(flicker);
    }
}
Also used : TileEntityAstralBarrier(am2.blocks.tileentities.TileEntityAstralBarrier) EntityFlicker(am2.entities.EntityFlicker) EntityEnderman(net.minecraft.entity.monster.EntityEnderman) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Aggregations

EntityEnderman (net.minecraft.entity.monster.EntityEnderman)7 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)5 EntityPlayer (net.minecraft.entity.player.EntityPlayer)5 AffinityData (am2.playerextensions.AffinityData)2 EntityLivingBase (net.minecraft.entity.EntityLivingBase)2 AMVector3 (am2.api.math.AMVector3)1 TileEntityAstralBarrier (am2.blocks.tileentities.TileEntityAstralBarrier)1 EntityDarkMage (am2.entities.EntityDarkMage)1 EntityFlicker (am2.entities.EntityFlicker)1 EntityLightMage (am2.entities.EntityLightMage)1 AMDataWriter (am2.network.AMDataWriter)1 EntityRegistration (cpw.mods.fml.common.registry.EntityRegistry.EntityRegistration)1 Iterator (java.util.Iterator)1 EntityAIArrowAttack (net.minecraft.entity.ai.EntityAIArrowAttack)1 EntityAIAttackOnCollide (net.minecraft.entity.ai.EntityAIAttackOnCollide)1 EntityAITaskEntry (net.minecraft.entity.ai.EntityAITasks.EntityAITaskEntry)1 EntityDragon (net.minecraft.entity.boss.EntityDragon)1 EntityLightningBolt (net.minecraft.entity.effect.EntityLightningBolt)1 EntityItem (net.minecraft.entity.item.EntityItem)1 EntityMob (net.minecraft.entity.monster.EntityMob)1