So ive been trying to find an absolute foolproof way to get around the scheduled functions not maintaining target selectors, since giving tags and running based on that can be glitched if multiple people do it at the same time. Does anyone have any clues as to how to incorporate delays without the vulnerability of tagging entities?
#Targeting function owner with scheduled functions
1 messages · Page 1 of 1 (latest)
Someone will come and help soon!
💬 While you wait, take this time to provide more context and details.
🙇 After a while, hit the Summon Helpers button to ping the helper team. They'll be happy to help you
✅ Once your question has been resolved (or you no longer need it), please click Resolve Question or run /resolve
yea, when starting the schedule, you:
execute store result score <...> run schedule function <...> append
that stores the time that the scheduled function will run at
and then to get that entity in the scheduled function, you:
execute store result score .gametime <...> run time query gametime
execute as @a if score @s <...> <= .gametime <...> run say IT WAS ME HAHAHAHA
you can optimize the latter check using predicates
wait so the first command stores the gametime that the function will run at?
oh that is neat
if that wasnt the case you can still get it using 2 extra commands but yes, that is a really neat thing
I made a datapack recently that I use all the time for the exact purpose of scheduling events on entities, but it requires at least MC 1.20.3 since it uses macros: https://www.planetminecraft.com/data-pack/command-event-system-minecraft-1-20-2/
You just run the command as the entity:
execute as @p run function ml_ces:event/schedule/set {time:10,measure:"t",command:"say 10 tick delay"}
You can also set named events:
execute as @p run function ml_ces:event/schedule/set_named {time:10,measure:"s",command:"say 10 second delay",event:"cmd1"}
and clear them:
execute as @p run function ml_ces:event/schedule/clear {event:"cmd1"}
or use random times:
execute as @p run function ml_ces:event/schedule/set_random {min:1,max:5,measure:"s",command:"say scheduled between 1 and 5 seconds"}