How do I write a command that tests for shears? [duplicate]
I recently watched a video of how to use command blocks, and in it this guy showed that you cannot enter a certain place without shears. When he got shears he could walk through.
I know how to do /say, but I don't know how to require shears to walk in a certain block. What do I need to do?
Best Answer
Simple, just use the updated /clear command. Here's an example of a setup to open an iron door:
#1 /setblock <x> <y> <z> redstone_block 0 destroy
#2 /clear @a[r=10] <item id> 0 0 {display:{Name:"<custom item name>"}}
Here's the setup of the command blocks:
[] = iron door
{} = comparator
() = redstone_block
#1 = command block 1
#2 = command block 2
#1()#2{}[]
To explain exactly how this works, I'll go command by command. The first command block sets up a constant redstone loop, which will be constantly activating command block two. Command block two is testfor the item in the player's hand if the player is within a radius of ten blocks. Then command block two outputs a redstone signal which activates the iron door. Also, here are a few commands you might want to run in order to not lag your world:
/gamerule commandBlockOutput false
/gamerule doTileDrops false
Lastly you must play in the latest snapshot of minecraft for this to correctly work. I hope this helps!
Pictures about "How do I write a command that tests for shears? [duplicate]"
![How do I write a command that tests for shears? [duplicate] - Student Cheating During an Exam How do I write a command that tests for shears? [duplicate] - Student Cheating During an Exam](/assets/images/how_do_i_write_a_command_that_tests_for_shears_duplicate_1.jpeg)
![How do I write a command that tests for shears? [duplicate] - Student Cheating During an Exam How do I write a command that tests for shears? [duplicate] - Student Cheating During an Exam](/assets/images/how_do_i_write_a_command_that_tests_for_shears_duplicate_2.jpeg)
![How do I write a command that tests for shears? [duplicate] - Student Cheating During an Exam How do I write a command that tests for shears? [duplicate] - Student Cheating During an Exam](/assets/images/how_do_i_write_a_command_that_tests_for_shears_duplicate_3.jpeg)
A simple test to check a shear's sharpness
Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.
Images: RODNAE Productions, RODNAE Productions, RODNAE Productions, RODNAE Productions
