Minecraft mod making datapacks able to take control of some vanilla features
this mod adds commands to the game, which uncover some features to datapacks the root command is /deltatime
example:
execute store result score tickstoadd objective run deltatime tickstoadd
scoreboard players operation untilactionprevious objective = untilaction objective
scoreboard players operation untilaction objective -= tickstoadd objective
execute if score untilaction objective matches ..0 unless score untilactionp objective matches ..0 run function my:action
In this example, we are trying to run "function my:action" after "untilaction objective" ticks run. If we want to make it independant of server performance, we need to add a larger number of ticks to the counter, if the server lags. This means that there is a possibility that the counter jumps over the 0. In order to prevent the action from not executing, we need to have another variable, which tells us the tickcount before the tickstoadd get added (subtracted). Then we need to check if the previous count is higher than 0 and the current count is exactly or less than 0.
(note that if you set the counter to a lower/higher (according to the direction of counting) value while the counter is counting and you won't also change the previous count, it will execute everything in between the previous and current value)
(note that these values change after reconnect or changing gamemodes (except those that don't))

Minecraft mod making datapacks able to take control of some vanilla features like item cooldown or having a proper sense of time