Solved Enchanted Books

Discussion in 'Plugin Development' started by bryansolis13, Sep 14, 2016.

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

    bryansolis13

    Ok i looked around and couldn't find a way to do this. I need a way where i can make a custom enchanted book and people can put it in anvils with sword,armor,etc.. and get the enchantment on the sword,etc...

    This is how i make the enchanted book
    Code:
            ItemStack Book = new ItemStack(Material.ENCHANTED_BOOK,1);
            ItemMeta meta = Book.getItemMeta();
            meta.setDisplayName(ChatColor.YELLOW + "Enchanted Book");
            ArrayList<String> lores = new ArrayList<String>();
            lores.add(ChatColor.BLUE + "Sword");
            lores.add(ChatColor.GRAY + "Thrower");
            meta.setLore(lores);
            Book.setItemMeta(meta);
     
  2. Offline

    HeartandSoul

    This is not an enchantment, Its just ItemMeta. If you were to do that, you must make a custom GUI for it.
     
  3. Offline

    Zombie_Striker

  4. Offline

    bryansolis13

    I know it was just ItemMeta

    Thanks I'll give it a try
     
  5. Offline

    cococow123

    You could maybe try hidden NBT tags on the book?
     
  6. Offline

    bryansolis13

    @Zombie_Striker

    I did that and it just uses bukkit enchantments. Im sorry i didnt be more clear but what im trying to do it make custom enchantments to look like this
    [​IMG]
     
  7. Offline

    ArsenArsen

  8. Offline

    bryansolis13

    @ArsenArsen The code was above
    Code:
    ItemStack Book = new ItemStack(Material.ENCHANTED_BOOK,1);
            ItemMeta meta = Book.getItemMeta();
            meta.setDisplayName(ChatColor.YELLOW + "Enchanted Book");
            ArrayList<String> lores = new ArrayList<String>();
            lores.add(ChatColor.BLUE + "Sword");
            lores.add(ChatColor.GRAY + "Thrower");
            meta.setLore(lores);
            Book.setItemMeta(meta);
    This is all i have for the enchanted book. The rest of the code is for signs and stuff.
     
  9. Offline

    ArsenArsen

  10. Offline

    bryansolis13

    @ArsenArsen
    Yes I tried it but it didn't work when I put it in the anvil

    Code:
          
            ItemStack Book = new ItemStack(Material.ENCHANTED_BOOK,1);
            ItemMeta meta = Book.getItemMeta();
            meta.setDisplayName(ChatColor.YELLOW + "Enchanted Book");
            ArrayList<String> lores = new ArrayList<String>();
            lores.add(ChatColor.BLUE + "Sword");
            lores.add(ChatColor.GRAY + "Thrower");
            meta.setLore(lores);
         
            Glow glow = new Glow(71);
            meta.addEnchant(glow, 1, true); 
         
            Book.setItemMeta(meta);
     
            player.getInventory().addItem(Book);
     
    Last edited: Sep 18, 2016
  11. Offline

    bryansolis13

  12. Offline

    bryansolis13

  13. Offline

    Zombie_Striker

    @bryansolis13
    Tahg me if you want me to respond.

    What you want cannot be done; You want to add a new enchantment that reacts differently than other enchantments. You either need to overhaul the Anvil System (Using PrepareAnvilEvent to apply a custom lore to the "result") or merge those two lines (into "Sword Thrower").
     
  14. Offline

    bryansolis13

Thread Status:
Not open for further replies.

Share This Page