1
Execute command difficulties
Hey y'all,
I'm new to coding mc datapack and I am having some issues with an execute command.
I need a set block command to run when spiders get over a certain "webtimer" score
This webtimer score is automatically going up all the time and will reset after a certain time. But don't worry about that for this part.
So far here is what I have:
/execute as @s[type=spider] if score @s[type=spider] webtimer >= 5 webtimer run setblock ~ ~ ~ minecraft:cobweb
The issue is that it doesn't do anything. The only requirement I have is that this must work in multiplayer
I'm new to coding mc datapack and I am having some issues with an execute command.
I need a set block command to run when spiders get over a certain "webtimer" score
This webtimer score is automatically going up all the time and will reset after a certain time. But don't worry about that for this part.
So far here is what I have:
/execute as @s[type=spider] if score @s[type=spider] webtimer >= 5 webtimer run setblock ~ ~ ~ minecraft:cobweb
The issue is that it doesn't do anything. The only requirement I have is that this must work in multiplayer
3
Try this:
/execute as @s[type=spider] if score @s webtimer matches 5.. at @s run setblock ~ ~ ~ minecraft:cobweb
what the '>=' operator does is compare a any score from any entity, such as this:
execute if score @s webtimer >= @p test run ...
what the above command does is compare the webtimer score of @s to @p's test score, and executes the command only if webtimer for @s is greater than or equal to test of @p. The command in the OP compares the webtimer score of entity '5' (which doesn't exist) to that of the spider.
Hope this helps!
/execute as @s[type=spider] if score @s webtimer matches 5.. at @s run setblock ~ ~ ~ minecraft:cobweb
what the '>=' operator does is compare a any score from any entity, such as this:
execute if score @s webtimer >= @p test run ...
what the above command does is compare the webtimer score of @s to @p's test score, and executes the command only if webtimer for @s is greater than or equal to test of @p. The command in the OP compares the webtimer score of entity '5' (which doesn't exist) to that of the spider.
Hope this helps!
it did help to understand what the "matches" means exactly. The line of code you suggested had issues with the "@s", I'm not sure why but it was not able to target the spiders. However, I was able to make some progress with the advice you gave
/execute as @e[type=spider] if score @s[type=spider] webtimer matches 5 run setblock ~ ~ ~ minecraft:cobweb
This line of code here is able to place at the players location when the webtimer is 5. Now I need to figure how to get it to target the spiders and place webs at their location
Thanks for all of your help
/execute as @e[type=spider] if score @s[type=spider] webtimer matches 5 run setblock ~ ~ ~ minecraft:cobweb
This line of code here is able to place at the players location when the webtimer is 5. Now I need to figure how to get it to target the spiders and place webs at their location
Thanks for all of your help
/execute as @e[type=spider] at @s if score @s webtimer matches 5 run setblock ~ ~ ~ minecraft:cobweb
