private int maxStack(Inventory inv, Material mat) { return Math.min(inv.getMaxStackSize(), mat.getMaxStackSize()); } }
/** * Assign a Material to this ItemType (for internal use only). * * @param material The internal material for this item. */ public final void setMaterial(Material material) { if (this.material != null && id != -1) { throw new IllegalStateException("Material is already set in " + this); } Preconditions.checkNotNull(material); this.material = material; id = material.getId(); maxStackSize = material.getMaxStackSize(); }
/** * Get the maximum stacksize for the material hold in this ItemStack. * (Returns -1 if it has no idea) * * @return The maximum you can stack this material to. */ @Utility public int getMaxStackSize() { Material material = getType(); if (material != null) { return material.getMaxStackSize(); } return -1; }
int maxStackSize = item.getType() == null ? 64 : item.getType().getMaxStackSize(); int toAdd = item.getAmount();
slotItem.getType().getMaxStackSize() - slotItem.getAmount()); if (transfer == 0) { return InventoryAction.NOTHING; if (slotItem.getAmount() + 1 <= slotItem.getType().getMaxStackSize()) { return InventoryAction.PLACE_ONE;
stack.setAmount(stack.getType().getMaxStackSize()); player.setItemOnCursor(stack); break;
@Override public int getMaxStackSize() { return m.getMaxStackSize(); }
/** * Get the maximum stacksize for the material hold in this ItemStack. * (Returns -1 if it has no idea) * * @return The maximum you can stack this material to. */ @Utility public int getMaxStackSize() { Material material = getType(); if (material != null) { return material.getMaxStackSize(); } return -1; }
/** * Expand a stack of items. * * @param item * @param infinite */ public static void expandStack(ItemStack item, boolean infinite, boolean overrideStackSize) { if (item == null || item.getAmount() == 0 || item.getTypeId() <= 0) { return; } int stackSize = overrideStackSize ? 64 : item.getType().getMaxStackSize(); if (item.getType().getMaxStackSize() == 1) { return; } if (infinite) { item.setAmount(-1); } else if (item.getAmount() < stackSize){ item.setAmount(stackSize); } }
return null; else if (SlimefunManager.isItemSimiliar(new CustomItem(is, 1), new CustomItem(stack, 1), true, DataType.ALWAYS) && is.getAmount() < is.getType().getMaxStackSize()) { int amount = is.getAmount() + stack.getAmount(); if (amount > is.getType().getMaxStackSize()) { is.setAmount(is.getType().getMaxStackSize()); stack.setAmount(amount - is.getType().getMaxStackSize()); return null; else if (SlimefunManager.isItemSimiliar(new CustomItem(is, 1), new CustomItem(stack, 1), true, DataType.ALWAYS) && is.getAmount() < is.getType().getMaxStackSize()) { int amount = is.getAmount() + stack.getAmount(); if (amount > is.getType().getMaxStackSize()) { is.setAmount(is.getType().getMaxStackSize()); stack.setAmount(amount - is.getType().getMaxStackSize()); return null; else if (SlimefunManager.isItemSimiliar(new CustomItem(is, 1), new CustomItem(stack, 1), true, DataType.ALWAYS) && is.getAmount() < is.getType().getMaxStackSize()) { ItemStack prev = is.clone(); int amount = is.getAmount() + stack.getAmount(); if (amount > is.getType().getMaxStackSize()) { is.setAmount(is.getType().getMaxStackSize()); stack.setAmount(amount - is.getType().getMaxStackSize());
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onSmelt(FurnaceSmeltEvent e) { if (BlockStorage.check(e.getBlock()) != null && BlockStorage.check(e.getBlock()) instanceof EnhancedFurnace) { EnhancedFurnace furnace = (EnhancedFurnace) BlockStorage.check(e.getBlock()); Furnace f = (Furnace) e.getBlock().getState(); int amount = f.getInventory().getSmelting().getType().toString().endsWith("_ORE") ? furnace.getOutput(): 1; ItemStack output = RecipeCalculator.getSmeltedOutput(f.getInventory().getSmelting().getType()); ItemStack result = f.getInventory().getResult(); if (result != null) result = result.clone(); f.getInventory().setResult(null); if (result != null) f.getInventory().setResult(new CustomItem(result, result.getAmount() + amount > result.getMaxStackSize() ? result.getMaxStackSize(): result.getAmount() + amount)); else f.getInventory().setResult(new CustomItem(output, output.getAmount() + amount > output.getType().getMaxStackSize() ? output.getType().getMaxStackSize(): output.getAmount() + amount)); } }
int maxSize = newItem.getType().getMaxStackSize(); if (amount > maxSize) { if (maxSize == 0) {
private static boolean transferOneItem(InventoryView view, int fromSlot) { ItemStack from = view.getItem(fromSlot).clone(); ItemStack to = view.getItem(Alchemy.INGREDIENT_SLOT).clone(); if (isEmpty(from)) { return false; } boolean emptyTo = isEmpty(to); int fromAmount = from.getAmount(); if (!emptyTo && fromAmount >= from.getType().getMaxStackSize()) { return false; } else if (emptyTo || from.isSimilar(to)) { if (emptyTo) { to = from.clone(); to.setAmount(1); } else { to.setAmount(to.getAmount() + 1); } from.setAmount(fromAmount - 1); view.setItem(Alchemy.INGREDIENT_SLOT, to); view.setItem(fromSlot, from); return true; } return false; }
int maxStackSize = overrideStackSize ? 64 : item.getType().getMaxStackSize();
int fromAmount = from.getAmount(); int toAmount = to.getAmount(); int maxSize = to.getType().getMaxStackSize();
int rest = item.getType().getMaxStackSize() - BlockStorage.getInventory(b).getItemInSlot(43).getAmount(); if (rest > 0) { int amt = item.getAmount() > rest ? rest: item.getAmount();