diff --git a/lib/plugins/book.js b/lib/plugins/book.js index 56fb69bfb..9c1616979 100644 --- a/lib/plugins/book.js +++ b/lib/plugins/book.js @@ -10,17 +10,27 @@ 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, slot, 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) => { - bot._client.write('edit_book', { - new_book: Item.toNotch(book), - signing, - hand - }) + if (bot.supportFeature('editBookPacketUsesNbt')) { // 1.13 - 1.17 + editBook = (book, pages, title, slot, signing = false, hand = 0) => { + bot._client.write('edit_book', { + hand: slot, + pages, + title + }) + } + } else { // 1.18+ + editBook = (book, pages, title, slot, signing = false, hand = 0) => { + bot._client.write('edit_book', { + new_book: Item.toNotch(book), + signing, + hand + }) + } } } @@ -38,7 +48,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, moveToQuickBar ? 0 : slot - 36, signing) await once(bot.inventory, `updateSlot:${moveToQuickBar ? 36 : slot}`) bot.setQuickBarSlot(quickBarSlot)