From 7cb639987116817327a5346e841b08295811ce60 Mon Sep 17 00:00:00 2001 From: Alex Howe Date: Tue, 7 May 2024 20:27:06 +0100 Subject: [PATCH] Added support for new edit book packet (#3204) --- lib/plugins/book.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/plugins/book.js b/lib/plugins/book.js index 56fb69bfbe..c8e5ff3986 100644 --- a/lib/plugins/book.js +++ b/lib/plugins/book.js @@ -10,18 +10,26 @@ function inject (bot) { if (bot.supportFeature('editBookIsPluginChannel')) { bot._client.registerChannel('MC|BEdit', 'slot') bot._client.registerChannel('MC|BSign', 'slot') - editBook = (book, signing = false) => { + editBook = (book, pages, title, signing = false) => { if (signing) bot._client.writeChannel('MC|BSign', Item.toNotch(book)) else bot._client.writeChannel('MC|BEdit', Item.toNotch(book)) } } else if (bot.supportFeature('hasEditBookPacket')) { - editBook = (book, signing = false, hand = 0) => { + editBook = (book, pages, title, signing = false, hand = 0) => { bot._client.write('edit_book', { new_book: Item.toNotch(book), signing, hand }) } + } else if (bot.supportFeature('hasNonNbtEditBookPacket')) { + editBook = (book, pages, title, signing = false, hand = 0) => { + bot._client.write('edit_book', { + hand, + pages, + title + }) + } } async function write (slot, pages, author, title, signing) { @@ -38,7 +46,7 @@ function inject (bot) { bot.setQuickBarSlot(moveToQuickBar ? 0 : slot - 36) const modifiedBook = await modifyBook(moveToQuickBar ? 36 : slot, pages, author, title, signing) - editBook(modifiedBook, signing) + editBook(modifiedBook, pages, title, signing) await once(bot.inventory, `updateSlot:${moveToQuickBar ? 36 : slot}`) bot.setQuickBarSlot(quickBarSlot)