1

Execute command difficulties

_Hardlight_ 1/11/23 1:17 am history
166
1/15/2023 12:40 am
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
Posted by
_Hardlight_
Level 21 : Expert Mage
3

  Have something to say?

JoinSign in

3

Spuduking
01/11/2023 2:57 pm
Level 34 : Artisan Procrastinator
history
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!
3
_Hardlight_
01/12/2023 4:37 pm
Level 21 : Expert Mage
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
2
Apollo404
01/15/2023 12:40 am
She/Her • Level 71 : Legendary Terraformer Fox
/execute as @e[type=spider] at @s if score @s webtimer matches 5 run setblock ~ ~ ~ minecraft:cobweb
1

Welcome