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


Java EntityAnimal.getGrowingAge方法代碼示例

本文整理匯總了Java中net.minecraft.entity.passive.EntityAnimal.getGrowingAge方法的典型用法代碼示例。如果您正苦於以下問題:Java EntityAnimal.getGrowingAge方法的具體用法?Java EntityAnimal.getGrowingAge怎麽用?Java EntityAnimal.getGrowingAge使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.minecraft.entity.passive.EntityAnimal的用法示例。


在下文中一共展示了EntityAnimal.getGrowingAge方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: onLivingDrops

import net.minecraft.entity.passive.EntityAnimal; //導入方法依賴的package包/類
@SubscribeEvent
public void onLivingDrops(LivingDropsEvent event)
{
	Entity e = event.entity;
	List<EntityItem> drops = event.drops;
	// Remove all drops from cows, sheep and pigs, add carcass drop
	if (e instanceof EntityCow || e instanceof EntityPig || e instanceof EntitySheep)
	{
		EntityAnimal a = (EntityAnimal) e;
		Iterator<EntityItem> it = drops.iterator();
		while (it.hasNext())
		{
			EntityItem i = it.next();
			it.remove();
		}

		if (a.getGrowingAge() == 0)
		{
			if (a instanceof EntityCow) a.dropItem(TanneryItems.bloodyCowCarcass, 1);
			else if (a instanceof EntityPig) a.dropItem(TanneryItems.bloodyPigCarcass, 1);
			else if (a instanceof EntitySheep) a.dropItem(TanneryItems.bloodySheepCarcass, 1);
		}
	}
}
 
開發者ID:hero887,項目名稱:Tannery,代碼行數:25,代碼來源:EntityDropsHandler.java

示例4: callMethod

import net.minecraft.entity.passive.EntityAnimal; //導入方法依賴的package包/類
@Override
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws LuaException, InterruptedException {
	if (!Config.enableFeederTurtle)
		throw new LuaException("Feeder Turtles have been disabled");
	if (method == 0) {
		ItemStack curItem = turtle.getInventory().getStackInSlot(turtle.getSelectedSlot());
		if (curItem == null || curItem.stackSize <= 0)
			return new Object[] {false};
		ChunkCoordinates pos = turtle.getPosition();
		for (EntityAnimal animal : (List<EntityAnimal>)turtle.getWorld().getEntitiesWithinAABB(EntityAnimal.class, AxisAlignedBB.getBoundingBox(pos.posX - 1.5D, pos.posY - 1.5D, pos.posZ - 1.5D, pos.posX + 1.5D, pos.posY + 1.5D, pos.posZ + 1.5D))) {
			if (animal.getGrowingAge() == 0 && !animal.isInLove() && animal.isBreedingItem(curItem)) {
				animal.setTarget(null);
				animal.func_146082_f(null);//setting inLove to 600
				curItem.stackSize--;
				if (curItem.stackSize <= 0)
					turtle.getInventory().setInventorySlotContents(turtle.getSelectedSlot(), null);
				else
					turtle.getInventory().setInventorySlotContents(turtle.getSelectedSlot(), curItem);
				return new Object[]{true};
			}
		}
		return new Object[]{false};
	}
	return new Object[0];
}
 
開發者ID:austinv11,項目名稱:PeripheralsPlusPlus,代碼行數:26,代碼來源:PeripheralFeeder.java

示例5: attackEntity

import net.minecraft.entity.passive.EntityAnimal; //導入方法依賴的package包/類
@Override
protected ArrayList<ItemStack> attackEntity(ITurtleAccess turtle, Entity entity) throws TurtleFailureAttack {
    final IInventory inv = turtle.getInventory();
    final int selected = turtle.getSelectedSlot();
    final ItemStack currStack = inv.getStackInSlot(selected);
    if (currStack == null || currStack.stackSize <= 0) {
        throw new TurtleFailureAttack("selected slot empty");
    }
    final EntityAnimal animal = (EntityAnimal) entity;
    if (animal.getGrowingAge() == 0 && !animal.isInLove() && animal.isBreedingItem(currStack)) {
        animal.setTarget(null); // remove anything they're following
        animal.func_146082_f(null); // set it in love
        --currStack.stackSize;
        if (currStack.stackSize == 0) {
            inv.setInventorySlotContents(selected, null);
        }
    }
    return null;
}
 
開發者ID:theoriginalbit,項目名稱:MoarPeripherals,代碼行數:20,代碼來源:UpgradeFeeder.java

示例6: findAnimalToFeed

import net.minecraft.entity.passive.EntityAnimal; //導入方法依賴的package包/類
protected EntityAnimal findAnimalToFeed(int n) {
	Point3I point = getPoint(n);
	boundCheck = new AxisAlignedBB(point.getX(), point.getY()-1, point.getZ(), 
			point.getX()+1, point.getY()+2, point.getZ()+1);
	List<EntityAnimal> entities = world.getEntitiesWithinAABB(EntityAnimal.class, boundCheck);
	if (!entities.isEmpty()) {
		for (EntityAnimal animal: entities) {
			if ( (!slots[SLOT_FOOD].isEmpty()) && (animal.isBreedingItem(slots[SLOT_FOOD])) ) {
				if (animal.getGrowingAge() == 0 && !animal.isInLove()) {
					return animal;
				}
			}
		}
	}
	return null;
}
 
