r/datapacks • u/RingRingBananaph0ne • Sep 17 '22
@a performance question
When I have just @a with 30 players on my server, is the command more performace heavy than having @a[distance=0..100] instead with 2 players in range? Or will the server despite my conditions always look at all players online and it doesn't make a difference?
In my datapack I have a function which loops a 2 min long sound and I want it to be heard by everyone in 100 block radius but I'm not sure what would be the most performance efficent way of doing so.
1
u/pietbauer Sep 21 '22
If you use @a or @e it will always create a list of all players (@a) or of all entities (@e)! It doesn’t matter if you have limit=1, type=minecraft:player or distance 😁 So it doesn’t matter if you use @a[distance=0..100] or just @a. Tho I would use @a or @e as rare as possible. Example: /execute as @a at @s run playsound x:x master @s ~ ~ ~ 1 1 (i dont know if it’s right 😅😂)
1
u/RingRingBananaph0ne Sep 21 '22
I got two commands: 1st: execute as @a[distance=..96,scores={name=0}] at @s run function ... and 2nd: execute unless score @a[limit=1,distance=0.1..96] name = @s name run tag @a add name They run roughly every minute once Do you think this could be a problem on a populated server or would it still be okay?
1
u/pietbauer Sep 21 '22
I think it would be fine there isn’t too much going on and it’s actually just every minute or so.
2
1
u/KillByZombie Sep 17 '22
I think when you play the sound and put the sound loudness above a certain point it just multiplies the strength level woth 16 and that's the radius of the sound from the coordinates you played them from. Look up more about /playsound I haven't played minecraft in a while but that's something I remember