當前位置: 首頁>>代碼示例>>Java>>正文


Java EntityAnimal.setGrowingAge方法代碼示例

本文整理匯總了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);
}
 
開發者ID:jm-organization,項目名稱:connor41-etfuturum2,代碼行數:19,代碼來源:ServerEventHandler.java

示例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);
        }
    }
}
 
開發者ID:sameer,項目名稱:ExtraUtilities,代碼行數:26,代碼來源:BlockPureLove.java

示例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);
            }
        }
    }
}
 
開發者ID:sameer,項目名稱:ExtraUtilities,代碼行數:29,代碼來源:TileEntityGeneratorPink.java

示例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);
      }
   }

}
 
開發者ID:lerion13,項目名稱:witchery,代碼行數:76,代碼來源:EntityWitchProjectile.java


注:本文中的net.minecraft.entity.passive.EntityAnimal.setGrowingAge方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。