MCPcopy
hub / github.com/PrismarineJS/mineflayer / write

Function write

lib/plugins/book.js:37–59  ·  view source on GitHub ↗
(slot, pages, author, title, signing)

Source from the content-addressed store, hash-verified

35 }
36
37 async function write (slot, pages, author, title, signing) {
38 assert.ok(slot >= 0 && slot <= 44, 'slot out of inventory range')
39 const book = bot.inventory.slots[slot]
40 assert.ok(book && book.type === bot.registry.itemsByName.writable_book.id, `no book found in slot ${slot}`)
41 const quickBarSlot = bot.quickBarSlot
42 const moveToQuickBar = slot < 36
43
44 if (moveToQuickBar) {
45 await bot.moveSlotItem(slot, 36)
46 }
47
48 bot.setQuickBarSlot(moveToQuickBar ? 0 : slot - 36)
49
50 const modifiedBook = await modifyBook(moveToQuickBar ? 36 : slot, pages, author, title, signing)
51 editBook(modifiedBook, pages, title, moveToQuickBar ? 0 : slot - 36, signing)
52 await once(bot.inventory, `updateSlot:${moveToQuickBar ? 36 : slot}`)
53
54 bot.setQuickBarSlot(quickBarSlot)
55
56 if (moveToQuickBar) {
57 await bot.moveSlotItem(36, slot)
58 }
59 }
60
61 function modifyBook (slot, pages, author, title, signing) {
62 const book = Object.assign({}, bot.inventory.slots[slot])

Callers 1

injectFunction · 0.70

Calls 2

modifyBookFunction · 0.85
onceFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…