have been combing and reading the minecraft wiki, you tube, and here, racking my brain, trying to figure out how to turn off my command block functionality that I already turned on when the player is holding a particular item.
So my original issue was that I cannot directly test for 'SelectedItem' in most commands that I use to reference a player in the functionality of my command blocks, so then I figured I would use a tag:
/scoreboard players tag @a add Cmps {SelectedItem:{id:"minecraft:compass",Count:1b}}
Now this already sucks as I cannot figure out how to check only for players that do NOT have the tag, making this command spam adding the tag.
Then I can reference to players with that tag and other criteria like their Y axis viewing angle:
/title @a[rym=-11,ry=11,tag=Cmps] actionbar {"text":"whatever text needed","color":"light_purple"}
'... (and more of the same for different angle ranges)
So the idea is when they hold a specific item in their hand, my functionality kicks in, but then when they switch out and are no longer holding the item, I need to turn OFF that functionality for exactly that player. So I need to remove the tag when they are no longer holding it...
But HOW do check for someone NOT holding a particular item without spanning other command blocks and possibly referencing different players?
One would hope for things like this: (note the "!" after "id:")
/scoreboard players tag @a[tag=Cmps] remove Cmps SelectedItem:{id:!"minecraft:compass"}
THIS IS SO FRUSTRATING!
I have to check for 2 things [the tag and the LACK of holding an item] but I have to be certain it is referencing the same player and then on top of that remove the tag from that same player.
How do I check if the selected item is NOT a particular item and be certain of which player it is [and turn off only their tag]?
Bonus question: How to check only for players that do NOT have the tag so I can avoid spamming adding the tag?
Well wholy crap that's a silly bunt, it does work but I wouldn't know that since a few days ago when I was working on this in another area of my world there was a command block looped setting the tag I was using so even when I removed it I would still have it so that the result would always turn out null for the 'not' check.
OK so this is what I got...
This works as expected:
/scoreboard players tag @a[tag=!Cmps] add Cmps {SelectedItem:{id:"minecraft:clock"}}
and that turns on the tag.
So I add a CmpsChk tag to all that have the Cmps tag:
/scoreboard players tag @a[tag=Cmps] add CmpsChk
Then go through those w/t CmpsChk tag and if they have the compass, remove the CmpsChk tag:
/scoreboard players tag @a[tag=CmpsChk] remove CmpsChk {SelectedItem:{id:"minecraft:clock"}}
Then any that have the CmpsChk was not holding the compass but have the Cmps tag, so remove it and then the CmpsChk tag:
/scoreboard players tag @a[tag=CmpsChk] remove Cmps
/scoreboard players tag @a[tag=CmpsChk] remove CmpsChk
And,... it all works great.
Thanks guys, sorry for my silly bug, but your posts helped me realize that the method was possible and to eventually catch that bug, again thanks!
have been combing and reading the minecraft wiki, you tube, and here, racking my brain, trying to figure out how to turn off my command block functionality that I already turned on when the player is holding a particular item.
So my original issue was that I cannot directly test for 'SelectedItem' in most commands that I use to reference a player in the functionality of my command blocks, so then I figured I would use a tag:
Now this already sucks as I cannot figure out how to check only for players that do NOT have the tag, making this command spam adding the tag.
Then I can reference to players with that tag and other criteria like their Y axis viewing angle:
So the idea is when they hold a specific item in their hand, my functionality kicks in, but then when they switch out and are no longer holding the item, I need to turn OFF that functionality for exactly that player. So I need to remove the tag when they are no longer holding it...
But HOW do check for someone NOT holding a particular item without spanning other command blocks and possibly referencing different players?
One would hope for things like this: (note the "!" after "id:")
/scoreboard players tag @a[tag=Cmps] remove Cmps SelectedItem:{id:!"minecraft:compass"}
/execute @a[tag=Cmps] ~ ~ ~ /testfor @s {SelectedItem:{id:!"minecraft:compass"}} ......
THIS IS SO FRUSTRATING!
I have to check for 2 things [the tag and the LACK of holding an item] but I have to be certain it is referencing the same player and then on top of that remove the tag from that same player.
How do I check if the selected item is NOT a particular item and be certain of which player it is [and turn off only their tag]?
Bonus question: How to check only for players that do NOT have the tag so I can avoid spamming adding the tag?
1.13 or 1.12? If this is 1.13 it will be a whole lot easier
1.12 because he used /scoreboard instead of /tag
If that is the case, then here is my answer:
I'm a programmer. I use C/C++, BASIC, Assembly, and Python. If i sound too technicial, that's because it's the way i think.
My Suggestions
1.12.2 java
I tried using @a[tag=!tagName] and it just fails and doesn't find any results [unless there is some nuance I am missing in how I used and tested it].
Being myself an old time programmer of various languages I figured they would have such a thing so I tried:
@a[tag=!tagName]
@a[!tag=tagName]
@a![tag=tagName]
and then I tried the even sillier:
@a[tag!=tagName]
[as it would imply to find ANY tag that is not that tag]
most gave syntax like errors but a couple gave null results [failed to find any results].
Maybe I am missing something, I'll go back and have a look, but in the mean time have you specifically used that syntax before successfully?
Hope you get something out of this
@Implodingllama It states: "This video is unavailable.", apparently the video is no longer valid.
Thanks for fixing the video link, great reference video, thank you!
Well wholy crap that's a silly bunt, it does work but I wouldn't know that since a few days ago when I was working on this in another area of my world there was a command block looped setting the tag I was using so even when I removed it I would still have it so that the result would always turn out null for the 'not' check.
OK so this is what I got...
This works as expected:
and that turns on the tag.
So I add a CmpsChk tag to all that have the Cmps tag:
Then go through those w/t CmpsChk tag and if they have the compass, remove the CmpsChk tag:
Then any that have the CmpsChk was not holding the compass but have the Cmps tag, so remove it and then the CmpsChk tag:
And,... it all works great.
Thanks guys, sorry for my silly bug, but your posts helped me realize that the method was possible and to eventually catch that bug, again thanks!
Glad you could figure it out!