how would i use testforblock to teleport,say i want the command block to test any player on the map and see if there holding a book in there heand with a certain word written in it,and once it finds it it teles them to spawn
or at least test for a block and tele them
can someone help me out with that
Rollback Post to RevisionRollBack
praise be to God the Father, Son, and Holy spirit. the world is a beautiful place get out and see Gods creation. john 3 :16
That will test for an item with a particular name ONLY WHEN HELD AND IN THEIR FIRST SLOT, therefor you can use it to test for a named book.
Connect this up to your input: Like this:
The pink block would contain the testfor command listed above, and the green block containing /tp @p[x,y,z] x y z
The coordinates inside the square brackets being where the pressure plate is, and outside being where to teleport to.
HOWEVER, if you wanted this to be global, you would have to set up a redstone clock attached to one command block. The code inside being
an execute code (which I hate) something (not exactly) along the lines of
/execute @a{Inventory:[{Slot:0b,tag:{display:{Name:"NAMEOFBOOK"}}}],SelectedItemSlot:0} ~0 ~0 ~0 /tp x y z
In order to test a player is holding it in any slot, you can either give it a custom attribute level 0 and then test for attribute level 0, or attach the system above to 9 command blocks, each testing for one slot.
Had a few minutes to think about it and have managed it using the scoreboard command!
Pink: /scoreboard players set @a teleport 1 {SelectedItem:{tag:{display:{Name:"CUSTOM NAME HERE"}}}}
Green: /tp @a[score_teleport_min=1] x y z
Blue: /scoreboard players set @a teleport 0
x y z are spawn co-ordinates
Custom name has to be added through command or renaming on an anvil
/give @p ITEMNAME 1 0 {display:{Name:"CUSTOM NAME HERE"}}
Added hint: you might want /gamerule commandBlockOutput false
to stop the messages from popping up onscreen
This can be connected up to a redstone clock to be permanent and global!
or at least test for a block and tele them
can someone help me out with that
praise be to God the Father, Son, and Holy spirit. the world is a beautiful place get out and see Gods creation. john 3 :16
/testfor @p {Inventory:[{Slot:0b,tag:{display:{Name:"INSERTBLOCKNAMEHERE"}}}],SelectedItemSlot:0}
That will test for an item with a particular name ONLY WHEN HELD AND IN THEIR FIRST SLOT, therefor you can use it to test for a named book.
Connect this up to your input: Like this:
The pink block would contain the testfor command listed above, and the green block containing /tp @p[x,y,z] x y z
The coordinates inside the square brackets being where the pressure plate is, and outside being where to teleport to.
HOWEVER, if you wanted this to be global, you would have to set up a redstone clock attached to one command block. The code inside being
an execute code (which I hate) something (not exactly) along the lines of
/execute @a{Inventory:[{Slot:0b,tag:{display:{Name:"NAMEOFBOOK"}}}],SelectedItemSlot:0} ~0 ~0 ~0 /tp x y z
In order to test a player is holding it in any slot, you can either give it a custom attribute level 0 and then test for attribute level 0, or attach the system above to 9 command blocks, each testing for one slot.
Pink: /scoreboard players set @a teleport 1 {SelectedItem:{tag:{display:{Name:"CUSTOM NAME HERE"}}}}
Green: /tp @a[score_teleport_min=1] x y z
Blue: /scoreboard players set @a teleport 0
x y z are spawn co-ordinates
Custom name has to be added through command or renaming on an anvil
/give @p ITEMNAME 1 0 {display:{Name:"CUSTOM NAME HERE"}}
Added hint: you might want /gamerule commandBlockOutput false
to stop the messages from popping up onscreen
This can be connected up to a redstone clock to be permanent and global!
Hope this helps you!
Duskreaper
Mental Block Gaming
thank you
and God bless
praise be to God the Father, Son, and Holy spirit. the world is a beautiful place get out and see Gods creation. john 3 :16