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


Java EntityAnimal.isBreedingItem方法代码示例

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


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

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

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

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

示例4: isFoodItem

import net.minecraft.entity.passive.EntityAnimal; //导入方法依赖的package包/类
private boolean isFoodItem(EntityAnimal animal, ItemStack food) {
	if (animal.isBreedingItem(food))
		return true;
	else if (animal instanceof EntityPig && food.getItem() == ModItems.beetroot && EtFuturum.enableBeetroot)
		return true;
	else if (animal instanceof EntityChicken && food.getItem() == ModItems.beetroot_seeds && EtFuturum.enableBeetroot)
		return true;
	else
		return false;
}
 
开发者ID:jm-organization,项目名称:connor41-etfuturum2,代码行数:11,代码来源:ServerEventHandler.java

示例5: hasBreedingItem

import net.minecraft.entity.passive.EntityAnimal; //导入方法依赖的package包/类
public boolean hasBreedingItem(EntityAnimal animal) {
	for (int i = 0; i < this.inventory.getSizeInventory(); i++) {
		if (this.inventory.getStackInSlot(i) != null
				&& animal.isBreedingItem(this.inventory.getStackInSlot(i)))
			return true;
	}
	return false;
}
 
开发者ID:Alec-WAM,项目名称:CrystalMod,代码行数:9,代码来源:WorksiteAnimalFarm.java

示例6: getBreedingItem

import net.minecraft.entity.passive.EntityAnimal; //导入方法依赖的package包/类
public ItemStack getBreedingItem(EntityAnimal animal) {
	for (int i = 0; i < this.inventory.getSizeInventory(); i++) {
		if (ItemStackTools.isValid(this.inventory.getStackInSlot(i))
				&& animal.isBreedingItem(this.inventory.getStackInSlot(i)))
			return this.inventory.getStackInSlot(i).copy();
	}
	return ItemStackTools.getEmptyStack();
}
 
开发者ID:Alec-WAM,项目名称:CrystalMod,代码行数:9,代码来源:WorksiteAnimalFarm.java

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

示例8: getFirstBreedingItem

import net.minecraft.entity.passive.EntityAnimal; //导入方法依赖的package包/类
public ItemStack getFirstBreedingItem(EntityAnimal animal) {
    for (int i = 0; i < inFeedItems.getSlots(); ++i) {
        if (animal.isBreedingItem(inFeedItems.getStackInSlot(i))) return inFeedItems.getStackInSlot(i);
    }
    return ItemStack.EMPTY;
}
 
开发者ID:Buuz135,项目名称:Industrial-Foregoing,代码行数:7,代码来源:AnimalStockIncreaserTile.java

示例9: onBreedingUse

import net.minecraft.entity.passive.EntityAnimal; //导入方法依赖的package包/类
private boolean onBreedingUse( final ItemStack stack, final World world ) {
	final ArrayList animals = getAnimals( world );

	if ( animals == null ) {
		return false;
	}

	int count = 0;


	for ( int i = 0; i < animals.size() && count < 3 && stack.stackSize > 0; i++ ) {
		final EntityAnimal entity = (EntityAnimal) animals.get( i );

		int isBreedingCounter = ReflectionHelper.getPrivateValue(EntityAnimal.class, entity, MCP_BREEDING);
		// skip unbreedable animals
		if (!entity.isBreedingItem(stack) // can't breed with this item
				|| entity.getGrowingAge() != 0 // is juvenile (negative) or recently proceated (positive)
				|| isBreedingCounter != 0 // literally breeding now.
				) {
			continue;}
		triedBreeding = true;

		if ( fairy.getDistanceToEntity( entity ) < 3F ) {
			ReflectionHelper.setPrivateValue(EntityAnimal.class, entity, 600, MCP_INLOVE);			
			count++;
			stack.stackSize--;
		}
	}

	if ( count > 0 ) {
		fairy.armSwing( !fairy.didSwing );
		fairy.setTempItem( stack.getItem() );

		fairy.attackTime = 1;
		fairy.setHearts( !fairy.didHearts );

		if ( fairy.flymode() && fairy.getFlyTime() > 0 ) {
			fairy.setFlyTime( 0 );
		}

		return true;
	}

	return false;
}
 
开发者ID:allaryin,项目名称:FairyFactions,代码行数:46,代码来源:FairyJob.java


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