{{for|the command|Commands/tick}}
Nearly all video games (including ''Minecraft'') are driven by one big {{w|Control flow#Loops|program loop}}. Just as every gear in a clock is synchronized with the pendulum, every task involved in advancing a game simulation is synchronized with the game loop. Appropriately, one cycle of the game loop is called a '''tick'''.

== Game tick ==
A game tick is where ''Minecraft's'' game loop runs once. The game normally runs at a fixed rate of 20 ticks per second, so one tick happens every 0.05 seconds (50 milliseconds or 1/20 seconds), making an  [[Daylight cycle|in-game day]] last exactly 24 000 ticks (20 minutes). However, if the computer is unable to keep up with this speed, there are fewer game ticks per second (TPS). As the vast majority of actions are timed based on tick count rather than on wall clock time, this means that many things take longer on a slower computer.

A statistic related to ticks per second (TPS) is milliseconds per tick (MSPT), the time a server actually uses to compute a tick. The TPS can be maintained at 20 only if the MSPT is no higher than 50. The following often contribute to server-side lag:
* [[Hopper]]s constantly try to search for items above them. Cover with any [[solid block]] (except [[Bee Nest|bee nests]] and [[Beehive|beehives]]), as this stops the checks for items. Alternatively, use [[water]] flow-based [[Tutorials/Item transportation|transport]] which is faster in bulk.
* Redstone machinery. Redstone components, especially redstone dust cause excessive amounts of block updates and lag. Disabling redstone contraptions and clocks when not in use can help mitigate this.
* [[Mob]] AI. Use torches to guide hostile mob spawning. Use more efficient farms for animals.
* Random Tick Speed. When using the command {{cmd|gamerule randomTickSpeed}} if the chosen random tick speed is too high, it can cause the MSPT to rise unusually.

The MSPT value is displayed in the F3 [[debug screen]] as "ms ticks" {{in|java}}. The frame time graph ({{key|F3+2}}) shows the TPS value. Both displays are available only as a multiplayer host or singleplayer since the stats come from the integrated ''server'' of your ''Minecraft'' game.

{{IN|java}}, tick rates can be controlled by the command {{cmd|tick}}.

{{calculator|tick}}

== Game process ==
{{IN|java}}, in each game loop the following actions are processed in order:

* Reset next tick time if lagging 2s behind expected tick time
* Compute next tick time
* Increment tick count
* [[Function (Java Edition)|Functions]] with [[Function_(Java_Edition)#Invocation_from_function_tags|{{code|tick}} or {{code|load}} tags]] are executed
* Each [[dimension]] is ticked in order of [[overworld]], the [[nether]], the [[end]] and [[custom dimension]]s. For each dimension:
** Send time every 20 game ticks to players
** Update [[world border]] bounds
** Advance [[weather]] cycle
** Update [[Daylight cycle|daylight cycle]] time
** Player [[Bed#Sleeping|sleeping]] logic
** Run [[Commands/schedule|scheduled]] commands
** [[#Scheduled_tick|Scheduled block ticks]]
** [[#Scheduled_tick|Scheduled fluid ticks]]
** [[Raid]] logic
** Update chunks [[Chunk#Level_and_load_type|load level]]
** For all chunks in random order:
*** [[Spawn]] mobs
*** Tick ice and snow
*** [[#Random ticks|Random ticks]]
** Send block changes to players
** Update [[Point of Interest|points of interest]]
** Unloads chunks
** Execute [[block event]]s
** Tick [[Ender Dragon|dragon]] fight
** For all [[Entity#Riding|non-passenger]] entities:
*** Check if it can [[Spawn#Java_Edition_2|despawn]]
*** Tick entity
*** Tick passengers
** Tick [[Block entity|block entities]]
** Handle game events
* Send queued packets and handle incoming packets for each player
* Send player info to players
* Autosave every 6000 ticks
* Run pending tasks and wait for next tick

== Chunk tick ==
[[File:RandomTickRange.png|thumb|right|300px|The extent of random tick, shown with the spread of grass on dirt. Notice how the grass follows chunk boundaries. The red and blue arrows in the center mark the +X and +Z directions. The player is in the (7,7) location in a chunk, slightly toward the north-west corner of the chunk, which means the centers of two chunks on the edge in the -X and -Z directions are brought within the 128-block radius, thereby allowing chunk tick processing. This is confirmed by the two one-chunk grass protrusions on the northern and western edges. (North is up)]]

As a part of a game tick, specific [[chunk]]s are ticked on every game tick.

{{IN|java}}, chunks with loading type of entity ticking (see [[Chunk#Level and load type]]) ''and'' with horizontal distance between its center and a player (not in spectator mode) less than 128 blocks are ticked on every game tick. A few things should be noted here: first, the chunk should be <u>loaded</u> as an entity-ticking chunk. Second, if the chunk receives chunk tick, even if some blocks in the chunk are out of the 128-block radius, they can receive random tick as normal. Third, because 128 blocks is the <u>horizontal distance</u>, the player's position along the y-axis does not matter.

{{IN|bedrock}}, all chunks inside [[simulation distance]] (or specified in the /tickingarea command) are ticked on every game tick. Random ticking randomly occurs in blocks in ticking chunks, regardless of player position inside the chunk. The 128-block distance used in Java does not apply.

In both editions, the following things happen when a chunk gets ticked:
* Mobs naturally [[spawn]].
* During a [[thunderstorm]], lightning may strike somewhere in the chunk ({{frac|1|100000}} chance).
* {{frac|1|16}} chance that one column is chosen for weather checks on the topmost block:
** If in a cold biome, [[water]] [[Ice#Snowy biomes|freezes into ice]] if possible.
** If [[snowfall|snowing]], a [[snow|snow layer]] is placed if possible.
*** Additionally, cauldrons can be filled with [[powder snow]].
** If [[rain]]ing, a [[cauldron]] is filled with water.
* A certain number of blocks within the chunk receive random block ticks, as described below.

=== Random tick ===
[[Chunk]]s consist of one subchunk per 16 blocks of height, each one being a 16×16×16=4096 block cube. Subchunks are distributed vertically starting at the lowest y level. Every chunk tick, some blocks are chosen at random from each subchunk in the chunk. The blocks at those positions are given a "random tick".

{{IN|java}}, the number of blocks chosen from each subchunk is specified by {{cmd|gamerule randomTickSpeed}} (defaults to 3), and one block can be chosen multiple times in one chunk tick. {{IN|bedrock}}, it also depends on {{cd|randomTickSpeed}} (defaults to 1), but it specifies only relative speed instead of the exact number.

Most blocks ignore this tick, but some use it to do something:
*[[Crops]] may grow or uproot.
*[[Mushroom]]s may spread or uproot.
*[[Vines]] may spread.
*[[Fire]] may burn out or spread.
*[[Ice]] and [[snow|snow layer]]s may melt.
*[[Leaves]] may decay.
*[[Farmland]] hydration is updated.
*[[Cacti]], [[sugar cane]], [[kelp]], [[bamboo]], [[chorus flower]]s, [[Mangrove_Propagule|mangrove propagules]] and [[Sweet Berries|sweet berry bushes]] may grow.
*[[Grass Block|Grass block]]s and [[mycelium]] may spread.
*Grass blocks, mycelium, and [[nylium]] may decay (only if the condition is met).
*[[Sapling]]s may grow into a [[tree]].
*[[Lava]] may set fires nearby.
*[[Mud]] may turn into [[clay]] if placed on top of a block with [[pointed dripstone]] underneath.
*Lit [[redstone ore]] turns off.
*[[Nether Portal (block)|Nether portal block]]s may spawn a [[zombified piglin]].
*[[Turtle egg]]s crack or hatch.
*[[Campfire]] smoke appears.
*[[Budding amethyst]] may grow an [[amethyst bud]] on any of its sides as longs as there is no solid block.
*[[Block of Copper|Copper block]]s (or any of its non-oxidized variants) may advance one stage in oxidation.
*[[Pointed dripstone]] may fill a cauldron below.
*[[Pointed Dripstone|Pointed dripstone]] may grow a stalagmite/stalactite if the conditions are met.

Because random block ticks are granted randomly, there is no way to predict when a block can receive its next tick. {{IN|java}}, the ''median'' time between ticks is '''47.30''' seconds (<math>\log_{\frac{4096-3}{4096}}(0.5) \approx</math> 946.03 game ticks). That is, there is a 50% chance for the interval to be equal or shorter than 47.30 seconds and a 50% chance for it to be equal or longer than 47.30. However, sometimes it is much longer or shorter: for example, there is a 1.38% chance for the interval to be less than one second and a 1.23% chance for the interval to be over five minutes. On ''average'', blocks are updated every '''68.27''' seconds (<math>\frac{4096}{3} \approx</math> 1365.33 game ticks). For the math behind these numbers, see the Wikipedia entries for the [[wikipedia:geometric distribution|geometric distribution]].

==Scheduled tick ==
Some blocks can request a tick sometime in the future. These "scheduled ticks" are used for things that have to happen in a predictable pattern—for instance, [[redstone repeater]]s schedule a tick to change state {{in|java}}, [[water]] schedules a tick when it needs to move.

As a part of a game tick, each block position that has requested a scheduled block tick gets ticked on the specific game tick.

{{IN|java}}, there are two types of scheduled ticks: block ticks and fluid ticks. Block ticks are executed first based on priority, and then based on scheduling order. A lower value for priority results in earlier execution during the scheduled tick phase. If a [[redstone repeater]] is facing the back or side of another diode, its block tick has a priority of -3. If a redstone repeater is depowering, it has a priority of -2. Otherwise, the repeater has a priority of -1. If a redstone comparator is facing the back or side of another diode, it has a priority of -1. All other block ticks have a priority of 0. Then, each block with a scheduled fluid tick get a tick. Fluid ticks do not use priorities and are ordered based on scheduling order.

{{IN|java}}, the maximum number of scheduled ticks per game tick is 65,536. {{IN|bedrock}}, the maximum number of scheduled ticks '''in a chunk''' per game tick is 100.

==Redstone tick ==
The term '''redstone tick''' is a unit of time that describes a delay of two game ticks, creating a {{frac|1|10}} of a second delay.

{{IN|je}}, redstone ticks are actually not a "real" thing that's handled by distinct game logic, but a term coined by the community to make communication about redstone easier, since most redstone components have delays of multiples of 2 game ticks. For example, a [[redstone repeater]] can have a delay of 2, 4, 6, or 8 game ticks, which could instead be described as having a delay of 1 to 4 redstone ticks.
*The downsides of using "redstone ticks" to describe timing behavior are: it suggests a (non-existent) mandatory alignment to multiples of 2 game ticks, and that certain features (like [[scaffolding]] or [[leaves]] propagating updates, or a [[piston]] with 1gt start delay) randomly introduce "half–redstone ticks," potentially introducing to the learner the (incorrect) idea that other fractional values might exist. As a result, more specialized technical Minecraft players typically stick with game ticks as the preferred unit of measurement for delays in redstone contraptions.

{{IN|be}}, redstone ticks are actually a real thing in the game as the redstone system is calculated by concurrent threads. The transmission of the redstone signal is influenced by redstone ticks.

==Piston tick ==
{{exclusive|java|section=1}}
The Immediate Update Theory holds that [[pistons]]' start delay is 0, the entity stage to the [[block event]] stage is a game tick, or in other words, the game tick is divided by the end of [[block event]]. This type of "game tick" is called '''Piston tick(pt)'''. The start delay of [[note block]]s<!-- and [[bell]]s--> is the same as pistons, it's 0pt. The delay of [[#Scheduled tick|scheduled-tick]] components based on piston-tick timing are unfixed<!--, it will reduce 1pt delay when it reveives a synced signal-->.

== History ==
{{Incomplete section}}
{{HistoryTable
|{{HistoryLine|java}}
|{{HistoryLine||1.13|dev=18w10c|Now [[water]] can schedule a tick before a previous scheduled tick has finished during the scheduled tick stage in which the previous tick is executed.}}
|{{HistoryLine||1.20.2|dev=23w31a|Now the chance of weather checks in chunk ticks is affected by the gamerule {{cd|randomTickSpeed}}.}}
}}

== Navigation ==
{{Navbox Java Edition technical|general}}
{{Navbox Bedrock Edition}}

[[Category:Game terms]]

[[de:Tick]]
[[es:Ciclo]]
[[fr:Tick]]
[[it:Tick]]
[[ja:ティック]]
[[ko:틱]]
[[lzh:礦藝刻]]
[[pl:Tick]]
[[pt:Tick]]
[[ru:Такт]]
[[uk:Такт]]
[[zh:刻]]
