So I’m working on a map and need help with the Testfor command. I’ve looked around and tried out several different things and just messed around with the command without help, but I can’t get it to activate with the book in hand. Here’s the command I have set up, but it doesn’t work.

/testfor @a {SelectedItemSlot:8,Inventory:[{Slot:8b,id:minecraft:written_book,tag:{pages:["[\"\",{\"text\":\"Master, I have done as you told me, Minera will soon fall to your Undead Army. I still have not figured out how to obtain the sword, but you were right to check the bookshelf before attempting more drastic measures... (the note is torn)\"}]"],display:{Name:"Torn Note"}}}]}

Now here's a different version, but without a book (this one works perfectly).

/testfor @a {SelectedItemSlot:8,Inventory:[{Slot:8b,tag:{display:{Name:"Torn Note"}}}]}

My problem is that with a book the second command doesn’t light up and I really want to use a book for this part of my map.

Also I should say, the command for the book itself should be fine, I used a JSON Minecraft generator and it works fine with /give. I did edit the format slightly to try to get the testfor command to work, but it didn’t.

  • I can't test it right now, so I'll just post this as a comment, but can't you just remove the "tag" tag from the first command? or if your trying to test for a particular book, can't you just test for the name, not the pages? – Venya Nov 8 '16 at 17:06
  • It seems to be a problem with your pages tag – El Six Mar 7 '17 at 22:37
  • In 1.12 id:"minecraft:written_book" work – l4m2 May 10 '18 at 3:46

Better not be using the "pages" tag for testfor'ing books. pages uses JSON format, and there are many valid JSON formats for a book, and you couldn't detect them all. Use a custom NBT tag to detect a specific book, or instead just use the book name.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.