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


Java IInventory.isItemValidForSlot方法代碼示例

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


在下文中一共展示了IInventory.isItemValidForSlot方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testInventoryInsertion

import net.minecraft.inventory.IInventory; //導入方法依賴的package包/類
public int testInventoryInsertion(IInventory inventory, ItemStack item) {
	if (item.isEmpty() || item.getCount() == 0) {
		return 0;
	}
	if (inventory == null) {
		return 0;
	}
	int slotCount = inventory.getSizeInventory();
	int itemSizeCounter = item.getCount();
	for (int i = 0; i < slotCount && itemSizeCounter > 0; i++) {

		if (!inventory.isItemValidForSlot(i, item)) {
			continue;
		}
		ItemStack inventorySlot = inventory.getStackInSlot(i);
		if (inventorySlot.isEmpty()) {
			itemSizeCounter -= Math.min(Math.min(itemSizeCounter, inventory.getInventoryStackLimit()), item.getMaxStackSize());
		}
		else if (areMergeCandidates(item, inventorySlot)) {

			int space = inventorySlot.getMaxStackSize() - inventorySlot.getCount();
			itemSizeCounter -= Math.min(itemSizeCounter, space);
		}
	}
	if (itemSizeCounter != item.getCount()) {
		itemSizeCounter = Math.max(itemSizeCounter, 0);
		return item.getCount() - itemSizeCounter;
	}
	return 0;
}
 
開發者ID:p455w0rd,項目名稱:EndermanEvolution,代碼行數:31,代碼來源:EntityFrienderman.java

示例2: canInsertItemInSlot

import net.minecraft.inventory.IInventory; //導入方法依賴的package包/類
/**
 * Can this hopper insert the specified item from the specified slot on the specified side?
 */
private static boolean canInsertItemInSlot(IInventory inventoryIn, ItemStack stack, int index, EnumFacing side)
{
    return !inventoryIn.isItemValidForSlot(index, stack) ? false : !(inventoryIn instanceof ISidedInventory) || ((ISidedInventory)inventoryIn).canInsertItem(index, stack, side);
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:8,代碼來源:TileEntityHopper.java

示例3: canInsertItemInSlot

import net.minecraft.inventory.IInventory; //導入方法依賴的package包/類
private static boolean canInsertItemInSlot(IInventory inventoryIn, ItemStack stack, int index, EnumFacing side) {
	return !inventoryIn.isItemValidForSlot(index, stack) ? false : !(inventoryIn instanceof ISidedInventory) || ((ISidedInventory) inventoryIn).canInsertItem(index, stack, side);
}
 
開發者ID:p455w0rd,項目名稱:EndermanEvolution,代碼行數:4,代碼來源:FriendermanUtils.java


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