本文整理汇总了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);
}