本文整理汇总了Java中net.minecraft.inventory.IInventory.getSizeInventory方法的典型用法代码示例。如果您正苦于以下问题:Java IInventory.getSizeInventory方法的具体用法?Java IInventory.getSizeInventory怎么用?Java IInventory.getSizeInventory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.inventory.IInventory
的用法示例。
在下文中一共展示了IInventory.getSizeInventory方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getItemBlockWithInventory
import net.minecraft.inventory.IInventory; //导入方法依赖的package包/类
public ItemStack getItemBlockWithInventory(IInventory inventory, ItemStack stack) {
if (!stack.isEmpty() && stack.getItem() instanceof ItemBlock && inventory != null && inventory.getSizeInventory() > 0) {
if (!stack.hasTagCompound()) {
stack.setTagCompound(new NBTTagCompound());
}
NBTTagCompound stackNBT = stack.getOrCreateSubCompound("BlockEntityTag");
NBTTagList stackList = new NBTTagList();
for (int i = 0; i < inventory.getSizeInventory(); i++) {
if (inventory.getStackInSlot(i).isEmpty()) {
continue;
}
NBTTagCompound slotNBT = new NBTTagCompound();
slotNBT.setByte("Slot", (byte) i);
inventory.getStackInSlot(i).writeToNBT(slotNBT);
stackList.appendTag(slotNBT);
}
stackNBT.setTag("Items", stackList);
stack.setTagInfo("BlockEntityTag", stackNBT);
return stack;
}
return null;
}
示例2: load
import net.minecraft.inventory.IInventory; //导入方法依赖的package包/类
/**
* Load inventory data from NBT tag
* @param inventory Target inventory
* @param tag tag to load
* @param seed Loading seed
*/
private static void load(IInventory inventory, NBTTagCompound tag, long seed) {
if (tag == null || !Configurator.NATIVE_LOOT) {
return;
}
Random random = new Random(seed);
NBTTagList items = tag.getTagList("Items", Constants.NBT.TAG_COMPOUND);
for (int i = 0; i < items.tagCount() && i < inventory.getSizeInventory(); ++i) {
NBTTagCompound stackTag = items.getCompoundTagAt(i);
String itemName = stackTag.getString("id").replaceAll(".*:", "");
itemName = itemName.isEmpty() ? String.valueOf(stackTag.getShort("id")) : itemName;
Pattern iPattern = Pattern.compile(Pattern.quote(itemName), Pattern.CASE_INSENSITIVE);
UItem item = Utils.select(UItems.items.select(iPattern), random.nextLong());
byte count = items.getCompoundTagAt(i).getByte("Count");
int damage = items.getCompoundTagAt(i).getShort("Damage");
int slot = stackTag.hasKey("Slot", Constants.NBT.TAG_BYTE) ? stackTag.getByte("Slot") : i;
slot = (slot < 0 || slot >= inventory.getSizeInventory()) ? i : slot;
if (item != null && count > 0 && UItems.getPossibleMeta(item).contains(damage)) {
inventory.setInventorySlotContents(slot, new UItemStack(item, count, damage).getItemStack());
}
}
}
示例3: moveItemsIntoStack
import net.minecraft.inventory.IInventory; //导入方法依赖的package包/类
private static void moveItemsIntoStack(IInventory chest, ItemStack stack)
{
if (stack.getTagCompound() == null)
{
stack.setTagCompound(new NBTTagCompound());
}
NBTTagList nbtList = new NBTTagList();
for (int i = 0; i < chest.getSizeInventory(); ++i)
{
if (!chest.getStackInSlot(i).isEmpty())
{
NBTTagCompound nbtTabCompound2 = new NBTTagCompound();
nbtTabCompound2.setShort("Slot", (short) i);
chest.getStackInSlot(i).copy().writeToNBT(nbtTabCompound2);
chest.setInventorySlotContents(i, ItemStack.EMPTY);
nbtList.appendTag(nbtTabCompound2);
}
}
stack.getTagCompound().setTag("Items", nbtList);
}
示例4: hasPaymentOrderInMatrix
import net.minecraft.inventory.IInventory; //导入方法依赖的package包/类
private boolean hasPaymentOrderInMatrix(IInventory matrix)
{
int counter = 0;
while (counter < matrix.getSizeInventory())
{
if (matrix.getStackInSlot(counter) != null && matrix.getStackInSlot(counter).getItem() instanceof PaymentOrder)
{
return true; // Found it
}
counter += 1;
}
return false;
}
示例5: getSlotToPushTo
import net.minecraft.inventory.IInventory; //导入方法依赖的package包/类
protected int getSlotToPushTo(IInventory inventory) {
int slot = 0;
for(; slot < inventory.getSizeInventory(); ++slot) {
if(debug) {
FMLLog.log(Level.INFO, "E " + (inventory.getStackInSlot(slot) != null));
if(inventory.getStackInSlot(slot) != null) {
FMLLog.log(Level.INFO, "E " + slot + " " + inventory.getStackInSlot(slot).toString());
FMLLog.log(Level.INFO, "E-true " + (inventory.getStackInSlot(slot) == null));
FMLLog.log(Level.INFO, "E-true " + (inventory.getStackInSlot(slot).getItem() == blockItemStack.getItem()));
FMLLog.log(Level.INFO, "E-true " + (inventory.getStackInSlot(slot).getItemDamage() == blockItemStack.getItemDamage()));
FMLLog.log(Level.INFO, "E-true " + inventory.getStackInSlot(slot).stackSize + " < " + inventory.getStackInSlot(slot).getItem().getItemStackLimit(inventory.getStackInSlot(slot)));
}
}
if(inventory.getStackInSlot(slot) == null || inventory.getStackInSlot(slot).getItem() == blockItemStack.getItem() && inventory.getStackInSlot(slot).getItemDamage() == blockItemStack.getItemDamage()
&& inventory.getStackInSlot(slot).stackSize < inventory.getStackInSlot(slot).getItem().getItemStackLimit(inventory.getStackInSlot(slot)))
break;
}
if(slot > inventory.getSizeInventory() - 1)
slot = inventory.getSizeInventory() - 1;
if(debug)
FMLLog.log(Level.INFO, "E" + slot);
return slot;
}
示例6: handleItem
import net.minecraft.inventory.IInventory; //导入方法依赖的package包/类
private static void handleItem(EntityPlayer entityPlayer, IInventory inventory, Item[] items)
{
for (int index = 0; index < inventory.getSizeInventory(); index++)
{
if (inventory.getStackInSlot(index) == null)
continue;
for (int itemIndex = 0; itemIndex < items.length; itemIndex++)
{
damageItem(entityPlayer, inventory, index, items[itemIndex]);
}
}
}
示例7: countSlotsNotEmpty
import net.minecraft.inventory.IInventory; //导入方法依赖的package包/类
private static int countSlotsNotEmpty(IInventory inventory)
{
int result = 0;
for (int i = 0; i < inventory.getSizeInventory(); i++)
{
if (!inventory.getStackInSlot(i).isEmpty()) result++;
}
return result;
}
示例8: matches
import net.minecraft.inventory.IInventory; //导入方法依赖的package包/类
@Override
public boolean matches(IInventory inv) {
if (inv.getSizeInventory()<9) return false;
for(int i=0; i<9; i++) {
if (ingredients[i]==null) {
if (!inv.getStackInSlot(i).isEmpty()) return false;
} else {
if (!OreItems.matches(ingredients[i], inv.getStackInSlot(i))) return false;
}
}
return true;
}
示例9: isInventoryEmpty
import net.minecraft.inventory.IInventory; //导入方法依赖的package包/类
/**
* Returns false if the specified IInventory contains any items
*/
private static boolean isInventoryEmpty(IInventory inventoryIn, EnumFacing side)
{
if (inventoryIn instanceof ISidedInventory)
{
ISidedInventory isidedinventory = (ISidedInventory)inventoryIn;
int[] aint = isidedinventory.getSlotsForFace(side);
for (int i = 0; i < aint.length; ++i)
{
if (isidedinventory.getStackInSlot(aint[i]) != null)
{
return false;
}
}
}
else
{
int j = inventoryIn.getSizeInventory();
for (int k = 0; k < j; ++k)
{
if (inventoryIn.getStackInSlot(k) != null)
{
return false;
}
}
}
return true;
}
示例10: putStackInInventoryAllSlots
import net.minecraft.inventory.IInventory; //导入方法依赖的package包/类
/**
* Attempts to place the passed stack in the inventory, using as many slots as required. Returns leftover items
*/
public static ItemStack putStackInInventoryAllSlots(IInventory inventoryIn, ItemStack stack, EnumFacing side)
{
if (inventoryIn instanceof ISidedInventory && side != null)
{
ISidedInventory isidedinventory = (ISidedInventory)inventoryIn;
int[] aint = isidedinventory.getSlotsForFace(side);
for (int k = 0; k < aint.length && stack != null && stack.stackSize > 0; ++k)
{
stack = insertStack(inventoryIn, stack, aint[k], side);
}
}
else
{
int i = inventoryIn.getSizeInventory();
for (int j = 0; j < i && stack != null && stack.stackSize > 0; ++j)
{
stack = insertStack(inventoryIn, stack, j, side);
}
}
if (stack != null && stack.stackSize == 0)
{
stack = null;
}
return stack;
}
示例11: GuiChest
import net.minecraft.inventory.IInventory; //导入方法依赖的package包/类
public GuiChest(IInventory upperInv, IInventory lowerInv)
{
super(new ContainerChest(upperInv, lowerInv, Minecraft.getMinecraft().thePlayer));
this.upperChestInventory = upperInv;
this.lowerChestInventory = lowerInv;
this.allowUserInput = false;
int i = 222;
int j = i - 108;
this.inventoryRows = lowerInv.getSizeInventory() / 9;
this.ySize = j + this.inventoryRows * 18;
}
示例12: isInventoryEmpty
import net.minecraft.inventory.IInventory; //导入方法依赖的package包/类
/**
* Returns false if the specified IInventory contains any items
*/
private static boolean isInventoryEmpty(IInventory inventoryIn, EnumFacing side)
{
if (inventoryIn instanceof ISidedInventory)
{
ISidedInventory isidedinventory = (ISidedInventory)inventoryIn;
int[] aint = isidedinventory.getSlotsForFace(side);
for (int i : aint)
{
if (!isidedinventory.getStackInSlot(i).func_190926_b())
{
return false;
}
}
}
else
{
int j = inventoryIn.getSizeInventory();
for (int k = 0; k < j; ++k)
{
if (!inventoryIn.getStackInSlot(k).func_190926_b())
{
return false;
}
}
}
return true;
}
示例13: isInventoryEmpty
import net.minecraft.inventory.IInventory; //导入方法依赖的package包/类
/**
* Returns false if the specified IInventory contains any items
*/
private static boolean isInventoryEmpty(IInventory inventoryIn, EnumFacing side)
{
if (inventoryIn instanceof ISidedInventory)
{
ISidedInventory isidedinventory = (ISidedInventory)inventoryIn;
int[] aint = isidedinventory.getSlotsForFace(side);
for (int i : aint)
{
if (isidedinventory.getStackInSlot(i) != null)
{
return false;
}
}
}
else
{
int j = inventoryIn.getSizeInventory();
for (int k = 0; k < j; ++k)
{
if (inventoryIn.getStackInSlot(k) != null)
{
return false;
}
}
}
return true;
}
示例14: captureDroppedItems
import net.minecraft.inventory.IInventory; //导入方法依赖的package包/类
public static boolean captureDroppedItems(IHopper p_145891_0_)
{
IInventory iinventory = getHopperInventory(p_145891_0_);
if (iinventory != null)
{
EnumFacing enumfacing = EnumFacing.DOWN;
if (isInventoryEmpty(iinventory, enumfacing))
{
return false;
}
if (iinventory instanceof ISidedInventory)
{
ISidedInventory isidedinventory = (ISidedInventory)iinventory;
int[] aint = isidedinventory.getSlotsForFace(enumfacing);
for (int i = 0; i < aint.length; ++i)
{
if (pullItemFromSlot(p_145891_0_, iinventory, aint[i], enumfacing))
{
return true;
}
}
}
else
{
int j = iinventory.getSizeInventory();
for (int k = 0; k < j; ++k)
{
if (pullItemFromSlot(p_145891_0_, iinventory, k, enumfacing))
{
return true;
}
}
}
}
else
{
for (EntityItem entityitem : func_181556_a(p_145891_0_.getWorld(), p_145891_0_.getXPos(), p_145891_0_.getYPos() + 1.0D, p_145891_0_.getZPos()))
{
if (putDropInInventoryAllSlots(p_145891_0_, entityitem))
{
return true;
}
}
}
return false;
}