/** * Gets an ItemStack representing the cursor prior to any modifications * as a result of this drag. * * @return the original cursor */ public ItemStack getOldCursor() { return oldCursor.clone(); }
/** * Gets the item that is being dispensed. Modifying the returned item will * have no effect, you must use {@link * #setItem(org.bukkit.inventory.ItemStack)} instead. * * @return An ItemStack for the item being dispensed */ public ItemStack getItem() { return item.clone(); }
/** * Get the input material. * * @return The input material. */ public ItemStack getInput() { return this.ingredient.clone(); }
/** * Gets the ItemStack being moved; if modified, the original item will not * be removed from the source inventory. * * @return ItemStack */ public ItemStack getItem() { return itemStack.clone(); }
/** * Get the result of this recipe. * * @return The result stack. */ public ItemStack getResult() { return output.clone(); }
/** * Gets the item that is being consumed. Modifying the returned item will * have no effect, you must use {@link * #setItem(org.bukkit.inventory.ItemStack)} instead. * * @return an ItemStack for the item being consumed */ public ItemStack getItem() { return item.clone(); }
/** * Get the result of this recipe. * * @return The resulting stack. */ public ItemStack getResult() { return output.clone(); } }
/** * Get the result. * * @return The result stack. */ public ItemStack getResult() { return output.clone(); } }
@Override public ItemStack ensureServerConversions(ItemStack itemStack) { // TODO: Implementation (1.12.1) return itemStack.clone(); }
@Override public ItemStack getSaddle() { return saddle != null ? saddle.clone() : null; }
/** * Sets the ItemStack being moved; if this is different from the original * ItemStack, the original item will not be removed from the source * inventory. * * @param itemStack The ItemStack */ public void setItem(ItemStack itemStack) { Validate.notNull(itemStack, "ItemStack cannot be null. Cancel the event if you want nothing to be transferred."); this.itemStack = itemStack.clone(); }
/** * Get the list of ingredients used for this recipe. * * @return The input list */ public List<ItemStack> getIngredientList() { ArrayList<ItemStack> result = new ArrayList<ItemStack>(ingredients.size()); for (ItemStack ingredient : ingredients) { result.add(ingredient.clone()); } return result; } }
/** * Get a copy of the ingredients map. * * @return The mapping of character to ingredients. */ public Map<Character, ItemStack> getIngredientMap() { HashMap<Character, ItemStack> result = new HashMap<Character, ItemStack>(); for (Map.Entry<Character, ItemStack> ingredient : ingredients.entrySet()) { if (ingredient.getValue() == null) { result.put(ingredient.getKey(), null); } else { result.put(ingredient.getKey(), ingredient.getValue().clone()); } } return result; }
/** * Update the given slot with the current value from the inventory. * * @param slot The slot to update. */ private void updateItem(int slot) { ItemStack source = getItem(slot); slots[slot] = source == null ? null : source.clone(); }
/** * Update the given slot with the current value from the view. * * @param slot The slot to update. */ private void updateItem(int slot) { // sanitize() used as a last line of defense to prevent client crashes // GlowInventory should generally be able to keep its contents safe ItemStack source = view.getItem(slot); slots[slot] = source == null ? null : ItemIds.sanitize(source.clone()); }
/** * Set the firework item of this firework entity. If an empty ItemStack, or none of the type * {{@link Material#FIREWORK}} was given, a new Firework ItemStack will be created. * * @param item FireWork Item this entity should use */ public void setFireworkItem(ItemStack item) { if (InventoryUtil.isEmpty(item) || !Material.FIREWORK.equals(item.getType())) { item = DEFAULT_FIREWORK_ITEM.clone(); } this.metadata.set(MetadataIndex.FIREWORK_INFO, item.clone()); }
@Override public void setItemStack(ItemStack stack) { // stone is the "default state" for the item stack according to the client metadata.set(MetadataIndex.ITEM_ITEM, stack == null ? new ItemStack(Material.STONE) : stack.clone()); } }
@Override public void setItem(ItemStack is) { is = InventoryUtil.itemOrEmpty(is).clone(); is.setAmount(1); metadata.set(MetadataIndex.ITEM_FRAME_ITEM, is); }
private ItemStack combine(ItemStack slotItem, ItemStack cursor, int amount) { if (InventoryUtil.isEmpty(slotItem)) { ItemStack stack = cursor.clone(); stack.setAmount(amount); return stack; } else if (slotItem.isSimilar(cursor)) { slotItem.setAmount(slotItem.getAmount() + amount); return slotItem; } else { throw new IllegalArgumentException( "Trying to combine dissimilar " + slotItem + " and " + cursor); } }
/** * Get the underlying firework item. * * @return The Firework ItemStack of this Firework entity, or a new Firework ItemStack */ public ItemStack getFireworkItem() { ItemStack item = this.metadata.getItem(MetadataIndex.FIREWORK_INFO); if (InventoryUtil.isEmpty(item) || !Material.FIREWORK.equals(item.getType())) { item = DEFAULT_FIREWORK_ITEM.clone(); } return item; }