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);
}
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();
}
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);
}
}
}
Aggregations