當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。