1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Enchanted book

Discussion in 'Development' started by Hipster, Oct 13, 2017.

  1. Hipster

    Hipster Zombie

    Messages:
    214
    i was trying to make a plugin to register and implement enchanted books, but while i was placing more than 1 enchanted book in my inventory, it will revert and not transfer, it won't even drop the enchanted book on the ground, i even put 64 in getMaxStackSize() function, i can't find the problem thats causing this... plz help
    Version of pmmp is : 7b5df10
    mcpe v1.2
    OS: Windows
    P.S. 1 enchanted book works fine and even drops on ground
     
  2. robske_110 (Tim)

    robske_110 (Tim) Wither Skeleton Poggit Reviewer

    Messages:
    1,342
    GitHub:
    robske110
    try to show us (parts) of your code
     
  3. Hipster

    Hipster Zombie

    Messages:
    214
    EnchantedBook.php ->
    Code:
    <?php
    
    declare(strict_types=1);
    
    namespace pocketmine\item;
    
    class EnchantedBook extends Item {
        public function __construct(int $meta = 0){
            parent::__construct(self::ENCHANTED_BOOK, $meta, "Enchanted Book");
        }
        public function getMaxStackSize() : int{
            return 64;
        }
    }
    Registering ->
    Code:
    ItemFactory::registerItem(new Item(Item::ENCHANTED_BOOK, 0, "Enchanted Book"));
     
  4. robske_110 (Tim)

    robske_110 (Tim) Wither Skeleton Poggit Reviewer

    Messages:
    1,342
    GitHub:
    robske110
    why are you constructing an Item instead of EnchantedBook?
    PHP:
    ItemFactory::registerItem(new EnchantedBook(Item::ENCHANTED_BOOK0"Enchanted Book"));
     
  5. Hipster

    Hipster Zombie

    Messages:
    214
    Because i tried
    Code:
    ItemFactory::registerItem(new EnchantedBook());
    and it didn't work
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.