Custom recipe with custom ingredients

Discussion in 'Plugin Development' started by bubbleguj, Dec 30, 2013.

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

    bubbleguj

    Hey,
    I'm trying to update my weed plugin. So I need to create tips and papes and a joint. The joint should need the tip and the papes. This is my code yet:
    Code:java
    1. //Tip
    2. ItemStack tip = new ItemStack(Material.PAPER, 6);
    3. ItemMeta tipim = tip.getItemMeta();
    4. tipim.setDisplayName("§2§lTip");
    5. ll.clear();
    6. ll.add("§7Use this tip to roll a joint");
    7. tipim.setLore(ll);
    8. tip.setItemMeta(tipim);
    9. ShapelessRecipe tiprecipe = new ShapelessRecipe(tip);
    10. tiprecipe.addIngredient(Material.PAPER);
    11. plugin.getServer().addRecipe(tiprecipe);
    12.  
    13. //Papes
    14. ItemStack papes = new ItemStack(Material.PAPER, 3);
    15. ItemMeta papesim = papes.getItemMeta();
    16. papesim.setDisplayName("§2§lPapes");
    17. ll.clear();
    18. ll.add("§7Use this papes to roll a joint");
    19. papesim.setLore(ll);
    20. papes.setItemMeta(papesim);
    21. ShapedRecipe papesrecipe = new ShapedRecipe(papes);
    22. papesrecipe.shape("PPP");
    23. papesrecipe.setIngredient('P', Material.PAPER);
    24. plugin.getServer().addRecipe(papesrecipe);
    25.  
    26. //Joint
    27. ItemStack joint = new ItemStack(Material.STICK, 1);
    28. ItemMeta jointim = joint.getItemMeta();
    29. jointim.setDisplayName("§2§lJoint");
    30. ll.clear();
    31. ll.add("§7The better way to smoke :)");
    32. jointim.setLore(ll);
    33. joint.setItemMeta(jointim);
    34. ShapedRecipe jointrecipe = new ShapedRecipe(joint);
    35. jointrecipe.shape("PPP", "TWW", "PPP");
    36. jointrecipe.setIngredient('P', new MaterialData(papes.getType(), papes.getData().getData()));
    37. jointrecipe.setIngredient('W', drugdata);
    38. jointrecipe.setIngredient('T', new MaterialData(tip.getType(), tip.getData().getData()));
    39. plugin.getServer().addRecipe(jointrecipe);


    The problem is: I can craft the Joint with normal papers. But I want that it can only be crafted with papes and a tip. The part which has to be changes is this:
    Code:java
    1. jointrecipe.setIngredient('P', new MaterialData(papes.getType(), papes.getData().getData()));
    2. jointrecipe.setIngredient('W', drugdata);
    3. jointrecipe.setIngredient('T', new MaterialData(tip.getType(), tip.getData().getData()));


    But I realy have no idea how to do this.

    Anyway, please help me! :/
     
Thread Status:
Not open for further replies.

Share This Page