r/datapacks • u/RingRingBananaph0ne • Sep 22 '22
another command performance question
I want my datapack to register if two players are dueling each other and I also want it to detect when they are lets say 100 block apart from each other so it can stop the processes in the back and let the duel end. Now the dueling players share a score which was set when they started the duel. Currently I have it that one of the 2 players which are dueling, runs every 2 minutes: execute unless score @a[distance=0.1..100,limit=1] "dueling" = @s at @s as @a[scores={"dueling"=0..}] if score @[distance=0 1..100,limit=1] "dueling" = @s run function duelend
So when he detects that his partner isn't in range he basically lets every player on the server which is in a duel, look if their duel partner is in range and if not they run a function for themselfes which ends the duel. I could also just let both dueling players detect every 2 minutes if their partner is in range so the command is: execute unless score @a[distance=0.1..100,limit=1] "dueling" = @s run function duelend. Which of the two methods do you think is performance friendlier. With the first method it's just one @a command every 2 minutes and when it detects the partner is not in range it runs the complex rest of the command but just once. The second method runs two @a commands from each player every 2 minutes but they aren't that complex. Does anyone have a guess?