Custom Crafting Recipe

Discussion in 'Plugin Development' started by inventorman101, Jul 11, 2013.

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

    inventorman101

    I was just asking about how to make the sum of the crafting to have a custom display name and lore
    I have a method that applies the name and lore, but I can't figure out how to add it into the ShapedCrafting object.

    Code:java
    1.  
    2. @Override
    3. public void onEnable()
    4. {
    5. getServer().getPluginManager().registerEvents(new EventListener(), this);
    6. PluginDescriptionFile pdfFile = this.getDescription();
    7. logger.info(pdfFile.getName()+ " Version " + pdfFile.getVersion()+ " Has Been Enabled!");
    8.  
    9. ItemStack weapon = new ItemStack(Material.BLAZE_ROD, 1);
    10. setWeaponName(weapon,"Blaze Infuser Rod", "Smelt your ores with this tool");
    11. ShapedRecipe blazeinfuser = new ShapedRecipe(ItemStack(weapon, 1)).shape("!","@","#").setIngredient('!', Material.FIREWORK_CHARGE).setIngredient('@', Material.BLAZE_ROD).setIngredient('#', Material.FURNACE);
    12. getServer().addRecipe(blazeinfuser);
    13. }
    14.  
     
  2. Offline

    ERROR372

    inventorman101

    This is how I did it so a saddle is craftable:

    Code:java
    1. final ShapedRecipe saddle = new ShapedRecipe(new ItemStack(Material.SADDLE, 1));
    2. saddle.shape("A A", "AAA", " B ");
    3. saddle.setIngredient('A', Material.LEATHER);
    4. saddle.setIngredient('B', Material.IRON_INGOT);
    5. getServer().addRecipe(saddle);
    6. saveSettings();


    Hope that helps.
     
  3. Offline

    inventorman101

    Actually I need it to have a custom item one that has custom ItemMeta, I already know how to make a plain item. I need it to have a custom ItemStack
     
  4. Offline

    Levi2241

    If I'm right, you don't add the name and lore to the Shaped Crafting, you add it to the item itself. Don't know the method off the top of my head. I would guess you would edit the ItemMeta of the weapon item.
     
  5. Offline

    inventorman101

    Levi2241
    Would I add it after the item is crafted or what?
     
  6. Offline

    ZeusAllMighty11

    Just pass your custom itemstack into the recipe parameters​
     
  7. Offline

    Levi2241

    Any time after the item is initialized. The plugin will craft the item with the name and lore set, since you are telling it that is the item you want crafted.
     
  8. Offline

    inventorman101

    It doesn't even craft :(
    Levi2241 TheGreenGamerHD
    Code:java
    1.  
    2. @Override
    3. public void onDisable()
    4. {
    5. PluginDescriptionFile pdfFile = this.getDescription();
    6. logger.info(pdfFile.getName() + " Has Been Disabled!");
    7. }
    8.  
    9. @Override
    10. public void onEnable()
    11. {
    12. getServer().getPluginManager().registerEvents(new EventListener(), this);
    13. PluginDescriptionFile pdfFile = this.getDescription();
    14. logger.info(pdfFile.getName()+ " Version " + pdfFile.getVersion()+ " Has Been Enabled!");
    15.  
    16. ItemStack item = new ItemStack(Material.BLAZE_ROD); // Create Blaze Infuser Rod
    17. ItemMeta meta = item.getItemMeta();
    18. meta.setDisplayName(ChatColor.GOLD + "Blaze Infuser Rod"); // Set Display Name
    19. List<String> lore = new ArrayList<String>();
    20. lore.add("Smelt your ores with this tool"); // Add lore
    21. meta.setLore(lore);
    22. item.setItemMeta(meta);
    23. ShapedRecipe blazeinfuser = new ShapedRecipe(item);
    24. blazeinfuser.shape("!","@","#");
    25. blazeinfuser.setIngredient('!', Material.FIREWORK_CHARGE);
    26. blazeinfuser.setIngredient('@', Material.BLAZE_ROD);
    27. blazeinfuser.setIngredient('#', Material.FURNACE);
    28. getServer().addRecipe(blazeinfuser);
    29. }
    30.  
     
  9. Offline

    travja

    inventorman101 All looks fine to me... I would add some console output for debug to see if it gets all the way. Also.. what are you putting in the crafting table?
     
  10. Offline

    ZeusAllMighty11

    Use letters instead of those whacky symbols
     
  11. Offline

    Levi2241

    Just thought of something after reading travja 's post. The firework charge may be the one that has no color or special effect, which, if I'm right, is only able to get in the Creative inventory. I think the firework charge has different subtypes, doesn't it? Or does Material.FIREWORK_CHARGE cover all of those?
     
  12. Offline

    travja

    Levi2241 You're probably right, I ran into this problem while making a custom crafting recipe for sheep eggs which needed to accept all wool types. Use the .setIngredient() method and make the data value -1 that should cover all data types.
     
  13. Offline

    inventorman101

    Thanks guys I figured it out :)
     
Thread Status:
Not open for further replies.

Share This Page