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

Custom written book in mcpe 1.2.

Discussion in 'Development' started by alexwolf_dev, Aug 16, 2017.

  1. alexwolf_dev

    alexwolf_dev Spider Jockey

    Messages:
    43
    GitHub:
    Frago9876543210
    Why does the game crashed when the book is opened?

    PHP:
    $p $e->getPlayer();
    $book Item::get(Item::WRITTEN_BOOK01);
    $nbt = new CompoundTag("", []);
    $nbt->author = new StringTag("author""author");
    $nbt->title = new StringTag("title""title");
    $pages = [
        new 
    StringTag("page1"'text1'),
        new 
    StringTag("page2"'text2')
    ];
    $nbt->pages = new ListTag("pages"$pages);
    $book->setCompoundTag($nbt);
    $p->getInventory()->addItem($book);
     
  2. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    How sure are you that those are the NBT keys for book and packets aren't used to handle it?
     
  3. Eduardo

    Eduardo Baby Zombie

    Messages:
    100
    GitHub:
    xBeastMode
    You have to register your own written book item class since there's no class for it in pocketmine yet.
    ...
    https://minecraft.gamepedia.com/Written_Book
     
    Last edited: Aug 16, 2017
    jasonwynn10 likes this.
  4. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    That's for PC. NOTE that PC's nbt keys aren't always the same as PE's. I can give several instances to support my argument.
     
    jasonwynn10 likes this.
  5. Eduardo

    Eduardo Baby Zombie

    Messages:
    100
    GitHub:
    xBeastMode
    I agree on that. But for data packets: how would a packet apply to a written book? It doesn't make sense unless written books now have UUIDs.
     
    jasonwynn10 likes this.
  6. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    BookEditPacket could be your answer. I can assure you books use packets just like maps do. The NBT probably stores the text information but requires BookEditPacket to be sent to the client for viewing the written text and signature.
     
    jasonwynn10 likes this.
  7. Eduardo

    Eduardo Baby Zombie

    Messages:
    100
    GitHub:
    xBeastMode
    I just took a look at the packet and that could be the answer. I'm gonna test it out :D
     
    jasonwynn10 and Muqsit like this.
  8. Sandertv

    Sandertv Zombie Pigman Poggit Reviewer

    Messages:
    786
    GitHub:
    Sandertv
    Book text at least is managed with NBT, not packets.
     
  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.