I'd like to know if its possible to spawn a lectern with a custom written book in it.
I currently have an observer that detects if the book on the lectern is either removed, or the lectern is destroyed. It then powers a command block that replaces the lectern, with a new book located in it. However, I have been unable to spawn a new lectern with the same custom written book, all I've been able to spawn is a lectern with a blank written book, using the command /setblock ~ ~2 ~ minecraft:lectern[has_book=true]
Hi ! I hope it's not too late. I've found a solution for that : do note use setblock but clone command/ You put the exact same lectern with written book near from it, you place a comparator and a torch like in this video :
Thanks to it you'll run the command only if someone take off the book or destroy the lectern, but not if he just read it.
In the command block you put this command : "minecraft:clone x1 y1 z1 x1 y1 z1 x2 y2 z2 destroy".
x1 y1 z1 = replace it with the coordinate of the lectern the player can't see (ex : 1124 68 232)
x2 y2 z2 = replace it with the coordinate of the lectern the player wil use.
The destroy argument is very important because a bug could generate a barrier insteed of lecturn if you past a lectern on another lectern. To avoid any problems i use to command blocks in chain : the first one "minecraft:setblock x2 y2 z2 air destroy" and the second one "minecraft:clone x1 y1 z1 x1 y1 z1 x2 y2 z2"
Additionnaly you should maybe place a chain of command block : the first one to clear the book from the inventory of the player, the next one to remove all items from the ground. Thanks to it, players won't be abble to take of the book.