本文整理汇总了Java中net.minecraft.entity.passive.EntityAnimal.setGrowingAge方法的典型用法代码示例。如果您正苦于以下问题:Java EntityAnimal.setGrowingAge方法的具体用法?Java EntityAnimal.setGrowingAge怎么用?Java EntityAnimal.setGrowingAge使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.entity.passive.EntityAnimal
的用法示例。
在下文中一共展示了EntityAnimal.setGrowingAge方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: feedBaby
import net.minecraft.entity.passive.EntityAnimal; //导入方法依赖的package包/类
private void feedBaby(EntityAnimal animal, EntityPlayer player, ItemStack stack) {
int currentAge = animal.getGrowingAge();
int age = (int) (-currentAge * 0.1F);
animal.setGrowingAge(currentAge + age);
player.swingItem();
Random itemRand = animal.worldObj.rand;
for (int i = 0; i < 3; i++) {
double d0 = itemRand.nextGaussian() * 0.02D;
double d1 = itemRand.nextGaussian() * 0.02D;
double d2 = itemRand.nextGaussian() * 0.02D;
animal.worldObj.spawnParticle("happyVillager", animal.posX + itemRand.nextFloat() * 0.5, animal.posY + 0.5 + itemRand.nextFloat() * 0.5, animal.posZ + itemRand.nextFloat() * 0.5, d0, d1, d2);
}
if (!player.capabilities.isCreativeMode)
if (--stack.stackSize <= 0)
player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
}
示例2: onEntityCollidedWithBlock
import net.minecraft.entity.passive.EntityAnimal; //导入方法依赖的package包/类
public void onEntityCollidedWithBlock(final World world, final int x, final int y, final int z, final Entity entity) {
if (this.rand.nextInt(5) > 0) {
return;
}
if (entity instanceof EntityAnimal) {
final EntityAnimal animal = (EntityAnimal)entity;
if (animal.getGrowingAge() < 0) {
animal.addGrowth(this.rand.nextInt(40));
}
else if (animal.getGrowingAge() > 0) {
int j = animal.getGrowingAge();
j -= this.rand.nextInt(40);
if (j < 0) {
j = 0;
}
animal.setGrowingAge(j);
}
else if (!animal.isInLove()) {
if (world.getEntitiesWithinAABB((Class)entity.getClass(), entity.boundingBox.expand(8.0, 8.0, 8.0)).size() > 32) {
return;
}
animal.func_146082_f((EntityPlayer)null);
}
}
}
示例3: doSpecial
import net.minecraft.entity.passive.EntityAnimal; //导入方法依赖的package包/类
@Override
public void doSpecial() {
if (this.coolDown > 0.0 && this.rand.nextInt(40) == 0) {
for (final Object entity : this.worldObj.getEntitiesWithinAABB((Class)EntityAnimal.class, AxisAlignedBB.getBoundingBox((double)this.x(), (double)this.y(), (double)this.z(), (double)(this.x() + 1), (double)(this.y() + 1), (double)(this.z() + 1)).expand(10.0, 10.0, 10.0))) {
final EntityAnimal animal = (EntityAnimal)entity;
if (animal.getGrowingAge() < 0) {
animal.addGrowth(this.rand.nextInt(40));
}
else if (animal.getGrowingAge() > 0) {
int j = animal.getGrowingAge();
j -= this.rand.nextInt(40);
if (j < 0) {
j = 0;
}
animal.setGrowingAge(j);
}
else {
if (animal.isInLove() || this.rand.nextInt(40) != 0) {
continue;
}
if (animal.worldObj.getEntitiesWithinAABB((Class)entity.getClass(), animal.boundingBox.expand(8.0, 8.0, 8.0)).size() > 32) {
return;
}
animal.func_146082_f((EntityPlayer)null);
}
}
}
}
示例4: impactLove
import net.minecraft.entity.passive.EntityAnimal; //导入方法依赖的package包/类
private void impactLove(MovingObjectPosition mop, boolean enhanced) {
double RADIUS = enhanced?5.0D:4.0D;
AxisAlignedBB axisalignedbb = super.boundingBox.expand(RADIUS, 2.0D, RADIUS);
List list1 = super.worldObj.getEntitiesWithinAABB(EntityLiving.class, axisalignedbb);
if(list1 != null && !list1.isEmpty() && !super.worldObj.isRemote) {
EntityLivingBase entityThrower = this.getThrower();
EntityPlayer thrower = entityThrower != null && entityThrower instanceof EntityPlayer?(EntityPlayer)entityThrower:null;
Iterator iterator = list1.iterator();
ArrayList villagers = new ArrayList();
ArrayList zombies = new ArrayList();
while(iterator.hasNext()) {
EntityLiving limit = (EntityLiving)iterator.next();
double zombie = limit.getDistanceSq(super.posX, super.posY, super.posZ);
if(zombie < RADIUS * RADIUS) {
double baby = 1.0D - Math.sqrt(zombie) / RADIUS;
if(limit == mop.entityHit) {
baby = 1.0D;
}
int j = (int)(baby * 400.0D + 0.5D);
if(limit instanceof EntityAnimal) {
EntityAnimal zombie1 = (EntityAnimal)limit;
if(zombie1.getGrowingAge() >= 0) {
zombie1.setGrowingAge(0);
zombie1.func_146082_f((EntityPlayer)null);
}
} else if(limit instanceof EntityVillager) {
EntityVillager var26 = (EntityVillager)limit;
if(var26.getGrowingAge() >= 0) {
villagers.add(var26);
}
} else if(limit instanceof EntityZombie) {
EntityZombie var25 = (EntityZombie)limit;
if(!var25.isChild() && thrower != null) {
NBTTagCompound nbt = var25.getEntityData();
if(PotionEnslaved.isMobEnslavedBy(var25, thrower)) {
zombies.add(var25);
}
}
}
}
}
int var20 = 10;
while(villagers.size() > 1 && var20-- > 0) {
EntityVillager var22 = (EntityVillager)villagers.get(0);
EntityVillager mate = (EntityVillager)villagers.get(1);
var22.setPosition(mate.posX, mate.posY, mate.posZ);
ParticleEffect.HEART.send(SoundEffect.NONE, mate, 1.0D, 2.0D, 8);
this.giveBirth(var22, mate);
villagers.remove(0);
villagers.remove(0);
}
var20 = 10;
while(zombies.size() > 1 && var20-- > 0) {
EntityZombie var21 = (EntityZombie)zombies.get(0);
EntityZombie var23 = (EntityZombie)zombies.get(1);
var21.setPosition(var23.posX, var23.posY, var23.posZ);
ParticleEffect.HEART.send(SoundEffect.NONE, var23, 1.0D, 2.0D, 8);
var21.setVillager(true);
var23.setVillager(true);
EntityZombie var24 = new EntityZombie(super.worldObj);
var24.setLocationAndAngles(var23.posX, var23.posY, var23.posZ, 0.0F, 0.0F);
var24.setChild(true);
super.worldObj.spawnEntityInWorld(var24);
zombies.remove(0);
zombies.remove(0);
}
}
}