Minecraft:Commands/stopwatch: Difference between revisions
More actions
Sync: updated from Minecraft |
Sync: updated from Minecraft |
||
| Line 6: | Line 6: | ||
Allows manipulation of stopwatches to keep track of ''real'' time — the time measured is not affected by the game's tick rate (i.e. pausing, {{cmd|tick}}, or even server lag). This makes it useful to detect and compensate for lag e.g. when programming functions in a [[Minecraft:data pack]]. | Allows manipulation of stopwatches to keep track of ''real'' time — the time measured is not affected by the game's tick rate (i.e. pausing, {{cmd|tick}}, or even server lag). This makes it useful to detect and compensate for lag e.g. when programming functions in a [[Minecraft:data pack]]. | ||
Their elapsed time can be checked against a value range using <code>[[Minecraft:Commands/execute#(if%7Cunless) stopwatch|/execute (if|unless) stopwatch]]</code>. | |||
== Usage == | == Usage == | ||
Latest revision as of 11:04, 4 September 2026
Template:Exclusive Template:Infobox command
Allows manipulation of stopwatches to keep track of real time — the time measured is not affected by the game's tick rate (i.e. pausing, Template:Cmd, or even server lag). This makes it useful to detect and compensate for lag e.g. when programming functions in a Minecraft:data pack.
Their elapsed time can be checked against a value range using /execute (if|unless) stopwatch.
Usage
The time is calculated with millisecond precision. Therefore:
- When displayed, it is presented in seconds with 3 decimal places (e.g.
43.961s). - While any number can be used as the
scaleargument, ascalewith a value >1000 is not useful to extract additional precision in the integer return value.
Syntax
/stopwatch ...
... create <id>- Creates a stopwatch, which immediately begins running
... query <id> [<scale>]- Gets the value of the stopwatch, the amount of time since it was created/restarted in seconds.
... restart <id>- Restarts a stopwatch
... remove <id>- Removes a stopwatch
Arguments
- Specifies the stopwatch to operate on.
- Must be a Minecraft:resource location for an unregistered content.
- Specifies the value to multiply the returned value by, e. g.
stopwatch query foo:bar 20would get the elapsed time in ticks<ref>https://www.minecraft.net/en-us/article/minecraft-snapshot-25w42a</ref>. Does not affect the value displayed in chat. If the return value would exceed 32-bit signed integer limits (<-2147483648 or >2147483647), it is clamped.
Result
Template:Result table Template:Result table Template:Result table Template:Result table Template:Result table Template:Result table Template:Result table Template:Result table
Output
Template:Output table Template:Output table Template:Output table Template:Output table Template:Output table Template:Output table Template:Output table
History
Minecraft:de:Befehl/stopwatch Minecraft:ja:コマンド/stopwatch Minecraft:pt:Comandos/stopwatch Minecraft:zh:命令/stopwatch