Search in sources :

Example 6 with NormalDamageSource

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

the class BulletProjectile method onHitEntity.

@Override
public void onHitEntity(Entity entity) {
    if (entity != null && !getEntityWorld().isRemote) {
        int damage = ConfigHandler.getGunTurretSettings().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.attackEntityFrom(new NormalDamageSource("bullet"), damage);
                entity.hurtResistantTime = 0;
                playSound();
            } else {
                return;
            }
        } else {
            entity.attackEntityFrom(new NormalDamageSource("bullet"), 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 7 with NormalDamageSource

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

the class DisposableTurretProjectile method onHitEntity.

@Override
public void onHitEntity(Entity entity) {
    if (entity != null && !getEntityWorld().isRemote) {
        int damage = ConfigHandler.getDisposableTurretSettings().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.attackEntityFrom(new NormalDamageSource("disposable"), damage);
                entity.hurtResistantTime = 0;
            } else {
                return;
            }
        } else {
            entity.attackEntityFrom(new NormalDamageSource("disposable"), damage);
            entity.hurtResistantTime = 0;
        }
        setMobDropLoot(entity);
        if (itemBound != null) {
            itemBound.setDead();
        }
        this.setDead();
    }
}
Also used : EntityLivingBase(net.minecraft.entity.EntityLivingBase) NormalDamageSource(omtteam.openmodularturrets.entity.projectiles.damagesources.NormalDamageSource) EntityPlayer(net.minecraft.entity.player.EntityPlayer)

Example 8 with NormalDamageSource

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

the class GrenadeProjectile method onUpdate.

@Override
public void onUpdate() {
    super.onUpdate();
    if (ticksExisted >= 40) {
        if (!getEntityWorld().isRemote) {
            float strength = ConfigHandler.canGrenadesDestroyBlocks ? 1.4F : 0.1F;
            getEntityWorld().createExplosion(null, posX, posY, posZ, strength, true);
            AxisAlignedBB axis = new AxisAlignedBB(this.posX - 3, this.posY - 3, this.posZ - 3, this.posX + 3, this.posY + 3, this.posZ + 3);
            List<EntityLivingBase> targets = getEntityWorld().getEntitiesWithinAABB(EntityLivingBase.class, axis);
            for (EntityLivingBase mob : targets) {
                int damage = ConfigHandler.getGrenadeTurretSettings().getDamage();
                if (isAmped) {
                    EntityLivingBase elb = (EntityLivingBase) mob;
                    damage += ((int) elb.getHealth() * (getDamageAmpBonus() * amp_level));
                }
                setMobDropLoot(mob);
                if (mob instanceof EntityPlayer) {
                    if (canDamagePlayer((EntityPlayer) mob)) {
                        mob.attackEntityFrom(new NormalDamageSource("grenade"), damage * 0.9F);
                        mob.attackEntityFrom(new ArmorBypassDamageSource("grenade"), damage * 0.1F);
                        mob.hurtResistantTime = 0;
                    }
                } else {
                    mob.attackEntityFrom(new NormalDamageSource("grenade"), damage * 0.9F);
                    mob.attackEntityFrom(new ArmorBypassDamageSource("grenade"), damage * 0.1F);
                    mob.hurtResistantTime = 0;
                }
            }
            this.setDead();
        }
        for (int i = 0; i <= 20; i++) {
            getEntityWorld().spawnParticle(EnumParticleTypes.REDSTONE, posX, posY, posZ, 1.0D, 1.0D, 1.0D);
        }
    }
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) ArmorBypassDamageSource(omtteam.openmodularturrets.entity.projectiles.damagesources.ArmorBypassDamageSource) EntityLivingBase(net.minecraft.entity.EntityLivingBase) NormalDamageSource(omtteam.openmodularturrets.entity.projectiles.damagesources.NormalDamageSource) EntityPlayer(net.minecraft.entity.player.EntityPlayer)

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