4

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.

3
  • 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
    Commented Nov 8, 2016 at 17:06
  • It seems to be a problem with your pages tag
    – El Six
    Commented Mar 7, 2017 at 22:37
  • In 1.12 id:"minecraft:written_book" work
    – l4m2
    Commented May 10, 2018 at 3:46

1 Answer 1

1

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 and acknowledge you have read our privacy policy.

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