Solved Enchanted Book use without Anvil

Discussion in 'Plugin Development' started by Scipione, Jan 10, 2013.

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

    Scipione

    I'm currently pondering how to manage it, to "use" an Enchanted Book without the Anvil.
    for example: put the enchanted book and the item into the crafting table and "merge" them into enchanted item, or similar.

    Perhaps anyone can throw a few ideas in how to get this to work.

    Thanks for every tip (;

    Thanks for moving into the right forum section @ Mods :)

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

    fireblast709

    • get the enchantments on the book using EnchantmentStorageMeta
    • apply the enchantments on the ItemStack
    • remove the book
     
  3. Offline

    Scipione

    Thanks for tips (shame on me i didn't remind EnchantementStorageMeta ...)
    i didn't change outputs of the craftingtable yet and i fear i need another lil hint

    currently i try to change the "setResult" of the event, but it seems the event isn't even fired.
    i tried CraftItemEvent and also PrepareItemCraftEvent

    to debug i added broadcast messages, but they don't appear. Listener is normally registered in the plugin.
    are these the wrong events to handle the craftingtable ? or do i missing somethin ?

    Thanks for reply


    /EDIT:
    can someone post me one example code of generating a single new recipe which can be crafted in a craftingtable and showing the result in the inventory window after adding the correct shapeless ingredient ?
    would be awesome :)
     
  4. Offline

    fireblast709

    Code:java
    1. ItemStack result = new ItemStack(Material.STICK, 1);
    2. ItemMeta im = result.getItemMeta();
    3. im.setDisplayName("The AMAZING stick");
    4. ArrayList<String> lore = new ArrayList<String>();
    5. lore.add("He is made of wood");
    6. lore.add("He is used in torches");
    7. lore.add("Ooh stick keeps the mobs at bay");
    8. lore.add("Its the AMAZING stick");
    9. im.setLore(lore);
    10. result.setItemMeta(im);
    11. // Just to differ the sticks, ignore this
    12. result.setDurability((short)1);
    13. ShapelessRecipe stick = new ShapelessRecipe(result);
    14. // the last parameter is the data, which could be ignored
    15. stick.addIngredient(2, Material.STICK, 0);
    16.  
    17. Bukkit.getServer().addRecipe(stick);
     
  5. Offline

    Cjreek

    I just did exactly THIS for my plugin. If you want I can give you the source and/or the plugin!
    (I don't think it's fair to pay additional 3459072 levels just do put the enchantments of a book on an item...)
     
  6. Offline

    Scipione

    oh the source would be a real help :)
    i PM you my mailadress :)

    Thanks a lot
     
Thread Status:
Not open for further replies.

Share This Page