Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Minecraft:Tick: Difference between revisions

From SAS Gaming Wiki
SyncBot (talk | contribs)
Remove broken links to missing pages
SyncBot (talk | contribs)
Sync: updated from Minecraft
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{for|the command|Commands/tick}}
{{about||random ticks|Random Tick|the command|Commands/tick|function uses|Tick.json}}
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'''.
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 ==
== 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  in-game day last exactly 24 000 ticks (20 minutes). However, if the computer is unable to keep up with this speed, the amount of game ticks per second (TPS) decreases. As the vast majority of actions are timed based on tick count rather than on real time, this means that many things take longer on a slower computer.
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  [[Minecraft:Daylight cycle|in-game day]] last exactly 24 000 ticks (20 minutes). However, if the computer is unable to keep up with this speed, the amount of game ticks per second (TPS) decreases. As the vast majority of actions are timed based on tick count rather than on real 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:
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:
* [[Minecraft:Hopper]]s constantly try to search for items above them. Covering a hopper with any [[Minecraft:solid block]] (except bee nests and [[Minecraft:beehive]]s), stops this check for items; composters can also be used for this purpose and are even better for performance compared to solid blocks. Alternatively, use [[Minecraft:water]] flow-based transport which is faster in bulk.
* [[Minecraft:Hopper]]s constantly try to search for items above them. Covering a hopper with any [[Minecraft:solid block]] (except [[Minecraft:bee nest]]s and [[Minecraft:beehive]]s), stops this check for items; [[Minecraft:composters]] can also be used for this purpose and are even better for performance compared to solid blocks. Alternatively, use [[Minecraft:water]] flow-based [[Minecraft:Tutorial:Item transportation|transport]] which is faster in bulk.
* [[Minecraft:Redstone components]] (especially redstone dust), as they can cause excessive amounts of block updates and/or light updates. Disabling redstone contraptions and clocks when not in use can help mitigate this.
* [[Minecraft:Redstone components]] (especially redstone dust), as they can cause excessive amounts of [[Minecraft:block updates]] and/or [[Minecraft:light]] updates. Disabling redstone contraptions and clocks when not in use can help mitigate this.
* Mob AI. Large amounts of mobs. To mitigate this, torches can be used to prevent hostile mob spawning. As for animal farms-related lag, make sure to use entity-efficient farm designs.
* [[Minecraft:Mob AI]]. Large amounts of mobs. To mitigate this, torches can be used to prevent hostile [[Minecraft:mob spawning]]. As for animal farms-related lag, make sure to use entity-efficient farm designs.
* Random Tick Speed. If the random tick speed is set too high, it can cause the MSPT to rise unusually.
* Random Tick Speed. If the random tick speed is set 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.
The MSPT value is displayed in the F3 [[Minecraft: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}}.
{{IN|java}}, tick rates can be controlled by the command {{cmd|tick}}.
Line 23: Line 23:
* Compute next tick time
* Compute next tick time
* Increment tick count
* Increment tick count
* Functions with {{code|tick}} or {{code|load}} tags are executed
* [[Minecraft:Function (Java Edition)|Functions]] with [[Minecraft:Function_(Java_Edition)#Invocation_from_function_tags|{{code|tick}} or {{code|load}} tags]] are executed
* Send time every 20 game ticks to players
* Send time every 20 game ticks to players
* Each [[Minecraft:dimension]] is ticked in order of [[Minecraft:Overworld]], the Nether, the End, and custom dimensions. For each dimension:
* Each [[Minecraft:dimension]] is ticked in order of [[Minecraft:Overworld]], the [[Minecraft:Nether]], the [[Minecraft:End]], and [[Minecraft:custom dimension]]s. For each dimension:
** Update world border bounds
** Update [[Minecraft:world border]] bounds
** Advance weather cycle
** Advance [[Minecraft:weather]] cycle
** Update daylight cycle time
** Update [[Minecraft:daylight cycle]] time
** Player [[Minecraft:Bed#Sleeping|sleeping]] logic
** Player [[Minecraft:Bed#Sleeping|sleeping]] logic
** Run [[Minecraft:Commands/schedule|scheduled]] commands
** Run [[Minecraft:Commands/schedule|scheduled]] commands
** Execute [[#Scheduled_tick|Scheduled block ticks]]
** Execute [[#Scheduled_tick|Scheduled block ticks]]
** Execute [[#Scheduled_tick|Scheduled fluid ticks]]
** Execute [[#Scheduled_tick|Scheduled fluid ticks]]
** Raid logic
** [[Minecraft:Raid]] logic
** Update chunks load level
** Update chunks [[Minecraft:Chunk#Level_and_load_type|load level]]
** For all chunks in random order:
** For all chunks in random order:
*** Spawn mobs
*** [[Minecraft:Mob spawning|Spawn]] mobs
*** Tick ice and snow
*** Tick ice and snow
*** [[#Random tick|Random ticks]]
*** [[#Random tick|Random ticks]]
** Send block changes to players
** Send block changes to players
** Update points of interest
** Update [[Minecraft:Point of Interest|points of interest]]
** Unloads chunks
** Unloads chunks
** Execute [[Minecraft:block]] events
** Execute [[Minecraft:block]] events
** Tick dragon fight
** Tick [[Minecraft:Ender Dragon|dragon]] fight
** For all non-passenger entities:
** For all [[Minecraft:Entity#Riding|non-passenger]] entities:
*** Check if it can despawn
*** Check if it can [[Minecraft:Mob spawning|despawn]]
*** Tick entity
*** Tick entity
*** Tick passengers
*** Tick passengers
Line 56: Line 56:


== Chunk tick ==
== Chunk tick ==
As a part of a game tick, specific chunks are ticked on every game tick.
As a part of a game tick, specific [[Minecraft:chunk]]s are ticked on every game tick.


{{IN|java}}, chunks with loading type of entity ticking (see Chunk) are ticked on every game tick. This primarily includes chunks in the simulation distance, but chunks loaded through other methods are also random-ticked. Mob spawning and lightning strikes require a player within 8 chunks to occur, even if the chunk is fully loaded. Precipitation-related actions and all other random tick actions (such as crop growth) do not require any player to be near the chunk.
{{IN|java}}, chunks with loading type of entity ticking (see [[Minecraft:Chunk#Level and load type]]) are ticked on every game tick. This primarily includes chunks in the simulation distance, but chunks loaded through other methods are also random-ticked. Mob spawning and lightning strikes require a player within 8 chunks to occur, even if the chunk is fully loaded. Precipitation-related actions and all other random tick actions (such as crop growth) do not require any player to be near the chunk.


{{IN|bedrock}}, all chunks inside [[Minecraft:simulation distance]] (or specified in the /tickingarea command) are ticked on every game tick.
{{IN|bedrock}}, all chunks inside [[Minecraft:simulation distance]] (or specified in the /tickingarea command) are ticked on every game tick.


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


=== Random tick ===
=== Random tick ===
Chunks 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". Subchunks that do not contain at least one block that can react to random ticks are skipped.  All blocks are a possible target of a random tick, including [[Minecraft:air]].
[[Minecraft: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". Subchunks that do not contain at least one block that can react to random ticks are skipped.  All blocks are a possible target of a random tick, including [[Minecraft:air]].


{{IN|java}}, the number of blocks chosen from each subchunk is specified by {{cmd|gamerule random_tick_speed}} (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.
{{IN|java}}, the number of blocks chosen from each subchunk is specified by {{cmd|gamerule random_tick_speed}} (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:
Most blocks ignore this tick, but some use it to do something:
*Crops may grow or uproot.
*[[Minecraft:Crops]] may grow or uproot.
*[[Minecraft:Mushroom]]s may spread or uproot.
*[[Minecraft:Mushrooms]] may spread or uproot.
*[[Minecraft:Vines]] may spread.
*{{BlockLink|Vines}} may spread.
*{{IN|BE}}, [[Minecraft:fire]] may burn out or spread.
*{{BlockLink|Fire}} may burn out or spread.{{only|bedrock|short=1}}
*[[Minecraft:Ice]] and [[Minecraft:snow]] layers may melt.
*{{BlockLink|Ice}} and {{BlockLink|snow}} layers may melt.
*[[Minecraft:Leaves]] may decay.
*{{BlockLink|Leaves}} may decay.
*[[Minecraft:Farmland]] hydration is updated.
*{{BlockLink|Farmland}} hydration is updated.
*Cacti, sugar cane, [[Minecraft:kelp]], [[Minecraft:bamboo]], chorus flowers, mangrove propagules and sweet berry bushes may grow.
*{{BlockLink|Cactus}}, {{BlockLink|sugar cane}}, {{BlockLink|kelp}}, {{BlockLink|bamboo}}, {{BlockLink|chorus flower}}s, {{BlockLink|mangrove propagule}}s and {{BlockLink|sweet berry bush}}es may grow.
*Grass blocks and [[Minecraft:mycelium]] may spread.
*{{BlockLink|Grass block}}s and {{BlockLink|mycelium}} may spread.
*Grass blocks, mycelium, and [[Minecraft:nylium]] may decay (only if the condition is met).
*{{BlockLink|Grass block}}s, {{BlockLink|mycelium}}, and {{BlockLink|nylium}} may decay (only if the condition is met).
*[[Minecraft:Sapling]]s may grow into a tree.
*[[Minecraft:Sapling]]s may grow into a [[Minecraft:tree]].
*[[Minecraft:Lava]] may set fires nearby.<ref group=note>In {{JE}}, this requires a player within an 8-chunk radius. However, {{cmd|gamerule allowFireTicksAwayFromPlayer}} removes this requirement if set to true.</ref>
*{{BlockLink|Lava}} may set fires nearby.<ref group=note>{{IN|JE}}, this requires a player within an 8-chunk radius. However, {{cmd|gamerule allowFireTicksAwayFromPlayer}} removes this requirement if set to true.</ref>
*[[Minecraft:Mud]] may turn into [[Minecraft:clay]] if placed on top of a block with pointed dripstone underneath.
*{{BlockLink|Mud}} may turn into {{BlockLink|clay}} if placed on top of a block with {{BlockLink|pointed dripstone}} underneath.
*Lit redstone ore turns off.
*Lit {{BlockLink|redstone ore}} turns off.
*Nether portal blocks may spawn a zombified piglin.
*{{BlockLink|Nether portal}} blocks may spawn a [[Minecraft:zombified piglin]].
*Turtle eggs crack or hatch.
*{{BlockLink|Turtle egg}}s crack or hatch.
*[[Minecraft:Campfire]] smoke appears.
*{{BlockLink|Campfire}} smoke appears.
*Budding amethyst may grow an amethyst bud on any of its sides as longs as there is no solid block.
*{{BlockLink|Budding amethyst}} may grow an {{BlockLink|amethyst bud}} on any of its sides as longs as there is no solid block.
*[[Minecraft:Block of Copper|Copper block]]s (or any of its non-oxidized variants) may advance one stage in oxidation.
*{{BlockLink|Block of Copper|text=Copper block}}s (or any of its non-oxidized variants) may advance one stage in [[Minecraft:oxidation]].
*Pointed dripstone may fill a cauldron below.
*{{BlockLink|pointed dripstone}} may fill a {{BlockLink|cauldron}} below.
*Pointed dripstone may grow a stalagmite/stalactite if the conditions are met.
*{{BlockLink|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 geometric distribution.
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 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 [[Minecraft:wikipedia:geometric distribution|geometric distribution]].


<references group="note"/>
<references group="note"/>


== Scheduled tick ==
== 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 repeaters schedule a tick to change state {{in|java}}, [[Minecraft:water]] schedules a tick when it needs to flow.
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, [[Minecraft:redstone repeater]]s schedule a tick to change state {{in|java}}, [[Minecraft:water]] schedules a tick when it needs to flow.


During the scheduled tick phase, each block position that had previously requested a scheduled tick for this game tick gets ticked.
During the scheduled tick phase, each block position that had previously requested a scheduled tick for this game tick gets ticked.


{{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}}, 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 [[Minecraft: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 [[Minecraft: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.
{{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.
Line 116: Line 116:
{{see also|Redstone mechanics}}
{{see also|Redstone mechanics}}
{{exclusive|bedrock|section=1}}
{{exclusive|bedrock|section=1}}
'''Redstone tick''' is a unit of time that describes a delay of two game ticks, creating a {{frac|1|10}} of a second delay.
'''Redstone tick''' is a unit of time that describes a delay of two [[Minecraft:game tick]]s, creating a {{frac|1|10}} of a second delay.
<!-- concurrent threads claim is unproven
The redstone system is calculated on concurrent threads, meaning that redstone updates are processed independently of the main game loop. This architecture utilizes a two-phase tick system, known as produce ticks (P-Ticks) and consume ticks (C-ticks), or alternatively as Output Ticks and Input Ticks.-->


The redstone system is calculated on concurrent threads, meaning that redstone updates are processed independently of the main game loop. This architecture utilizes a two-phase tick system, known as produce ticks (P-Ticks) and consume ticks (C-ticks), or alternatively as Output Ticks and Input Ticks.
The redstone system is calculated independently of the main game loop. Redstone updates are processed using two [[Minecraft:game tick]]s, split into two deterministic phases known as produce ticks (P-Ticks) and consume ticks (C-Ticks), or alternatively as Output Ticks and Input Ticks.


These two phases form a single redstone tick, which spans 2 game ticks. There are 10 redstone ticks per standard 20-game-tick second.
These two phases form a single redstone tick, which spans 2 game ticks. There are 10 redstone ticks per standard 20-game-tick second.
Line 127: Line 129:


'''Component Behavior'''
'''Component Behavior'''
*Power components (repeaters, comparators, redstone torchs, [[Minecraft:observer]]s, etc.): These components read their input side during an output/produce tick. After their configured delay, they update their output side and produce an input/consume tick.
*[[Minecraft:Power components]] ([[Minecraft:repeater]]s, [[Minecraft:comparator]]s, [[Minecraft:redstone torch]]s, [[Minecraft:observer]]s, etc.): These components read their input side during an output/produce tick. After their configured delay, they update their output side and produce an input/consume tick.
*Mechanism components ([[Minecraft:piston]]s, redstone lamps, [[Minecraft:door]]s, etc.): These components are activated during an input/consume tick and change their block state, which then creates block updates processed in the subsequent output/produce tick.
*[[Minecraft:Mechanism components]] ([[Minecraft:piston]]s, [[Minecraft:redstone lamp]]s, [[Minecraft:door]]s, etc.): These components are activated during an input/consume tick and change their block state, which then creates block updates processed in the subsequent output/produce tick.
*Redstone dust updates its power state on every game tick (20 times per second), independently of the dedicated redstone tick system. This allows it to transmit pulses with a duration of only 1 game tick. A dust line powered on an odd game tick serves as an output for components processing on P-Ticks, while one powered on an even game tick serves as an output for components on C-Ticks. This makes redstone dust one of the few components that can be "1-ticked" and used to create phase-specific pulses. Redstone dust only updates visually on output/produce ticks, meaning on input/consume tick while technically on looks visually off.  
*[[Minecraft:Redstone dust]] updates its power state on every game tick (20 times per second), independently of the dedicated redstone tick system. This allows it to transmit pulses with a duration of only 1 game tick. A dust line powered on an odd game tick serves as an output for components processing on P-Ticks, while one powered on an even game tick serves as an output for components on C-Ticks. This makes redstone dust one of the few components that can be "1-ticked" and used to create phase-specific pulses. Redstone dust only updates visually on output/produce ticks, meaning that on an input/consume tick, while technically on, it looks visually off.
*Armor stands update on both input and output ticks meaning they are one of the few redstone components that utilizes all 20 ticks. Minecarts with hoppers and minecarts with TNT might also be able to utilize all 20 game tick instead of being tied to P or C ticks.{{needs testing}}
*[[Minecraft:Armor stand]]s update on both input and output ticks, meaning they are one of the few redstone components that utilize all 20 game ticks. Other [[Minecraft:entities]] that interact with redstone, such as [[Minecraft:sulfur cube]]s that have absorbed TNT, [[Minecraft:minecarts with hoppers]], and [[Minecraft:minecarts with TNT]] might also be able to utilize all 20 game ticks instead of being tied to redstone's 10 P or C ticks.{{needs testing}}


The transmission and timing of redstone signals are determined by these ticks, which govern when redstone devices output power and when they respond to input.
The transmission and timing of redstone signals are determined by these ticks, which govern when redstone devices output power and when they respond to input.
Line 146: Line 148:
{{HistoryTable
{{HistoryTable
|{{HistoryLine|java}}
|{{HistoryLine|java}}
|{{HistoryLine||1.8|dev=14w17a|Added the game rule {{cd|randomTickSpeed}}.}}
|{{HistoryLine||1.8|dev=14w17a|Added the [[Minecraft:game rule]] {{cd|randomTickSpeed}}.}}
|{{HistoryLine||1.13|dev=18w10c|[[Minecraft:Water]] can now schedule a tick before a previous scheduled tick has finished during the scheduled tick stage in which the previous tick is executed.}}
|{{HistoryLine||1.13|dev=18w10c|[[Minecraft:Water]] can now 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|The chance of weather checks in chunk ticks is now affected by the gamerule {{cd|randomTickSpeed}}.}}
|{{HistoryLine||1.20.2|dev=23w31a|The chance of weather checks in chunk ticks is now affected by the gamerule {{cd|randomTickSpeed}}.}}
Line 168: Line 170:
[[Category:Game terms]]
[[Category:Game terms]]


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

Latest revision as of 11:15, 7 June 2026

Nearly all video games (including Minecraft) are driven by one big Template:W. 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 in-game day last exactly 24 000 ticks (20 minutes). However, if the computer is unable to keep up with this speed, the amount of game ticks per second (TPS) decreases. As the vast majority of actions are timed based on tick count rather than on real 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:

The MSPT value is displayed in the F3 Minecraft:debug screen as "ms ticks" Template:In. The frame time graph (Template:Key) 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.

Template:IN, tick rates can be controlled by the command Template:Cmd.

Template:Calculator

Game process

Template:IN, in each game loop the following actions are processed in order:

Chunk tick

As a part of a game tick, specific Minecraft:chunks are ticked on every game tick.

Template:IN, chunks with loading type of entity ticking (see Minecraft:Chunk#Level and load type) are ticked on every game tick. This primarily includes chunks in the simulation distance, but chunks loaded through other methods are also random-ticked. Mob spawning and lightning strikes require a player within 8 chunks to occur, even if the chunk is fully loaded. Precipitation-related actions and all other random tick actions (such as crop growth) do not require any player to be near the chunk.

Template:IN, all chunks inside Minecraft:simulation distance (or specified in the /tickingarea command) are ticked on every game tick.

In both editions, the following things happen when a chunk gets ticked:

Random tick

Minecraft:Chunks 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". Subchunks that do not contain at least one block that can react to random ticks are skipped. All blocks are a possible target of a random tick, including Minecraft:air.

Template:IN, the number of blocks chosen from each subchunk is specified by Template:Cmd (defaults to 3), and one block can be chosen multiple times in one chunk tick. Template:IN, it also depends on Template:Cd (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:

Because random block ticks are granted randomly, there is no way to predict when a block can receive its next tick. Template:IN, 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 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 geometric distribution.

<references group="note"/>

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, Minecraft:redstone repeaters schedule a tick to change state Template:In, Minecraft:water schedules a tick when it needs to flow.

During the scheduled tick phase, each block position that had previously requested a scheduled tick for this game tick gets ticked.

Template:IN, 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 Minecraft: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 Minecraft: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.

Template:IN, the maximum number of scheduled ticks per game tick is 65,536. Template:IN, the maximum number of scheduled ticks in a chunk per game tick is 100.

Redstone tick

Template:See also Template:Exclusive Redstone tick is a unit of time that describes a delay of two Minecraft:game ticks, creating a Template:Frac of a second delay.

The redstone system is calculated independently of the main game loop. Redstone updates are processed using two Minecraft:game ticks, split into two deterministic phases known as produce ticks (P-Ticks) and consume ticks (C-Ticks), or alternatively as Output Ticks and Input Ticks.

These two phases form a single redstone tick, which spans 2 game ticks. There are 10 redstone ticks per standard 20-game-tick second.

Tick cycle

  • Output/produce tick (Template:Va): Occurs first on odd-numbered game ticks. During this phase, components output or send their signal.
  • Input/consume tick (Template:Va): Occurs second on even-numbered game ticks. During this phase, components read or react to signals they are receiving.

Component Behavior

The transmission and timing of redstone signals are determined by these ticks, which govern when redstone devices output power and when they respond to input.

Piston tick

Template:Exclusive The piston tick is a different way to divide the game tick, based on the Immediate Update Theory by Sancarn and Selulance.<ref>Referred to as "immediate update bug" or "lever bug" in the original video https://www.youtube.com/watch?v=HCgkllZq338</ref> It was created by the Chinese redstone community in order to simplify the calculation of piston timings, but it never gained popularity in the Western community.

The piston tick starts in the entity phase of the game tick and ends in the block event phase, therefore a piston always takes 3 piston ticks to extend or retract, without any start delay. Redstone components that use scheduled ticks lose 1 piston tick of delay depending on how they are powered (for example this happens when a repeater gets powered by a redstone block that was pushed by a piston).

History

Template:Incomplete section

Java Edition

Template:HistoryTable

Bedrock Edition

Template:HistoryTable

References

Template:Reflist

Navigation

Template:Navbox Java Edition technical Template:Navbox Bedrock Edition

Minecraft:de:Tick Minecraft:es:Tic Minecraft:fr:Tick Minecraft:it:Tick Minecraft:ja:ティック Minecraft:ko:틱 Minecraft:lzh:刻 Minecraft:pl:Tick Minecraft:pt:Tique Minecraft:ru:Такт Minecraft:uk:Такт Minecraft:zh:刻