Solved Open a written book GUI on chest inventory click?

Discussion in 'Plugin Development' started by TwistedMexi, Oct 8, 2012.

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


    I already have a method for intercepting inventory clicks and items, but I can't seem to find any method to call the book to the client?

    Basically I want my bookshelf to be set so when someone clicks on a book inside of it, it stops them from getting the item (done) and instead displays the book as if you went to read it.

    Does anyone know what I could call to get this to display? I know it's apparently impossible at the moment to make a user read a book in their own inventory, but given the book information is stored server-side in my case, I'm hoping there's a way to push it down?

    Any assistance is appreciated,
  2. I'vee been looking for a way as well, but I haven't found a method yet. Mainly because there isn't a Book API in Bukkit right now.
  3. Offline


    Right, I'd stumbled upon that a lot, from the older dates I thought it would surely be out, even if just a simple one, by now. Is there any way to pull up other gui's from the server (crafting tables, furances, for example)? Just so I know if what I'm talking about is even roughly possible.
  4. It is not possible to pop up the book GUI, it is handled entirely on the client side.
    TwistedMexi likes this.
  5. Offline


    That's what I was afraid of. Thanks for confirming.

    That said, I'll be going forward with my bookshelf as is, in that it clones the books to your inventory. The problem now is, I need a way to prevent users from trading them with villagers. Time limits and distance to bookshelf limits won't help here as they're easily worked around.

    Anyone have a sleek suggestion on preventing this? A blacklist of sorts is all that comes to mind.
  6. You'd cancel the InventoryClickEvent if they're trying to place one of your books in a villager sell slot.
  7. Offline


    Yeah, that's what I was planning - maybe when the clones are made append " - *Copy" to the end and watch for book trades and cancel any if title contains "- *Copy". Just double-checking I wasn't overlooking something even smoother.
  8. Offline


    So the books works like everything clientside, so if I have a book on my inventory my client have the content of the book? I mean the client will not ask the server what is the content of the book?
  9. The server has it, otherwise how would the player read books not created while he was logged in? I guess you could get/set the info with NMS code... (no idea on how, though)
  10. Offline


    From my understanding it's technically both. Your client keeps a cache of what's in your inventory (for efficiency regarding the amount of access requests I suppose), but players inventories are also kept server-side, for obvious reasons.
    kroltan likes this.
  11. The book's content is stored with the book item itself. So when the client receives the inventory the book is in, it also receives the book content. If it's in a player's inventory, it will be sent when the player logs in. If it's in a chest, it will be sent when the chest is opened.
    Zidkon, TwistedMexi and kroltan like this.
  12. Offline


    So the content is sent without the user knowledge, if I get a book on my inventory and I don't want to read it it will just make space xD.

    We can say goodbye to the implementation to open a book GUI by serverside :D until they fix it on minecraft.
Thread Status:
Not open for further replies.

Share This Page