開發者ID:Vanhal,項目名稱:ProgressiveAutomation,代碼行數:17,代碼來源:TileFarmer.java

示例7: work

import net.minecraft.entity.passive.EntityAnimal; //導入方法依賴的package包/類
@Override
public float work() {
    if (WorkUtils.isDisabled(this.getBlockType())) return 0;

    AxisAlignedBB area = getWorkingArea();
    List<EntityAnimal> animals = this.world.getEntitiesWithinAABB(EntityAnimal.class, area);
    if (animals.size() == 0 || animals.size() > 35) return 0;
    EntityAnimal animal1 = animals.get(0);
    while ((animal1.isChild() || animal1.getGrowingAge() != 0 || getFirstBreedingItem(animal1).isEmpty() || animal1.isInLove()) && animals.indexOf(animal1) + 1 < animals.size())
        animal1 = animals.get(animals.indexOf(animal1) + 1);
    if (animal1.isChild() || animal1.getGrowingAge() != 0) return 0;
    EntityAnimal animal2 = animals.get(0);
    while ((animal2.equals(animal1) || animal2.isChild() || animal2.getGrowingAge() != 0 || getFirstBreedingItem(animal2).isEmpty() || animal1.isInLove()) && animals.indexOf(animal2) + 1 < animals.size())
        animal2 = animals.get(animals.indexOf(animal2) + 1);
    if (animal2.equals(animal1) || animal2.isChild() || animal2.getGrowingAge() != 0) return 0;
    if (animal1.getClass() != animal2.getClass()) return 0;
    ItemStack stack = getFirstBreedingItem(animal1);
    Item item = stack.getItem();
    stack.setCount(stack.getCount() - 1);
    stack = getFirstBreedingItem(animal2);
    if (stack.isEmpty()) {
        ItemHandlerHelper.insertItem(inFeedItems, new ItemStack(item, 1), false);
        return 0;
    }
    stack.setCount(stack.getCount() - 1);
    animal1.setInLove(null);
    animal2.setInLove(null);

    return 1;
}
 
開發者ID:Buuz135,項目名稱:Industrial-Foregoing,代碼行數:31,代碼來源:AnimalStockIncreaserTile.java

示例8: 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

示例9: scanForCows

import net.minecraft.entity.passive.EntityAnimal; //導入方法依賴的package包/類
private void scanForCows(List<EntityAnimal> animals) {
	scanForAnimals(animals, cowsToBreed, maxCowCount);
	for (EntityAnimal animal : animals) {
		if (animal.getGrowingAge() >= 0) {
			cowsToMilk.add(animal.getEntityId());
		}
	}
}
 
開發者ID:Alec-WAM,項目名稱:CrystalMod,代碼行數:9,代碼來源:WorksiteAnimalFarm.java

示例10: getAnimals

import net.minecraft.entity.passive.EntityAnimal; //導入方法依賴的package包/類
public ArrayList getAnimals( final World world ) {
	final List list = world.getEntitiesWithinAABB( EntityAnimal.class, fairy.boundingBox.expand( 5D, 5D, 5D ) );

	if ( list.size() < 2 ) {
		return null;
	}

	final ArrayList list2 = new ArrayList();

	for ( int i = 0; i < list.size(); i++ ) {
		final EntityAnimal entity1 = (EntityAnimal) list.get( i );

		final int fleeingTick = ReflectionHelper.getPrivateValue(EntityCreature.class, entity1, MCP_FLEEINGTICK);
		if ( fairy.peacefulAnimal( entity1 ) && fairy.canEntityBeSeen( entity1 ) && entity1.getHealth() > 0
				&& entity1.getEntityToAttack() == null && fleeingTick <= 0 && !entity1.isInLove()
				&& entity1.getGrowingAge() == 0 ) {
			for ( int j = 0; j < list.size(); j++ ) {
				final EntityAnimal entity2 = (EntityAnimal) list.get( j );

				if ( entity1 != entity2 && entity1.getClass() == entity2.getClass()
						&& entity2.getGrowingAge() == 0 ) {
					list2.add( entity1 );
				}
			}
		}
	}

	if ( list2.size() <= 0 ) {
		return null;
	} else {
		return list2;
	}
}
 
開發者ID:allaryin,項目名稱:FairyFactions,代碼行數:34,代碼來源:FairyJob.java

示例11: onEntityUpdate

