Search in sources :

Example 16 with EntityClayMan

use of de.sanandrew.mods.claysoldiers.entity.EntityClayMan in project ClaySoldiersMod by SanAndreasP.

the class EntityEmeraldChunk method onImpact.

@Override
protected void onImpact(MovingObjectPosition movObjPos) {
    if (movObjPos.entityHit != null) {
        boolean isEnemy = movObjPos.entityHit instanceof EntityClayMan && this.target instanceof EntityClayMan && !((EntityClayMan) movObjPos.entityHit).getClayTeam().equals(((EntityClayMan) this.target).getClayTeam());
        DamageSource dmgSrc = DamageSource.causeThrownDamage(this, this.getThrower());
        if (this.getThrower() == null) {
            dmgSrc = DamageSource.causeThrownDamage(this, this);
        }
        dmgSrc.setDamageBypassesArmor();
        if (movObjPos.entityHit == this.target || isEnemy) {
            float attackDmg = 3.0F + this.rand.nextFloat();
            if (movObjPos.entityHit.isWet()) {
                attackDmg *= 2.0F;
            }
            if (movObjPos.entityHit.attackEntityFrom(dmgSrc, attackDmg)) {
                if (this.getThrower() instanceof EntityClayMan) {
                    ((EntityClayMan) this.getThrower()).onProjectileHit(this, movObjPos);
                }
                if (movObjPos.entityHit instanceof EntityClayMan) {
                    EntityClayMan iChun = (EntityClayMan) movObjPos.entityHit;
                    movObjPos.entityHit.playSound("ambient.weather.thunder", 1.0F, 8.0F);
                    SoldierEffectInst effect = iChun.addEffect(SoldierEffects.getEffect(SoldierEffects.EFF_THUNDER));
                    if (effect != null && this.origin != null) {
                        effect.getNbtTag().setDouble("originX", this.origin.getValue0());
                        effect.getNbtTag().setDouble("originY", this.origin.getValue1());
                        effect.getNbtTag().setDouble("originZ", this.origin.getValue2());
                    }
                    iChun.updateUpgradeEffectRenders();
                }
            }
        } else {
            return;
        }
    }
    if (!this.worldObj.isRemote) {
        if (movObjPos.typeOfHit != MovingObjectType.BLOCK || this.getBlockCollisionBox(this.worldObj, movObjPos.blockX, movObjPos.blockY, movObjPos.blockZ) != null) {
            ParticlePacketSender.sendDiggingFx(this.posX, this.posY, this.posZ, this.dimension, Blocks.snow);
            this.setDead();
        }
        this.dataWatcher.updateObject(DW_DEAD, (byte) (this.isDead ? 1 : 0));
    }
}
Also used : EntityClayMan(de.sanandrew.mods.claysoldiers.entity.EntityClayMan) DamageSource(net.minecraft.util.DamageSource) SoldierEffectInst(de.sanandrew.mods.claysoldiers.util.soldier.effect.SoldierEffectInst)

Example 17 with EntityClayMan

use of de.sanandrew.mods.claysoldiers.entity.EntityClayMan in project ClaySoldiersMod by SanAndreasP.

the class EntityGravelChunk method onImpact.

@Override
protected void onImpact(MovingObjectPosition movObjPos) {
    if (movObjPos.entityHit != null) {
        float attackDmg = 2.0F + this.rand.nextFloat() * 2.0F;
        boolean isEnemy = movObjPos.entityHit instanceof EntityClayMan && this.target instanceof EntityClayMan && ((EntityClayMan) movObjPos.entityHit).getClayTeam().equals(((EntityClayMan) this.target).getClayTeam());
        DamageSource dmgSrc = DamageSource.causeThrownDamage(this, this.getThrower());
        if (this.getThrower() == null) {
            dmgSrc = DamageSource.causeThrownDamage(this, this);
        }
        if ((movObjPos.entityHit == this.target || isEnemy) && movObjPos.entityHit.attackEntityFrom(dmgSrc, attackDmg)) {
            if (this.getThrower() instanceof EntityClayMan) {
                ((EntityClayMan) this.getThrower()).onProjectileHit(this, movObjPos);
            }
        } else {
            return;
        }
    }
    if (!this.worldObj.isRemote) {
        if (movObjPos.typeOfHit != MovingObjectType.BLOCK || this.getBlockCollisionBox(this.worldObj, movObjPos.blockX, movObjPos.blockY, movObjPos.blockZ) != null) {
            ParticlePacketSender.sendDiggingFx(this.posX, this.posY, this.posZ, this.dimension, Blocks.gravel);
            this.setDead();
        }
        this.dataWatcher.updateObject(DW_DEAD, (byte) (this.isDead ? 1 : 0));
    }
}
Also used : EntityClayMan(de.sanandrew.mods.claysoldiers.entity.EntityClayMan) DamageSource(net.minecraft.util.DamageSource)

