org.bukkit.inventory.Inventory.getMaxStackSize()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(1.3k)|赞(0)|评价(0)|浏览(197)

本文整理了Java中org.bukkit.inventory.Inventory.getMaxStackSize()方法的一些代码示例,展示了Inventory.getMaxStackSize()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Inventory.getMaxStackSize()方法的具体详情如下:
包路径:org.bukkit.inventory.Inventory
类名称:Inventory
方法名:getMaxStackSize

Inventory.getMaxStackSize介绍

[英]Returns the maximum stack size for an ItemStack in this inventory.
[中]返回此资源清册中ItemStack的最大堆栈大小。

代码示例

代码示例来源:origin: GlowstoneMC/Glowstone

private int maxStack(Inventory inv, Material mat) {
    return Math.min(inv.getMaxStackSize(), mat.getMaxStackSize());
  }
}

代码示例来源:origin: bergerkiller/BKCommonLib

@Override
public int getMaxStackSize() {
  return base.getMaxStackSize();
}

代码示例来源:origin: bergerkiller/BKCommonLib

@Override
public int getMaxStackSize() {
  return base.getMaxStackSize();
}

代码示例来源:origin: ChestShop-authors/ChestShop-3

/**
 * Checks if the item fits the inventory
 *
 * @param item      Item to check
 * @param inventory inventory
 * @return Does item fit inside inventory?
 */
public static boolean fits(ItemStack item, Inventory inventory) {
  int left = item.getAmount();
  if (inventory.getMaxStackSize() == Integer.MAX_VALUE) {
    return true;
  }
  for (ItemStack iStack : getStorageContents(inventory)) {
    if (left <= 0) {
      return true;
    }
    if (MaterialUtil.isEmpty(iStack)) {
      left -= getMaxStackSize(item);
      continue;
    }
    if (!MaterialUtil.equals(iStack, item)) {
      continue;
    }
    left -= (getMaxStackSize(iStack) - iStack.getAmount());
  }
  return left <= 0;
}

相关文章