Solved Custom Items (not working)

Discussion in 'Plugin Development' started by ccrama, Jun 5, 2014.

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

    ccrama

    Hello Bukkit,
    I'm trying to make a custom recipe using skulls and gold, creating golden apples which have a custom name (if the skull came from ccrama, the golden apple would say "GOLDEN APPLE USING ccrama's HEAD"), but the custom recipe isn't working. Here is my code:

    Code:java
    1.  
    2. //global variable
    3. private ItemStack GOLDAPPLE = new ItemStack(Material.GOLDEN_APPLE, 1);
    4.  
    5. //in my onEnable
    6. ShapedRecipe strecipe = new ShapedRecipe(GOLDAPPLE);
    7. strecipe.shape("GGG","BTB","GGG");
    8. strecipe.setIngredient('G', Material.AIR);
    9. strecipe.setIngredient('T', Material.SKULL);
    10. strecipe.setIngredient('B', Material.GOLD_INGOT);
    11. getServer().addRecipe(strecipe);
    12.  
    13. //separate method
    14.  
    15. @EventHandler
    16. public void craft(PrepareItemCraftEvent e){
    17. if(e.getRecipe().getResult() == GOLDAPPLE){
    18. ItemMeta meta = GOLDAPPLE.getItemMeta();
    19. if(e.getInventory().getItem(5).hasItemMeta());
    20. String name = e.getInventory().getItem(5).getItemMeta().getDisplayName();
    21. meta.setDisplayName(ChatColor.GOLD + "GOLDEN APPLE MADE FROM " + name );
    22. e.getInventory().setResult(GOLDAPPLE);
    23. }
    24. }
    25.  
    26.  


    Any help would be great!
     
  2. Offline

    NathanWolf

    Try SKULL_ITEM instead of SKULL, perhaps?

    The latter represents the placed Block, not the item.
     
  3. Offline

    ccrama

    NathanWolf Good idea, but still didn't work :(. No errors in console or anything either.
     
  4. Offline

    teej107

    Try taking out or commenting it out:
    Code:java
    1. strecipe.setIngredient('G', Material.AIR);
    Leave G in the shape() though.
     
  5. Offline

    ccrama

    teej107 Testing now. I'll update in a second...

    EDIT THANKS teej107 worked! Now I just need it to change the lore... That part is still not working. I can probably debug that part on my own, the real issue was the recipe. Thanks guys
     
  6. Offline

    Pocketkid2

  7. Offline

    teej107

    This thread has been solved. And you are not using Bukkit anyway from the pastebin.
     
Thread Status:
Not open for further replies.

Share This Page