import net.minecraft.entity.passive.EntityAnimal; //導入方法依賴的package包/類
@Override
public void onEntityUpdate() {
    super.onEntityUpdate();
    if (!worldObj.isRemote && worldObj.getTotalWorldTime() % 3 == 0) {
        List<EntityAnimal> nearbyEntities = worldObj.getEntitiesWithinAABB(EntityAnimal.class, new AxisAlignedBB(posX - 1, posY - 1, posZ - 1, posX + 1, posY + 1, posZ + 1));
        for (EntityAnimal entity : nearbyEntities) {
            if (!entity.isInLove() && entity.getGrowingAge() == 0) {
                entity.setInLove(player);
                AuraCascade.proxy.networkWrapper.sendToAllAround(new PacketBurst(5, entity.posX, entity.posY, entity.posZ), new NetworkRegistry.TargetPoint(entity.worldObj.provider.getDimension(), entity.posX, entity.posY, entity.posZ, 32));
                break;

            }
        }
    }
}
 
開發者ID:AdlyTempleton,項目名稱:Aura-Cascade,代碼行數:16,代碼來源:EntityBreederFairy.java

示例12: itemInteractionForEntity

import net.minecraft.entity.passive.EntityAnimal; //導入方法依賴的package包/類
@Override
public boolean itemInteractionForEntity(ItemStack stack, EntityPlayer player, EntityLivingBase target) {
	if (player.worldObj.isRemote || player.isSneaking() ||
	    !(target instanceof EntityAnimal))
		return false;
	
	InventoryPouch pouch = InventoryPouch.getOrCreate(player, player.inventory.currentItem);
	ItemStack item = getNextItem(pouch, null);
	if ((item == null) || !PouchAPI.getEntry(item).isFood ||
	    !((EntityAnimal)target).isBreedingItem(item))
		return false;
	boolean used = false;
	
	AxisAlignedBB aabb = AxisAlignedBB.getBoundingBox(
			target.posX - 2, target.posY - 1, target.posZ - 2,
			target.posX + 2, target.posY + 1, target.posZ + 2);
	List<EntityAnimal> entities = target.worldObj.getEntitiesWithinAABB(target.getClass(), aabb);
	
	for (EntityAnimal entity : entities) {
		if ((item = getNextItem(pouch, item)) == null) break;
		if ((entity.getGrowingAge() == 0) && !entity.isInLove() &&
		    entity.isBreedingItem(item)) {
			entity.func_146082_f(player);
			item.stackSize--;
			item = setLastPouchItem(pouch, item);
			used = true;
		}
	}
	return used;
}
 
開發者ID:copygirl,項目名稱:PocketBags,代碼行數:31,代碼來源:ItemPouch.java

示例13: shouldExecute

import net.minecraft.entity.passive.EntityAnimal; //導入方法依賴的package包/類
/**
 * Returns whether the EntityAIBase should begin execution.
 */
public boolean shouldExecute()
{
    if (this.childAnimal.getGrowingAge() >= 0)
    {
        return false;
    }
    else
    {
        List<EntityAnimal> list = this.childAnimal.worldObj.<EntityAnimal>getEntitiesWithinAABB(this.childAnimal.getClass(), this.childAnimal.getEntityBoundingBox().expand(8.0D, 4.0D, 8.0D));
        EntityAnimal entityanimal = null;
        double d0 = Double.MAX_VALUE;

        for (EntityAnimal entityanimal1 : list)
        {
            if (entityanimal1.getGrowingAge() >= 0)
            {
                double d1 = this.childAnimal.getDistanceSqToEntity(entityanimal1);

                if (d1 <= d0)
                {
                    d0 = d1;
                    entityanimal = entityanimal1;
                }
            }
        }

        if (entityanimal == null)
        {
            return false;
        }
        else if (d0 < 9.0D)
        {
            return false;
        }
        else
        {
            this.parentAnimal = entityanimal;
            return true;
        }
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:45,代碼來源:EntityAIFollowParent.java

示例14: shouldExecute

import net.minecraft.entity.passive.EntityAnimal; //導入方法依賴的package包/類
/**
 * Returns whether the EntityAIBase should begin execution.
 */
public boolean shouldExecute()
{
    if (this.childAnimal.getGrowingAge() >= 0)
    {
        return false;
    }
    else
    {
        List<EntityAnimal> list = this.childAnimal.world.<EntityAnimal>getEntitiesWithinAABB(this.childAnimal.getClass(), this.childAnimal.getEntityBoundingBox().expand(8.0D, 4.0D, 8.0D));
        EntityAnimal entityanimal = null;
        double d0 = Double.MAX_VALUE;

        for (EntityAnimal entityanimal1 : list)
        {
            if (entityanimal1.getGrowingAge() >= 0)
            {
                double d1 = this.childAnimal.getDistanceSqToEntity(entityanimal1);

                if (d1 <= d0)
                {
                    d0 = d1;
                    entityanimal = entityanimal1;
                }
            }
        }

        if (entityanimal == null)
        {
            return false;
        }
        else if (d0 < 9.0D)
        {
            return false;
        }
        else
        {
            this.parentAnimal = entityanimal;
            return true;
        }
    }
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:45,代碼來源:EntityAIFollowParent.java

示例15: 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.getGrowingAge方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。