Zarius / Bukkit-OtherBlocks

OtherBlocks (now known as OtherDrops) plugin for Bukkit (dev build: https://www.mediafire.com/?i6ows1g6kus2o0l)
http://dev.bukkit.org/server-mods/otherdrops/
GNU General Public License v3.0
17 stars 17 forks source link

OtherDrops enchants books incorrectly. #298

Open totemo opened 10 years ago

totemo commented 10 years ago

Hi, love your plugin. I recently ran a successful Halloween event which used OtherDrops to bring 1.7 style fishing to 1.6.4 and Halloween themed mobs and their drops. Thank you.

Now on to the bug:

OtherDrops enchant books as it would any other item. If you apply Sharpness 5 to a book, you get a book that does more damage than your fist when you hit a mob with it. However, that book cannot be applied to a weapon using an anvil. In the case of the event, the drop setting for books was "enchanted_book@!RANDOM/2%"

The correct way to make an enchanted book for use on an anvil is (in short):

    EnchantmentStorageMeta meta = (EnchantmentStorageMeta) item.getItemMeta();
    meta.addStoredEnchant(enchantment, level, true);
    item.setItemMeta(meta);

Partial extract of my fishing config follows:

otherdrops:
    PLAYER:
        # Disable default drop.
        # ---------------------------------------------------
        # This doesn't actually do anything. Just here for documentation.
        # What does work is to set one of the drop options in the clear or 
        # rough weather drops to /100%.

        - drop: NOTHING
          chance: 100%

        # Clear weather: less junk, less treasure.
        # ---------------------------------------------------
        # The 'Halloween 2013' lore is omitted from name tags because it causes
        # problems when applied.  That lore was also removed from books, on the
        # theory that it was causing problems there too, but actually OtherDrops
        # just creates enchanted books incorrectly.

        - drop: { raw_fish~&5Halloween 2013 Fishing/101%, bowl~&5Halloween 2013 Fishing/2%, fishing_rod@10-30~&5Halloween 2013 Fishing/2%, leather~&5Halloween 2013 Fishing/2%, leather_boots@30-50~&5Halloween 2013 Fishing/2%, rotten_flesh~&5Halloween 2013 Fishing/2%, stick~&5Halloween 2013 Fishing/2%, string~&5Halloween 2013 Fishing/2%, 373@0~&5Halloween 2013 Fishing/2%, bone~&5Halloween 2013 Fishing/2%, ink_sac~&5Halloween 2013 Fishing/2%, tripwire_hook~&5Halloween 2013 Fishing/2%, bow@10-30!RANDOM!RANDOM~&5Halloween 2013 Fishing/2%, enchanted_book@!RANDOM/2%, name_tag/2%, saddle~&5Halloween 2013 Fishing/2%, lily_pad~&5Halloween 2013 Fishing/2% }
          trigger: FISH_CAUGHT
          weather: CLEAR
          flags: UNIQUE