Skip to content

Commit

Permalink
Merge branch 'master' into mounting
Browse files Browse the repository at this point in the history
  • Loading branch information
qwqtoday committed Jun 22, 2024
2 parents 5cd28db + eb9982a commit 763811a
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions lib/plugins/book.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
}
}
}

Expand All @@ -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)
Expand Down

0 comments on commit 763811a

Please sign in to comment.