本文整理汇总了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);
}
示例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: 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);
}
}
}
示例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];
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
}
}
示例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());
}
}
}
示例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;
}
}
示例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;
}
}
}
}
示例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;
}
示例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;
}
}
}
示例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;
}
}
}
示例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);
}
}
}