12
Hello there! Today I will be showing you how to test to see if a player is holding a specific item. In this demonstration, to show that it works, I will apply invisibility to myself when holding white stained glass. So let's get things started. Begin by making a fill clock:
The top command block command:
/fill ~ ~-1 ~ ~9 ~-1 ~ minecraft:redstone_block
The bottom command block command:
/fill ~ ~1 ~ ~9 ~1 ~ minecraft:bedrock
After that, set up a new dummy scoreboard objective with the name "holding": /scoreboard objectives add holding dummy Holding
Hold up. We need to know in which order in a fill clock do commands get activated. Press F3 to get all of your client statistics. In the top left, look for the area that is labeled "Facing". Make sure that you're facing north (or negative Z, whichever you prefer). Commands will then activate from bottom to top, and left to right. That in mind, let us continue.
Let's set the value of "holding" to a player to 1 when they're holding a white stained glass. To do this, use this command:
/scoreboard players set @a holding 1 {SelectedItem:{id:"minecraft:stained_glass",Damage:0s}}
Now, whenever a person is holding a white stained glass, their "holding" score will be set to 1.
Next, let's apply a perpetual invisibility effect to a player will a "holding" score of 1 with the command: /effect @a[score_holding_min=1] invisibility 2 0
Now, whenever a player is holding a white stained glass, they get invisiblity. But we have a problem! Whenever a player isn't holding the glass anymore, they still get the effect! To fix this, add a last command block that constantly sets the "holding" score of a player to 0. Make SURE this comes AFTER the first two, otherwise it could mess up the machine. Use this command: /scoreboard players set @a holding 0
Things to consider: This is my single player world, and I'm on a team, hence the translucency of my invisibility effect. Also, the sidebar is displaying as "holding" as 0, even when I'm holding it. Doesn't matter, still works. >:)
If you're struggling with redstone or need help, feel free to contact me via PMC.
Remember, if you liked this tutorial feel free to Subscribe and diamond it. Be sure to leave a comment if you need me to make a tutorial on something else, or if you want to see different kinds of blogs.
Too da loo!
Fill Clock
The top command block command:
/fill ~ ~-1 ~ ~9 ~-1 ~ minecraft:redstone_block
The bottom command block command:
/fill ~ ~1 ~ ~9 ~1 ~ minecraft:bedrock
After that, set up a new dummy scoreboard objective with the name "holding": /scoreboard objectives add holding dummy Holding
Hold up. We need to know in which order in a fill clock do commands get activated. Press F3 to get all of your client statistics. In the top left, look for the area that is labeled "Facing". Make sure that you're facing north (or negative Z, whichever you prefer). Commands will then activate from bottom to top, and left to right. That in mind, let us continue.
Let's set the value of "holding" to a player to 1 when they're holding a white stained glass. To do this, use this command:
/scoreboard players set @a holding 1 {SelectedItem:{id:"minecraft:stained_glass",Damage:0s}}
Placement of the First Command Block (That isn't a fill clock command)
Now, whenever a person is holding a white stained glass, their "holding" score will be set to 1.
Next, let's apply a perpetual invisibility effect to a player will a "holding" score of 1 with the command: /effect @a[score_holding_min=1] invisibility 2 0
Placement of the Second Command Block (That isn't a fill clock command)
Now, whenever a player is holding a white stained glass, they get invisiblity. But we have a problem! Whenever a player isn't holding the glass anymore, they still get the effect! To fix this, add a last command block that constantly sets the "holding" score of a player to 0. Make SURE this comes AFTER the first two, otherwise it could mess up the machine. Use this command: /scoreboard players set @a holding 0
Placement of the Third Command Block (That isn't a fill clock command)
Outcome
Things to consider: This is my single player world, and I'm on a team, hence the translucency of my invisibility effect. Also, the sidebar is displaying as "holding" as 0, even when I'm holding it. Doesn't matter, still works. >:)
If you're struggling with redstone or need help, feel free to contact me via PMC.
Remember, if you liked this tutorial feel free to Subscribe and diamond it. Be sure to leave a comment if you need me to make a tutorial on something else, or if you want to see different kinds of blogs.
Too da loo!
Tags |
tools/tracking
3328147
6
how-to-test-if-a-player-is-holding-a-specific-item
Create an account or sign in to comment.
better Subscribe to keep track of it ;D