Search in sources :

Example 6 with EntityAgeable

use of net.minecraft.entity.EntityAgeable in project VoodooCraft by Mod-DevCafeTeam.

the class HexFertility method activeUse.

@Override
public ItemStack activeUse(ItemStack stackIn, World world, EntityPlayer player, EnumHand hand, int strength, @Nullable EntityLivingBase target) {
    if (world.isRemote || target == null)
        return super.activeUse(stackIn, world, player, hand, strength, target);
    if (target instanceof EntityZombie && !target.isChild()) {
        EntityZombie entity = new EntityZombie(world);
        entity.setChild(true);
        entity.copyLocationAndAnglesFrom(target);
        entity.onInitialSpawn(world.getDifficultyForLocation(new BlockPos(entity)), null);
        world.spawnEntity(entity);
    } else if (target instanceof EntityAgeable && !target.isChild()) {
        EntityAgeable entity = (EntityAgeable) target;
        EntityAgeable child = entity.createChild(entity);
        child.copyLocationAndAnglesFrom(entity);
        child.setGrowingAge(-24000);
        child.onInitialSpawn(world.getDifficultyForLocation(new BlockPos(entity)), null);
        world.spawnEntity(child);
    }
    return super.activeUse(stackIn, world, player, hand, strength, target);
}
Also used : EntityZombie(net.minecraft.entity.monster.EntityZombie) BlockPos(net.minecraft.util.math.BlockPos) EntityAgeable(net.minecraft.entity.EntityAgeable)

Example 7 with EntityAgeable

use of net.minecraft.entity.EntityAgeable in project ImmersiveEngineering by BluSunrize.

the class EntityRevolvershot method onImpact.

protected void onImpact(RayTraceResult mop) {
    boolean headshot = false;
    if (mop.entityHit instanceof EntityLivingBase)
        headshot = Utils.isVecInEntityHead((EntityLivingBase) mop.entityHit, new Vec3d(posX, posY, posZ));
    if (this.bulletType != null) {
        IBullet bullet = BulletHandler.getBullet(bulletType);
        if (bullet != null)
            bullet.onHitTarget(worldObj, mop, this.shootingEntity, this, headshot);
        if (headshot && mop.entityHit instanceof EntityAgeable && ((EntityAgeable) mop.entityHit).isChild()) {
            if (this.shootingEntity instanceof EntityPlayer)
                ((EntityPlayer) this.shootingEntity).addStat(IEAchievements.secret_birthdayParty);
            this.playSound(IESounds.birthdayParty, 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F));
        }
    }
    if (!this.worldObj.isRemote) {
        //			if(bulletType==3)
        //				worldObj.createExplosion(shootingEntity, posX, posY, posZ, 2, false);
        this.secondaryImpact(mop);
    }
    this.setDead();
}
Also used : IBullet(blusunrize.immersiveengineering.api.tool.BulletHandler.IBullet) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer) EntityAgeable(net.minecraft.entity.EntityAgeable)

Example 8 with EntityAgeable

use of net.minecraft.entity.EntityAgeable in project Railcraft by Railcraft.

the class EntityAIMateBreeding method spawnBaby.

/**
     * Spawns a baby animal of the same type.
     */
private void spawnBaby() {
    EntityAgeable baby = theAnimal.createChild(targetMate);
    if (baby instanceof EntityAnimal) {
        // 6000
        theAnimal.setGrowingAge(3600);
        // 6000
        targetMate.setGrowingAge(3600);
        theAnimal.resetInLove();
        targetMate.resetInLove();
        // -24000
        baby.setGrowingAge(-12000);
        modifyAI((EntityAnimal) baby);
        Random rand = theAnimal.getRNG();
        if (baby instanceof EntityOcelot) {
            EntityOcelot cat = (EntityOcelot) baby;
            if (rand.nextInt(10) == 0) {
                cat.setTameSkin(baby.worldObj.rand.nextInt(4));
            }
        }
        double x = rand.nextGaussian() * 0.2D;
        double z = rand.nextGaussian() * 0.2D;
        baby.setLocationAndAngles(theAnimal.posX + x, theAnimal.posY, theAnimal.posZ + z, 0.0F, 0.0F);
        theWorld.spawnEntityInWorld(baby);
        for (int i = 0; i < 7; ++i) {
            double px = rand.nextGaussian() * 0.02D;
            double py = rand.nextGaussian() * 0.02D;
            double pz = rand.nextGaussian() * 0.02D;
            theWorld.spawnParticle(HEART, theAnimal.posX + (double) (rand.nextFloat() * theAnimal.width * 2.0F) - (double) theAnimal.width, theAnimal.posY + 0.5D + (double) (rand.nextFloat() * theAnimal.height), theAnimal.posZ + (double) (rand.nextFloat() * theAnimal.width * 2.0F) - (double) theAnimal.width, px, py, pz);
        }
    }
}
Also used : Random(java.util.Random) EntityAgeable(net.minecraft.entity.EntityAgeable)

Aggregations

EntityAgeable (net.minecraft.entity.EntityAgeable)8 Entity (net.minecraft.entity.Entity)2 EntityLivingBase (net.minecraft.entity.EntityLivingBase)2 EntityZombie (net.minecraft.entity.monster.EntityZombie)2 IBullet (blusunrize.immersiveengineering.api.tool.BulletHandler.IBullet)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Random (java.util.Random)1 EntityGiantZombie (net.minecraft.entity.monster.EntityGiantZombie)1 EntityPigZombie (net.minecraft.entity.monster.EntityPigZombie)1 EntityPig (net.minecraft.entity.passive.EntityPig)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 ItemStack (net.minecraft.item.ItemStack)1 BlockPos (net.minecraft.util.math.BlockPos)1 BabyEntitySpawnEvent (net.minecraftforge.event.entity.living.BabyEntitySpawnEvent)1 DroneEntityBase (pneumaticCraft.common.ai.DroneEntityBase)1 BlockPosition (powercrystals.core.position.BlockPosition)1