Search in sources :

Example 6 with EntityDragon

use of net.minecraft.entity.boss.EntityDragon in project OpenModularTurrets by OpenModularTurretsTeam.

the class RocketProjectile method onHitEntity.

@Override
public void onHitEntity(Entity entity) {
    if (!getEntityWorld().isRemote && !(entity instanceof EntityPlayer && !canDamagePlayer((EntityPlayer) entity))) {
        float strength = ConfigHandler.canRocketsDestroyBlocks ? 2.3F : 0.1F;
        getEntityWorld().createExplosion(null, posX, posY, posZ, strength, true);
        AxisAlignedBB axis = new AxisAlignedBB(this.posX - 5, this.posY - 5, this.posZ - 5, this.posX + 5, this.posY + 5, this.posZ + 5);
        List<EntityLivingBase> targets = getEntityWorld().getEntitiesWithinAABB(EntityLivingBase.class, axis);
        for (EntityLivingBase mob : targets) {
            int damage = ConfigHandler.getRocketTurretSettings().getDamage();
            if (isAmped) {
                EntityLivingBase elb = (EntityLivingBase) mob;
                damage += ((int) elb.getHealth() * (getDamageAmpBonus() * amp_level));
            }
            if (mob instanceof EntityPlayer) {
                if (canDamagePlayer((EntityPlayer) mob)) {
                    mob.attackEntityFrom(new NormalDamageSource("rocket"), damage);
                    mob.hurtResistantTime = 0;
                }
            }
            if (ConfigHandler.isCanRocketsHurtEnderDragon() && mob instanceof EntityDragon) {
                ((EntityDragon) mob).setHealth(((EntityDragon) mob).getHealth() - damage);
                mob.hurtResistantTime = 0;
            } else {
                mob.attackEntityFrom(new NormalDamageSource("rocket"), damage);
                mob.hurtResistantTime = 0;
            }
            setMobDropLoot(mob);
        }
        this.setDead();
    }
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) EntityDragon(net.minecraft.entity.boss.EntityDragon) EntityLivingBase(net.minecraft.entity.EntityLivingBase) NormalDamageSource(omtteam.openmodularturrets.entity.projectiles.damagesources.NormalDamageSource) EntityPlayer(net.minecraft.entity.player.EntityPlayer)

Aggregations

EntityDragon (net.minecraft.entity.boss.EntityDragon)6 EntityLivingBase (net.minecraft.entity.EntityLivingBase)4 EntityPlayer (net.minecraft.entity.player.EntityPlayer)4 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)2 NormalDamageSource (omtteam.openmodularturrets.entity.projectiles.damagesources.NormalDamageSource)2 EntityDarkMage (am2.entities.EntityDarkMage)1 EntityLightMage (am2.entities.EntityLightMage)1 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)1 Random (java.util.Random)1 ParametersAreNonnullByDefault (javax.annotation.ParametersAreNonnullByDefault)1 DimensionInformation (mcjty.rftoolsdim.dimensions.DimensionInformation)1 RfToolsDimensionManager (mcjty.rftoolsdim.dimensions.RfToolsDimensionManager)1 Entity (net.minecraft.entity.Entity)1 EntityWither (net.minecraft.entity.boss.EntityWither)1 EntityLightningBolt (net.minecraft.entity.effect.EntityLightningBolt)1 EntityEnderCrystal (net.minecraft.entity.item.EntityEnderCrystal)1 EntityCreeper (net.minecraft.entity.monster.EntityCreeper)1 EntityEnderman (net.minecraft.entity.monster.EntityEnderman)1 EntityHorse (net.minecraft.entity.passive.EntityHorse)1 EntitySheep (net.minecraft.entity.passive.EntitySheep)1