1

I want to have a testfor command that only teleports a player with a specific team and writable_book in their inventory, and in that book on the first page it reads: "Test".
I've tried dozens of commands but couldn't figure it out. Is this even possible?

1 Answer 1

2

What you are looking for looks something like this:

{Inventory:[{id:minecraft:written_book,tag:{pages:[0:"\"Test\""]}}]}

But the teleport command does not support NBT tags. However, there is a workaround using scoreboards.

First add a scoreboard objective:

/scoreboard objectives add HoldingBook dummy HoldingBook

Then run these 2 commands on a fast clock:

/scoreboard players set @a HoldingBook 2 {Inventory:[{id:minecraft:written_book,tag:{pages:[0:"\"Test\""]}}]}
/scoreboard players remove @a HoldingBook 1

Now, you can teleport the players holing a written book with the word "Test" on the first page, and for example on team blue;

/tp @a[score_holdingbook_min=1,team=blue] <your-coords>

Hope this helps.

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.