Example 18 with EntityClayMan

use of de.sanandrew.mods.claysoldiers.entity.EntityClayMan in project ClaySoldiersMod by SanAndreasP.

the class UpgradeMagmacream method onSoldierDeath.

@Override
public void onSoldierDeath(EntityClayMan clayMan, SoldierUpgradeInst upgradeInst, DamageSource source) {
    if (source instanceof EntityDamageSource && !source.isProjectile() && !source.isExplosion() && source.getEntity() instanceof EntityClayMan) {
        EntityClayMan target = (EntityClayMan) source.getEntity();
        target.playSound("game.tnt.primed", 1.0F, 1.0F);
        target.addEffect(SoldierEffects.getEffect(SoldierEffects.EFF_MAGMABOMB));
        target.attackEntityFrom(DamageSource.magic, 0.0F);
    }
}
Also used : EntityClayMan(de.sanandrew.mods.claysoldiers.entity.EntityClayMan) EntityDamageSource(net.minecraft.util.EntityDamageSource)

Example 19 with EntityClayMan

use of de.sanandrew.mods.claysoldiers.entity.EntityClayMan in project ClaySoldiersMod by SanAndreasP.

the class UpgradeRedstone method onProjectileHit.

@Override
public void onProjectileHit(EntityClayMan clayMan, SoldierUpgradeInst upgradeInst, MovingObjectPosition target, ISoldierProjectile<? extends EntityThrowable> projectile) {
    if (target.entityHit instanceof EntityClayMan) {
        EntityClayMan caddicarus = (EntityClayMan) target.entityHit;
        if (caddicarus.addEffect(SoldierEffects.getEffect(SoldierEffects.EFF_REDSTONE)) != null) {
            caddicarus.playSound("random.fizz", 1.0F, 1.0F);
            upgradeInst.getNbtTag().setShort(NBT_USES, (short) (upgradeInst.getNbtTag().getShort(NBT_USES) - 1));
        }
    }
}
Also used : EntityClayMan(de.sanandrew.mods.claysoldiers.entity.EntityClayMan)

Example 20 with EntityClayMan

use of de.sanandrew.mods.claysoldiers.entity.EntityClayMan in project ClaySoldiersMod by SanAndreasP.

the class TileEntityClayNexus method countDamagingEnemies.

private int countDamagingEnemies() {
    @SuppressWarnings("unchecked") List<EntityClayMan> soldiers = this.worldObj.getEntitiesWithinAABB(EntityClayMan.class, this.p_damageArea);
    int cnt = 0;
    for (EntityClayMan dodger : soldiers) {
        if (!dodger.getClayTeam().equals(this.p_tempClayTeam.getTeamName())) {
            cnt++;
        }
    }
    return cnt;
}
Also used : EntityClayMan(de.sanandrew.mods.claysoldiers.entity.EntityClayMan)

Aggregations

EntityClayMan (de.sanandrew.mods.claysoldiers.entity.EntityClayMan)30 Entity (net.minecraft.entity.Entity)7 ISoldierProjectile (de.sanandrew.mods.claysoldiers.entity.projectile.ISoldierProjectile)4 DamageSource (net.minecraft.util.DamageSource)4 Block (net.minecraft.block.Block)2 World (net.minecraft.world.World)2 RGBAValues (de.sanandrew.core.manpack.util.helpers.SAPUtils.RGBAValues)1 Quartet (de.sanandrew.core.manpack.util.javatuples.Quartet)1 EntityBunnyMount (de.sanandrew.mods.claysoldiers.entity.mount.EntityBunnyMount)1 EntityGeckoMount (de.sanandrew.mods.claysoldiers.entity.mount.EntityGeckoMount)1 EntityHorseMount (de.sanandrew.mods.claysoldiers.entity.mount.EntityHorseMount)1 EntityTurtleMount (de.sanandrew.mods.claysoldiers.entity.mount.EntityTurtleMount)1 ClaymanTeam (de.sanandrew.mods.claysoldiers.util.soldier.ClaymanTeam)1 ASoldierEffect (de.sanandrew.mods.claysoldiers.util.soldier.effect.ASoldierEffect)1 SoldierEffectInst (de.sanandrew.mods.claysoldiers.util.soldier.effect.SoldierEffectInst)1 ASoldierUpgrade (de.sanandrew.mods.claysoldiers.util.soldier.upgrade.ASoldierUpgrade)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ArrayList (java.util.ArrayList)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 EntityThrowable (net.minecraft.entity.projectile.EntityThrowable)1