/** * Adds the specified ingredient. * * @param ingredient The ingredient to add. * @return The changed recipe, so you can chain calls. */ public ShapelessRecipe addIngredient(MaterialData ingredient) { return addIngredient(1, ingredient); }
for (ItemStack ingredient : recipe.getIngredientList()) { for (int i = 0; i < items.length; ++i) {
/** * Removes multiple instances of an ingredient from the list. If there are * less instances then specified, all will be removed. Only removes exact * matches, with a data value of 0. * * @param count The number of copies to remove. * @param ingredient The ingredient to remove * @return The changed recipe. */ public ShapelessRecipe removeIngredient(int count, Material ingredient) { return removeIngredient(count, ingredient, 0); }
ShapelessRecipe r = new ShapelessRecipe(key, is); for (String i : ingredients) { String[] recipe_idata = i.split(":"); Material m = Material.valueOf(recipe_idata[0]); r.addIngredient(m); r.setGroup("Jelly Babies");
ItemStack.deserialize((Map<String, Object>) data.get("result")); // NON-NLS NamespacedKey key = readKey(data, resultStack); ShapelessRecipe recipe = new ShapelessRecipe(key, resultStack); recipe.addIngredient(ItemStack.deserialize(entry).getData());
private void showShapelessRecipe(Player player, String str) { ShapelessRecipe recipe = plugin.getIncomposita().getShapelessRecipes().get(str); List<ItemStack> ingredients = recipe.getIngredientList(); plugin.getTrackerKeeper().getRecipeView().add(player.getUniqueId()); Inventory inv = plugin.getServer().createInventory(player, 27, ChatColor.DARK_RED + "" + str + " recipe"); int mapCount = 0; for (int i = 0; i < ingredients.size(); i++) { ItemMeta im = ingredients.get(i).getItemMeta(); if (ingredients.get(i).getType().equals(Material.FILLED_MAP)) { im.setDisplayName(getDisplayName(str, mapCount)); mapCount++; } if (ingredients.get(i).getType().equals(Material.MUSIC_DISC_STRAD)) { im.setDisplayName("Blank Storage Disk"); } ingredients.get(i).setItemMeta(im); inv.setItem(i * 9, ingredients.get(i)); } ItemStack result = recipe.getResult(); ItemMeta im = result.getItemMeta(); im.setDisplayName(str); if (str.equals("Save Storage Disk") || str.equals("Preset Storage Disk") || str.equals("Biome Storage Disk") || str.equals("Player Storage Disk") || str.equals("Sonic Blaster")) { im.addItemFlags(ItemFlag.values()); } result.setAmount(1); result.setItemMeta(im); inv.setItem(17, result); player.openInventory(inv); }
@Override public MCRecipe GetNewRecipe(String key, MCRecipeType type, MCItemStack result) { ItemStack is = ((BukkitMCItemStack) result).asItemStack(); if(type == MCRecipeType.MERCHANT) { return new BukkitMCMerchantRecipe(new MerchantRecipe(is, Integer.MAX_VALUE)); } NamespacedKey nskey = new NamespacedKey(CommandHelperPlugin.self, key); switch(type) { case FURNACE: return new BukkitMCFurnaceRecipe(new FurnaceRecipe(nskey, is, Material.AIR, 0.0F, 200)); case SHAPED: return new BukkitMCShapedRecipe(new ShapedRecipe(nskey, is)); case SHAPELESS: return new BukkitMCShapelessRecipe(new ShapelessRecipe(nskey, is)); } return null; }
@Override public MCItemStack getResult() { return new BukkitMCItemStack(r.getResult()); }
/** * Look up a recipe. * * @param key the key to look up * @return the recipe with the given key, or null if none match */ public Recipe getRecipeByKey(NamespacedKey key) { // FIXME: Linear time; use Map<NamespacedKey,?> instances instead for (ShapedRecipe shapedRecipe : shapedRecipes) { if (shapedRecipe.getKey().equals(key)) { return shapedRecipe; } } for (ShapelessRecipe shapelessRecipe : shapelessRecipes) { if (shapelessRecipe.getKey().equals(key)) { return shapelessRecipe; } } return null; }
public static ShapelessRecipe getChimaeraWingRecipe() { Material ingredient = Config.getInstance().getChimaeraItem(); int amount = Config.getInstance().getChimaeraRecipeCost(); ShapelessRecipe chimeraWing = new ShapelessRecipe(new NamespacedKey(mcMMO.p, "Chimera"), getChimaeraWing(1)); chimeraWing.addIngredient(amount, ingredient); return chimeraWing; } }
private void giveItem(String item, Player player) { ItemStack result; if (plugin.getIncomposita().getShapelessRecipes().containsKey(item)) { ShapelessRecipe recipe = plugin.getIncomposita().getShapelessRecipes().get(item); result = recipe.getResult(); } else { ShapedRecipe recipe = plugin.getFigura().getShapedRecipes().get(item); result = recipe.getResult(); } result.setAmount(1); player.getInventory().addItem(result); player.updateInventory(); }
@Override public String getKey() { return r.getKey().getKey(); }
/** * Adds the specified ingredient. * * @param ingredient The ingredient to add. * @return The changed recipe, so you can chain calls. */ public ShapelessRecipe addIngredient(Material ingredient) { return addIngredient(1, ingredient, 0); }
@Override public List<MCItemStack> getIngredients() { List<MCItemStack> ret = new ArrayList<>(); for(ItemStack is : r.getIngredientList()) { ret.add(new BukkitMCItemStack(is)); } return ret; }
/** * Removes an ingredient from the list. If the ingredient occurs multiple * times, only one instance of it is removed. Only removes exact matches, * with a data value of 0. * * @param ingredient The ingredient to remove * @return The changed recipe. */ public ShapelessRecipe removeIngredient(Material ingredient) { return removeIngredient(ingredient, 0); }
if (item.equals("save-disk") || item.equals("preset-disk") || item.equals("biome-disk") || item.equals("player-disk") || item.equals("custard") || item.equals("jelly-baby") || item.equals("wand")) { ShapelessRecipe recipe = plugin.getIncomposita().getShapelessRecipes().get(item_to_give); result = recipe.getResult(); } else { ShapedRecipe recipe = plugin.getFigura().getShapedRecipes().get(item_to_give);
/** * Adds multiples of the specified ingredient. * * @param count How many to add (can't be more than 9!) * @param ingredient The ingredient to add. * @return The changed recipe, so you can chain calls. */ public ShapelessRecipe addIngredient(int count, Material ingredient) { return addIngredient(count, ingredient, 0); }
for (ItemStack ingredient : ((ShapelessRecipe) recipe).getIngredientList()) { if (ingredient != null && (repairMaterial == null || ingredient.getType() == repairMaterial) && (repairMetadata == -1 || ingredient.getType().equals(repairMaterial))) { quantity += ingredient.getAmount();
/** * Removes an ingredient from the list. If the ingredient occurs multiple * times, only one instance of it is removed. If the data value is -1, * only ingredients with a -1 data value will be removed. * * @param ingredient The ingredient to remove * @param rawdata The data value; * @return The changed recipe. * @deprecated Magic value */ @Deprecated public ShapelessRecipe removeIngredient(Material ingredient, int rawdata) { return removeIngredient(1, ingredient, rawdata); }
/** * Adds the specified ingredient. * * @param ingredient The ingredient to add. * @param rawdata The data value, or -1 to allow any data value. * @return The changed recipe, so you can chain calls. * @deprecated Magic value */ @Deprecated public ShapelessRecipe addIngredient(Material ingredient, int rawdata) { return addIngredient(1, ingredient, rawdata); }