本文整理汇总了Java中net.minecraft.item.ItemStack.getMaxStackSize方法的典型用法代码示例。如果您正苦于以下问题:Java ItemStack.getMaxStackSize方法的具体用法?Java ItemStack.getMaxStackSize怎么用?Java ItemStack.getMaxStackSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.item.ItemStack
的用法示例。
在下文中一共展示了ItemStack.getMaxStackSize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: giveItemToPlayer
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
* This function will first try to set the item at the 'heldItem' position if possible.
* Otherwise it will try to find a suitable place elsewhere. If that fails it will spawn
* the item in the world. The stack parameter may be modified
*/
public static void giveItemToPlayer(EntityPlayer player, ItemStack stack) {
ItemStack heldItem = player.getHeldItem(EnumHand.MAIN_HAND);
if (ItemStackTools.isEmpty(heldItem)) {
player.setHeldItem(EnumHand.MAIN_HAND, stack);
player.openContainer.detectAndSendChanges();
return;
} else if (isItemStackConsideredEqual(heldItem, stack)) {
if (ItemStackTools.getStackSize(heldItem) < heldItem.getMaxStackSize()) {
int itemsToAdd = Math.min(ItemStackTools.getStackSize(stack), heldItem.getMaxStackSize() - ItemStackTools.getStackSize(heldItem));
ItemStackTools.incStackSize(heldItem, itemsToAdd);
ItemStackTools.incStackSize(stack, -itemsToAdd);
if (ItemStackTools.isEmpty(stack)) {
player.openContainer.detectAndSendChanges();
return;
}
}
}
// We have items remaining. Add them elsewhere
if (player.inventory.addItemStackToInventory(stack)) {
player.openContainer.detectAndSendChanges();
return;
}
// Spawn in world
spawnItemStack(player.getEntityWorld(), player.getPosition(), stack);
}
示例2: getOutput
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
* Returns the output ItemStack obtained by brewing the passed input and
* ingredient. Null if no matches are found.
*/
public static ItemStack getOutput(ItemStack input, ItemStack ingredient)
{
if (input == null || input.getMaxStackSize() != 1 || input.stackSize != 1) return null;
if (ingredient == null || ingredient.stackSize <= 0) return null;
for (IBrewingRecipe recipe : recipes)
{
ItemStack output = recipe.getOutput(input, ingredient);
if (output != null)
{
return output;
}
}
return null;
}
示例3: canSmelt
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
* Returns true if the furnace can smelt an item, i.e. has a source item, destination stack isn't full, etc.
*/
private boolean canSmelt()
{
if (((ItemStack)this.furnaceItemStacks.get(0)).func_190926_b())
{
return false;
}
else
{
ItemStack itemstack = FurnaceRecipes.instance().getSmeltingResult((ItemStack)this.furnaceItemStacks.get(0));
if (itemstack.func_190926_b())
{
return false;
}
else
{
ItemStack itemstack1 = (ItemStack)this.furnaceItemStacks.get(2);
return itemstack1.func_190926_b() ? true : (!itemstack1.isItemEqual(itemstack) ? false : (itemstack1.func_190916_E() < this.getInventoryStackLimit() && itemstack1.func_190916_E() < itemstack1.getMaxStackSize() ? true : itemstack1.func_190916_E() < itemstack.getMaxStackSize()));
}
}
}
示例4: canAddItemToSlot
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
* Checks if it's possible to add the given itemstack to the given slot.
*/
public static boolean canAddItemToSlot(Slot slotIn, ItemStack stack, boolean stackSizeMatters)
{
boolean flag = slotIn == null || !slotIn.getHasStack();
if (slotIn != null && slotIn.getHasStack() && stack != null && stack.isItemEqual(slotIn.getStack()) && ItemStack.areItemStackTagsEqual(slotIn.getStack(), stack))
{
flag |= slotIn.getStack().stackSize + (stackSizeMatters ? 0 : stack.stackSize) <= stack.getMaxStackSize();
}
return flag;
}
示例5: isInventoryFull
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
* Returns false if the inventory has any room to place items in
*/
private boolean isInventoryFull(IInventory inventoryIn, EnumFacing side)
{
if (inventoryIn instanceof ISidedInventory)
{
ISidedInventory isidedinventory = (ISidedInventory)inventoryIn;
int[] aint = isidedinventory.getSlotsForFace(side);
for (int k = 0; k < aint.length; ++k)
{
ItemStack itemstack1 = isidedinventory.getStackInSlot(aint[k]);
if (itemstack1 == null || itemstack1.stackSize != itemstack1.getMaxStackSize())
{
return false;
}
}
}
else
{
int i = inventoryIn.getSizeInventory();
for (int j = 0; j < i; ++j)
{
ItemStack itemstack = inventoryIn.getStackInSlot(j);
if (itemstack == null || itemstack.stackSize != itemstack.getMaxStackSize())
{
return false;
}
}
}
return true;
}
示例6: isFull
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
private boolean isFull()
{
for (ItemStack itemstack : this.inventory)
{
if (itemstack.func_190926_b() || itemstack.func_190916_E() != itemstack.getMaxStackSize())
{
return false;
}
}
return true;
}
示例7: updateDragSplitting
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
private void updateDragSplitting()
{
ItemStack itemstack = this.mc.thePlayer.inventory.getItemStack();
if (itemstack != null && this.dragSplitting)
{
this.dragSplittingRemnant = itemstack.stackSize;
for (Slot slot : this.dragSplittingSlots)
{
ItemStack itemstack1 = itemstack.copy();
int i = slot.getStack() == null ? 0 : slot.getStack().stackSize;
Container.computeStackSize(this.dragSplittingSlots, this.dragSplittingLimit, itemstack1, i);
if (itemstack1.stackSize > itemstack1.getMaxStackSize())
{
itemstack1.stackSize = itemstack1.getMaxStackSize();
}
if (itemstack1.stackSize > slot.getItemStackLimit(itemstack1))
{
itemstack1.stackSize = slot.getItemStackLimit(itemstack1);
}
this.dragSplittingRemnant -= itemstack1.stackSize - i;
}
}
}
示例8: canSmelt
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
* Returns true if the furnace can smelt an item, i.e. has a source item, destination stack isn't full, etc.
*/
private boolean canSmelt()
{
if (this.furnaceItemStacks[0] == null)
{
return false;
}
else
{
ItemStack itemstack = FurnaceRecipes.instance().getSmeltingResult(this.furnaceItemStacks[0]);
return itemstack == null ? false : (this.furnaceItemStacks[2] == null ? true : (!this.furnaceItemStacks[2].isItemEqual(itemstack) ? false : (this.furnaceItemStacks[2].stackSize < this.getInventoryStackLimit() && this.furnaceItemStacks[2].stackSize < this.furnaceItemStacks[2].getMaxStackSize() ? true : this.furnaceItemStacks[2].stackSize < itemstack.getMaxStackSize())));
}
}
示例9: isFull
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
private boolean isFull()
{
for (ItemStack itemstack : this.inventory)
{
if (itemstack == null || itemstack.stackSize != itemstack.getMaxStackSize())
{
return false;
}
}
return true;
}
示例10: hasRoom
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public boolean hasRoom(Predicate<ItemStack> matcher) {
for (ItemStack stack : inventory) {
if (stack.isEmpty()) {
return true;
}
if (!stack.isEmpty() && matcher.test(stack)) {
if (stack.getCount() < stack.getMaxStackSize()) {
return true;
}
}
}
return false;
}
示例11: isInventoryFull
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
* Returns false if the inventory has any room to place items in
*/
private boolean isInventoryFull(IInventory inventoryIn, EnumFacing side)
{
if (inventoryIn instanceof ISidedInventory)
{
ISidedInventory isidedinventory = (ISidedInventory)inventoryIn;
int[] aint = isidedinventory.getSlotsForFace(side);
for (int k : aint)
{
ItemStack itemstack1 = isidedinventory.getStackInSlot(k);
if (itemstack1 == null || itemstack1.stackSize != itemstack1.getMaxStackSize())
{
return false;
}
}
}
else
{
int i = inventoryIn.getSizeInventory();
for (int j = 0; j < i; ++j)
{
ItemStack itemstack = inventoryIn.getStackInSlot(j);
if (itemstack == null || itemstack.stackSize != itemstack.getMaxStackSize())
{
return false;
}
}
}
return true;
}
示例12: isInventoryFull
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
* Returns false if the inventory has any room to place items in
*/
private boolean isInventoryFull(IInventory inventoryIn, EnumFacing side)
{
if (inventoryIn instanceof ISidedInventory)
{
ISidedInventory isidedinventory = (ISidedInventory)inventoryIn;
int[] aint = isidedinventory.getSlotsForFace(side);
for (int k : aint)
{
ItemStack itemstack1 = isidedinventory.getStackInSlot(k);
if (itemstack1.func_190926_b() || itemstack1.func_190916_E() != itemstack1.getMaxStackSize())
{
return false;
}
}
}
else
{
int i = inventoryIn.getSizeInventory();
for (int j = 0; j < i; ++j)
{
ItemStack itemstack = inventoryIn.getStackInSlot(j);
if (itemstack.func_190926_b() || itemstack.func_190916_E() != itemstack.getMaxStackSize())
{
return false;
}
}
}
return true;
}
示例13: storePartialItemStack
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
* This function stores as many items of an ItemStack as possible in a matching slot and returns the quantity of
* left over items.
*/
private int storePartialItemStack(ItemStack itemStackIn)
{
Item item = itemStackIn.getItem();
int i = itemStackIn.stackSize;
int j = this.storeItemStack(itemStackIn);
if (j == -1)
{
j = this.getFirstEmptyStack();
}
if (j == -1)
{
return i;
}
else
{
ItemStack itemstack = this.getStackInSlot(j);
if (itemstack == null)
{
itemstack = itemStackIn.copy(); // Forge: Replace Item clone above to preserve item capabilities when picking the item up.
itemstack.stackSize = 0;
if (itemStackIn.hasTagCompound())
{
itemstack.setTagCompound(itemStackIn.getTagCompound().copy());
}
this.setInventorySlotContents(j, itemstack);
}
int k = i;
if (i > itemstack.getMaxStackSize() - itemstack.stackSize)
{
k = itemstack.getMaxStackSize() - itemstack.stackSize;
}
if (k > this.getInventoryStackLimit() - itemstack.stackSize)
{
k = this.getInventoryStackLimit() - itemstack.stackSize;
}
if (k == 0)
{
return i;
}
else
{
i = i - k;
itemstack.stackSize += k;
itemstack.animationsToGo = 5;
return i;
}
}
}
示例14: getStackLimit
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
protected int getStackLimit(int slot, ItemStack stack) {
return stack.getMaxStackSize();
}
示例15: canCombine
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
private static boolean canCombine(ItemStack stack1, ItemStack stack2)
{
return stack1.getItem() != stack2.getItem() ? false : (stack1.getMetadata() != stack2.getMetadata() ? false : (stack1.func_190916_E() > stack1.getMaxStackSize() ? false : ItemStack.areItemStackTagsEqual(stack1, stack2)));
}