Adding Shapeless Crafting Recipes

Discussion in 'Plugin Development' started by dingus007, Oct 2, 2013.

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

    dingus007

    I'm making a plugin where you can use the 4x4 player inventory crafting square to make items you could normally make in a furnace. I am registering the commands using a function I made to save on how fast I could write it. It doesn't seem to work and I couldn't find much help on bukkit.org. I'm pretty sure my plugin.yml is fine because my plugin set up just fine, it just isn't adding the recipes.

    Code:java
    1. package net.conectedpvp.craftablesmelting;
    2.  
    3. import org.bukkit.ChatColor;
    4. import org.bukkit.Material;
    5. import org.bukkit.inventory.ItemStack;
    6. import org.bukkit.inventory.ShapelessRecipe;
    7. import org.bukkit.plugin.java.JavaPlugin;
    8.  
    9. public class CraftableSmelting extends JavaPlugin {
    10.  
    11.  
    12. public void addSRecipe(Material ironIngot,Material coal, Material ironOre ){
    13. ShapelessRecipe rec = new ShapelessRecipe(new ItemStack(ironIngot));
    14. rec.addIngredient(coal);
    15. rec.addIngredient(ironOre);
    16. getServer().addRecipe(rec);
    17. }
    18. public String format(String msg) {
    19. return ChatColor.GOLD + "[CraftableSmelting] " + ChatColor.WHITE + msg;
    20. }
    21.  
    22. public void console(String msg) {
    23. getLogger().info(msg);
    24. }
    25. //onEnable and onDisable
    26. public void onEnable() {
    27. console(format("Activating CraftableSmelting v1.0"));
    28. addSRecipe(Material.IRON_INGOT,Material.COAL,Material.IRON_ORE);
    29. addSRecipe(Material.GOLD_INGOT,Material.COAL,Material.GOLD_ORE);
    30. addSRecipe(Material.STONE,Material.COAL,Material.COBBLESTONE);
    31. addSRecipe(Material.SAND,Material.COAL,Material.GLASS);
    32. addSRecipe(Material.CLAY_BALL,Material.COAL,Material.CLAY);
    33. addSRecipe(Material.PORK,Material.COAL,Material.GRILLED_PORK);
    34. addSRecipe(Material.RAW_BEEF,Material.COAL,Material.COOKED_BEEF);
    35. addSRecipe(Material.RAW_CHICKEN,Material.COAL,Material.COOKED_CHICKEN);
    36. addSRecipe(Material.RAW_FISH,Material.COAL,Material.COOKED_FISH);
    37. addSRecipe(Material.POTATO,Material.COAL,Material.BAKED_POTATO);
    38. addSRecipe(Material.WOOD,Material.COAL,Material.COAL);
    39. addSRecipe(Material.NETHERRACK,Material.COAL,Material.NETHER_BRICK_ITEM);
    40. addSRecipe(Material.CLAY_BRICK,Material.COAL,Material.HARD_CLAY);
    41. console(format("Added 13 smeltable crafting recipies"));
    42.  
    43. }
    44. public void onDisable() {
    45. console(format("Deactivating CraftableSmelting v1.0"));
    46. }
    47. }
    48.  


    Anyone going to help?

    Why you people ignore me?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 4, 2016
  2. Offline

    1Achmed1

  3. Offline

    Henzz

    dingus007
    I believe this is the format of creating shapeless recipes.
    PHP:
    ItemStack saddle = new ItemStack(Material.SADDLE1);
    ShapedRecipe saddlerecipe = new ShapedRecipe(saddle);
    saddlerecipe.shape("LLL""LIL""I I");
    saddlerecipe.setIngredient('L'Material.LEATHER);
    saddlerecipe.setIngredient('I'Material.IRON_INGOT);
    Bukkit.addRecipe(saddlerecipe);
     
  4. Offline

    viper_monster

    Henzz, that is for ShapedRecipes, and he is looking for ShapelessRecipes.
    Here is the code I'm using in one of my public plugins:
    Code:java
    1.  
    2. ItemStack is = new ItemStack(Material.MUSHROOM_SOUP, 1);
    3. ShapelessRecipe sr= new ShapelessRecipe(is);
    4. sr.addIngredient(1, Material.BOWL);
    5. sr.addIngredient(2, Material.CACTUS);
    6. Bukkit.addRecipe(sr);
    7.  


    dingus007 ^

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 4, 2016
  5. Offline

    Henzz

    spoljo666 likes this.
  6. Offline

    dingus007

    Forgot to say that I figured it out. I had mixed up the ingredients in their order. I also had to add @Override to onEnable and onDisable.
     
Thread Status:
Not open for further replies.

Share This Page