当前位置: 首页>>代码示例>>Java>>正文


Java EntityAnimal.isInLove方法代码示例

本文整理汇总了Java中net.minecraft.entity.passive.EntityAnimal.isInLove方法的典型用法代码示例。如果您正苦于以下问题:Java EntityAnimal.isInLove方法的具体用法?Java EntityAnimal.isInLove怎么用?Java EntityAnimal.isInLove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraft.entity.passive.EntityAnimal的用法示例。


在下文中一共展示了EntityAnimal.isInLove方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

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

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

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

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

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

示例6: setAnimalInLove

import net.minecraft.entity.passive.EntityAnimal; //导入方法依赖的package包/类
private void setAnimalInLove(EntityAnimal animal, EntityPlayer player, ItemStack stack) {
	if (!animal.isInLove()) {
		animal.func_146082_f(player);
		if (!player.capabilities.isCreativeMode)
			if (--stack.stackSize <= 0)
				player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
	}
}
 
开发者ID:jm-organization,项目名称:connor41-etfuturum2,代码行数:9,代码来源:ServerEventHandler.java

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

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

示例9: canMateWith

import net.minecraft.entity.passive.EntityAnimal; //导入方法依赖的package包/类
/**
 * Returns true if the mob is currently able to mate with the specified mob.
 */
public boolean canMateWith(EntityAnimal mob)
{
	if(hasGenders()){
		if( this.getGender() == 0 && ((EntityIatMob) mob).getGender() == 1){
           	return true;
           }if(this.getGender() == 1 && ((EntityIatMob) mob).getGender() == 0){
           	return true;
           }	
	}
	return mob == this ? false : (mob.getClass() != this.getClass() ? false : this.isInLove() && mob.isInLove());
}
 
开发者ID:Alex-the-666,项目名称:It-s-About-Time-Minecraft-Mod,代码行数:15,代码来源:EntityIatMob.java

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

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

示例12: checkEntityImmunities

import net.minecraft.entity.passive.EntityAnimal; //导入方法依赖的package包/类
/**
 * If an entity is not in range, do some more checks to see if we should
 * give it a shot.
 *
 * @param entity
 * @return
 */
public static boolean checkEntityImmunities(Entity entity)
{
    // quick checks.
    if ( entity.inWater /* isInWater */ || entity.fire > 0 )
    {
        return true;
    }
    if ( !( entity instanceof EntityArrow ) )
    {
        if ( !entity.onGround || entity.riddenByEntity != null
                || entity.ridingEntity != null )
        {
            return true;
        }
    } else if ( !( (EntityArrow) entity ).inGround )
    {
        return true;
    }
    // special cases.
    if ( entity instanceof EntityLiving )
    {
        EntityLiving living = (EntityLiving) entity;
        if ( living.attackTime > 0 || living.hurtTime > 0 || living.activePotionsMap.size() > 0 )
        {
            return true;
        }
        if ( entity instanceof EntityCreature && ( (EntityCreature) entity ).entityToAttack != null )
        {
            return true;
        }
        if ( entity instanceof EntityVillager && ( (EntityVillager) entity ).isMating() /* Getter for first boolean */ )
        {
            return true;
        }
        if ( entity instanceof EntityAnimal )
        {
            EntityAnimal animal = (EntityAnimal) entity;
            if ( animal.isChild() || animal.isInLove() /*love*/ )
            {
                return true;
            }
            if ( entity instanceof EntitySheep && ( (EntitySheep) entity ).getSheared() )
            {
                return true;
            }
        }
    }
    return false;
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:57,代码来源:ActivationRange.java

示例13: scanForAnimals

import net.minecraft.entity.passive.EntityAnimal; //导入方法依赖的package包/类
private void scanForAnimals(List<EntityAnimal> animals,
		List<EntityPair> targets, int maxCount) {
	EntityAnimal animal1;
	EntityAnimal animal2;
	EntityPair breedingPair;

	int age;

	for (int i = 0; i < animals.size(); i++) {
		animal1 = animals.get(i);
		age = animal1.getGrowingAge();

		if (age != 0 || animal1.isInLove()) {
			continue;
		}// unbreedable first-target, skip
		while (i + 1 < animals.size())// loop through remaining animals to
										// find a breeding partner
		{
			i++;
			animal2 = animals.get(i);
			age = animal2.getGrowingAge();
			if (age == 0 && !animal2.isInLove())// found a second breedable
												// animal, add breeding
												// pair, exit to outer loop
			{
				breedingPair = new EntityPair(animal1, animal2);
				targets.add(breedingPair);
				break;
			}
		}
	}

	int grownCount = 0;
	for (EntityAnimal animal : animals) {
		if (animal.getGrowingAge() >= 0) {
			grownCount++;
		}
	}

	if (grownCount > maxCount) {
		for (int i = 0, cullCount = grownCount - maxCount; i < animals
				.size() && cullCount > 0; i++) {
			if (animals.get(i).getGrowingAge() >= 0) {
				entitiesToCull.add(animals.get(i).getEntityId());
				cullCount--;
			}
		}
	}
}
 
开发者ID:Alec-WAM,项目名称:CrystalMod,代码行数:50,代码来源:WorksiteAnimalFarm.java

示例14: breedable

import net.minecraft.entity.passive.EntityAnimal; //导入方法依赖的package包/类
@Override
public boolean breedable() {
    EntityAnimal animal = this.getAnimal();
    return ((animal != null) && !animal.isInLove() && !animal.isChild() && (animal.getGrowingAge() == 0));
}
 
开发者ID:faceofcat,项目名称:Mekfarm,代码行数:6,代码来源:VanillaGenericAnimal.java

示例15: canBreed

import net.minecraft.entity.passive.EntityAnimal; //导入方法依赖的package包/类
protected boolean canBreed(final EntityAnimal animal, final EntityPlayerMP player) {
	if(animal.getGrowingAge() != 0 || animal.isInLove())
		return false;
	
	return !(animal instanceof EntityHorse);
}
 
开发者ID:OreCruncher,项目名称:ThermalRecycling,代码行数:7,代码来源:BreedingItemManager.java


注:本文中的net.minecraft.entity.passive.EntityAnimal.isInLove方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。