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

Function modifyBook

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

Source from the content-addressed store, hash-verified

59 }
60
61 function modifyBook (slot, pages, author, title, signing) {
62 const book = Object.assign({}, bot.inventory.slots[slot])
63 if (!book.nbt || book.nbt.type !== 'compound') {
64 book.nbt = {
65 type: 'compound',
66 name: '',
67 value: {}
68 }
69 }
70 if (signing) {
71 if (bot.supportFeature('clientUpdateBookIdWhenSign')) {
72 book.type = bot.registry.itemsByName.written_book.id
73 }
74 book.nbt.value.author = {
75 type: 'string',
76 value: author
77 }
78 book.nbt.value.title = {
79 type: 'string',
80 value: title
81 }
82 }
83 book.nbt.value.pages = {
84 type: 'list',
85 value: {
86 type: 'string',
87 value: pages
88 }
89 }
90 bot.inventory.updateSlot(slot, book)
91 return book
92 }
93
94 bot.writeBook = async (slot, pages) => {
95 await write(slot, pages, null, null, false)

Callers 1

writeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…