Creating custom recipe

Discussion in 'Plugin Development' started by mateuszhp, Jan 6, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    mateuszhp

    Hi, i want create custom recipe.
    Code:java
    1. ItemStack marmur = new ItemStack(Material.SMOOTH_BRICK, 1, (short)3);
    2. ItemMeta marmurmeta = marmur.getItemMeta();
    3. marmurmeta.setDisplayName(ChatColor.GRAY + "" + ChatColor.BOLD + "Marmur");
    4. marmur.setItemMeta(marmurmeta);
    5. marmur.addUnsafeEnchantment(Enchantment.THORNS, 10);
    6. ShapedRecipe recipe1 = new ShapedRecipe(marmur);
    7. recipe1.shape("SSS", "SSS", "SSS");
    8. recipe1.setIngredient('S', Material.COBBLESTONE, 64);
    9.  
    10. Bukkit.getServer().addRecipe(recipe);

    This is my code, but it don't works good :/

    I want to create recipe from which 9x64 Cobble Stone get one Smooth brick:3. Code at up, creating 9x64 Cobble Stone = 64xStoneBrick:3, but its not good :/
     
  2. Offline

    Xephiro

    You can't make a recipe of 9x64 Cobble Stone

    The parameters of setIngredient are
    • A character to represent the ingredient
    • The material
    • The raw material data as an integer. Not the amount.
    You cant use this
    Code:java
    1. ItemStack is = new ItemStack(Material.SMOOTH_BRICK);
    2. is.setAmount(3);
    3. ShapedRecipe recipe = new ShapedRecipe(is);
    4. recipe.shape("SSS", "SSS", "SSS");
    5. recipe.setIngredient('S', Material.COBBLESTONE);
     
  3. Offline

    DevVersion

    Code:java
    1. ItemStack item1 = new ItemStack(Material.DIAMOND_SWORD);
    2. ItemMeta meta1 = item1.getItemMeta();
    3. meta1.setDisplayName("§6§oFiresword");
    4. meta1.addEnchant(Enchantment.FIRE_ASPECT, 1, false);
    5. item1.setItemMeta(meta1);
    6. ShapedRecipe recipe1 = new ShapedRecipe(item1);
    7. recipe1.shape("OBX","OXB","SOO");
    8. recipe1.setIngredient('X', Material.DIAMOND);
    9. recipe1.setIngredient('S', Material.STICK);
    10. recipe1.setIngredient('B', Material.BLAZE_POWDER);
    11. Bukkit.addRecipe(recipe1);
     
  4. Offline

    mateuszhp

  5. Offline

    Xephiro

    mateuszhp

    Please explain more about please. :D
     
  6. Offline

    mateuszhp

    Currently SMOOTH_BRICK be executed even if there is no 9x64 Cobblestone in crafting, I want this crafting performed only if it is 9x64 in crafting. "You can not make a recipe of 9x64 Cobble Stone" on several servers I've seen ...
     
Thread Status:
Not open for further replies.

Share This Page