本文整理匯總了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;
}
示例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);
}
示例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);
}