Search in sources :

Example 1 with NormalDamageSource

use of omtteam.openmodularturrets.entity.projectiles.damagesources.NormalDamageSource in project OpenModularTurrets by OpenModularTurretsTeam.

the class LaserProjectile method onHitEntity.

@Override
public void onHitEntity(Entity entity) {
    if (entity != null && !getEntityWorld().isRemote) {
        int damage = ConfigHandler.getLaserTurretSettings().getDamage();
        if (isAmped) {
            if (entity instanceof EntityLivingBase) {
                EntityLivingBase elb = (EntityLivingBase) entity;
                damage += ((int) elb.getHealth() * (getDamageAmpBonus() * amp_level));
            }
        }
        if (entity instanceof EntityPlayer) {
            if (canDamagePlayer((EntityPlayer) entity)) {
                entity.setFire(2);
                entity.attackEntityFrom(new NormalDamageSource("laser"), damage);
                entity.hurtResistantTime = 0;
            } else {
                return;
            }
        } else {
            entity.setFire(2);
            entity.attackEntityFrom(new NormalDamageSource("laser"), damage);
            entity.hurtResistantTime = 0;
            setMobDropLoot(entity);
        }
        this.setDead();
    }
}
Also used : EntityLivingBase(net.minecraft.entity.EntityLivingBase) NormalDamageSource(omtteam.openmodularturrets.entity.projectiles.damagesources.NormalDamageSource) EntityPlayer(net.minecraft.entity.player.EntityPlayer)

Example 2 with NormalDamageSource

use of omtteam.openmodularturrets.entity.projectiles.damagesources.NormalDamageSource in project OpenModularTurrets by OpenModularTurretsTeam.

the class RocketProjectile method onHitBlock.

@Override
@ParametersAreNonnullByDefault
public void onHitBlock(IBlockState hitBlock, BlockPos pos) {
    if (hitBlock.getBlock() instanceof BlockAbstractTurretHead) {
        return;
    }
    if (!hitBlock.getMaterial().isSolid()) {
        // Go through non solid block
        return;
    }
    if (!getEntityWorld().isRemote) {
        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 (Entity mob : targets) {
            int damage = ConfigHandler.getRocketTurretSettings().getDamage();
            if (isAmped) {
                if (mob instanceof EntityLivingBase) {
                    EntityLivingBase elb = (EntityLivingBase) mob;
                    damage += ((int) elb.getHealth() * (0.08F * 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;
            }
        }
    }
    this.setDead();
}
Also used : BlockAbstractTurretHead(omtteam.openmodularturrets.blocks.turretheads.BlockAbstractTurretHead) AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) Entity(net.minecraft.entity.Entity) EntityDragon(net.minecraft.entity.boss.EntityDragon) EntityLivingBase(net.minecraft.entity.EntityLivingBase) NormalDamageSource(omtteam.openmodularturrets.entity.projectiles.damagesources.NormalDamageSource) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ParametersAreNonnullByDefault(javax.annotation.ParametersAreNonnullByDefault)

Example 3 with NormalDamageSource

use of omtteam.openmodularturrets.entity.projectiles.damagesources.NormalDamageSource 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)

Example 4 with NormalDamageSource

use of omtteam.openmodularturrets.entity.projectiles.damagesources.NormalDamageSource in project OpenModularTurrets by OpenModularTurretsTeam.

the class BlazingClayProjectile method onHitEntity.

@Override
public void onHitEntity(Entity entity) {
    if (!getEntityWorld().isRemote && !(entity instanceof EntityPlayer && !canDamagePlayer((EntityPlayer) entity))) {
        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);
        int damage = ConfigHandler.getIncendiaryTurretSettings().getDamage();
        if (isAmped) {
            if (entity instanceof EntityLivingBase) {
                EntityLivingBase elb = (EntityLivingBase) entity;
                damage += ((int) elb.getHealth() * (getDamageAmpBonus() * amp_level));
            }
        }
        for (EntityLivingBase mob : targets) {
            setMobDropLoot(mob);
            if (mob instanceof EntityPlayer) {
                if (canDamagePlayer((EntityPlayer) mob)) {
                    mob.attackEntityFrom(new NormalDamageSource("bullet"), damage);
                    mob.hurtResistantTime = 0;
                    mob.setFire(5);
                }
            } else {
                mob.attackEntityFrom(new NormalDamageSource("bullet"), damage);
                mob.hurtResistantTime = 0;
                mob.setFire(5);
            }
            setMobDropLoot(entity);
        }
        this.setDead();
    }
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) EntityLivingBase(net.minecraft.entity.EntityLivingBase) NormalDamageSource(omtteam.openmodularturrets.entity.projectiles.damagesources.NormalDamageSource) EntityPlayer(net.minecraft.entity.player.EntityPlayer)

Example 5 with NormalDamageSource

use of omtteam.openmodularturrets.entity.projectiles.damagesources.NormalDamageSource in project OpenModularTurrets by OpenModularTurretsTeam.

the class BlazingClayProjectile method onHitBlock.

@Override
@ParametersAreNonnullByDefault
public void onHitBlock(IBlockState hitBlock, BlockPos pos) {
    if (hitBlock.getBlock() instanceof BlockAbstractTurretHead) {
        return;
    }
    if (!hitBlock.getMaterial().isSolid()) {
        // Go through non solid block
        return;
    }
    if (!getEntityWorld().isRemote) {
        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);
        int damage = ConfigHandler.getIncendiaryTurretSettings().getDamage();
        for (Entity mob : targets) {
            if (mob instanceof EntityPlayer) {
                if (canDamagePlayer((EntityPlayer) mob)) {
                    mob.attackEntityFrom(new NormalDamageSource("bullet"), damage);
                    mob.hurtResistantTime = 0;
                    mob.setFire(5);
                    playSound();
                }
            } else {
                mob.attackEntityFrom(new NormalDamageSource("bullet"), damage);
                mob.hurtResistantTime = 0;
                mob.setFire(5);
                playSound();
            }
        }
        this.setDead();
    }
}
Also used : BlockAbstractTurretHead(omtteam.openmodularturrets.blocks.turretheads.BlockAbstractTurretHead) AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) Entity(net.minecraft.entity.Entity) EntityLivingBase(net.minecraft.entity.EntityLivingBase) NormalDamageSource(omtteam.openmodularturrets.entity.projectiles.damagesources.NormalDamageSource) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ParametersAreNonnullByDefault(javax.annotation.ParametersAreNonnullByDefault)

Aggregations

EntityLivingBase (net.minecraft.entity.EntityLivingBase)8 EntityPlayer (net.minecraft.entity.player.EntityPlayer)8 NormalDamageSource (omtteam.openmodularturrets.entity.projectiles.damagesources.NormalDamageSource)8 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)5 ParametersAreNonnullByDefault (javax.annotation.ParametersAreNonnullByDefault)2 Entity (net.minecraft.entity.Entity)2 EntityDragon (net.minecraft.entity.boss.EntityDragon)2 BlockAbstractTurretHead (omtteam.openmodularturrets.blocks.turretheads.BlockAbstractTurretHead)2 ArmorBypassDamageSource (omtteam.openmodularturrets.entity.projectiles.damagesources.ArmorBypassDamageSource)1