or you simply can’t use exclamation marks in NBT tags
This is the case unfortunately. Using !
for negation only works in selectors, and even then only for certain arguments (type
, name
, tag
, team
, m
).
The problem is, that when I move far away from the setup, the redstone stops working, leaving me unable to summon any new fireballs. Instead, I'm trying to use a command block to check when anything except for item is being held;
If I'm understanding correctly, this problem won't be solved by changing your commands if they already do the correct thing when you're near them.
You should instead move your contraption to spawn chunks (which are always loaded) or keep the chunks your contraption is in loaded with a chunk loader.
how I can check for anything except for a specific item?
Your original commands will leave players not holding the item with a score of 0, meaning you can do something like:
/scoreboard players add @a Fireball 1 {SelectedItem:{tag:{display:{Name:"Summon Fireball"}}}}
/execute @a[score_Fireball_min=1,score_Fireball=1] ~ ~ ~ /summon Fireball ~ ~2.5 ~ {direction:[0.0,0.0,0.0]}
/execute @a[score_Fireball_min=0,score_Fireball=0] ~ ~ ~ /say I'm not holding the fireball summon item
/scoreboard players set @a Fireball 0
You can rearrange these commands slightly to have players be left with 0 or 1 at the end of the tick depending on whether they're holding the fireball, if you want:
/scoreboard players set @a Fireball 0
/scoreboard players add @a Fireball 1 {SelectedItem:{tag:{display:{Name:"Summon Fireball"}}}}
/execute @a[score_Fireball_min=1,score_Fireball=1] ~ ~ ~ /summon Fireball ~ ~2.5 ~ {direction:[0.0,0.0,0.0]}
/execute @a[score_Fireball_min=0,score_Fireball=0] ~ ~ ~ /say I'm not holding the fireball summon item
Further, I’ve tried using exclamation marks to set the score of all entities, including the ones with a blank score, but except for the ones with a score of 2 or higher, to 0;
The score_...
argument also unfortunately doesn't accept !
for negation. You'll instead need to do this in multiple steps:
- Add 0 to all scores, turning null scores to 0:
/scoreboard players add @e[type=Arrow] Arrows 0
- Do the command for arrows with
Arrows
score less than 2: @e[score_Arrows=1]
- Do the command for arrows with Arrows score more than 2:
@e[score_Arrows_min=3]
This took me a while, I even manually went through all the steps (which is my last hope against bugs), but then I got it:
You just need to add ,tag=!D_InventorSkull
to the selector in the first command.
That way the skinned head doesn't get the baseSkull
tag and the first execute
in the third command doesn't trigger a second time.
scoreboard players tag @e[type=Item,tag=!baseSkull,tag=!D_InventorSkull] add baseSkull {Item:{id:"minecraft:skull",Damage:3s,Count:1b}}
Also, are you sure you don't want to kill the arrow, too? In that case you should add a sixth command:
execute @e[tag=D_InventorSkull] ~ ~ ~ kill @e[type=arrow,r=1]
In 1.13:
execute as @e[tag=D_InventorSkull] at @s run kill @e[type=arrow,distance=..1]
Best Answer
Here is one solution that works, but I am not sure I would use elegant to describe it. It involves creating a scoreboard objective to create an inversion. First the score is set to 1 for a fake player and then an execute command resets the score. If no tagged entities exist, the score does not get reset. Then you can test for the score.
Create a dummy objective:
Create a Repeat Unconditional Always Active command block with command:
Follow with a Chain Unconditional Always Active command block with command:
Create another Repeat Unconditional Always Active command block with command:
Follow that with a Chain Conditional Always Active command block. This block is used to run whatever commands you want after the entities have all been killed. Note: this command will run repeatedly unless you stop the system.
Also, if you don't mind having an extra armor stand to store data as part of your system, you could use a scoreboard tag instead of adding an objective.