I want an command to be executed in minecraft 1.15.2 [Java-Edition] when a player has turned a certain page in a book. I am currently using the following command for this in a repeating command block that is always active.

execute if entity @p[nbt={SelectedItem:{id:"minecraft:written_book",tag:{pages:["generator"]}}}] run say You opened the page with the word "generator"!

However, this command does not work and there is no error message.

1 Answer 1


Books don't store the currently looked-at page. As far as I know, it's not even known to the server which page you look at.

If you want to trigger something when a player turns to a page in a book, you need a lectern. And then you can simply use a comparator or read the Page tag in NBT.

  • From what I understand, that's never been the case. The command searches for a specific word [in this case "generator"] and as soon as this word is present on the opened page, a command is to be triggered.The word can appear on different pages, but the first page that is opened with this word triggers the command.
    – Dalavar
    May 2, 2020 at 19:43
  • No, you can only check whether any page with the exact content "generator" (and nothing else) exists anywhere in the book. And even that is complicated, because of this oversight. This answer tells you how to work around it. But that only lets you check whether that text is a page either anywhere in the book or on a specific page, but it doesn't tell you whether that's opened. Minecraft has no string manipulation, like search, substrings, concatenation, etc. May 2, 2020 at 19:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .