From Minecraft Wiki
Jump to: navigation, search

Nearly all video games (including Minecraft) are driven by one big 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[edit]

Minecraft's game loop normally runs at a fixed rate of 20 ticks per second, so one tick happens every 0.05 seconds. An in-game day lasts exactly 24000 ticks, or 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.

On each tick, various aspects of the game advance a little bit; moving objects change position, mobs check their surroundings and update their behavior, health and hunger are affected by the player's circumstances, and much more. All of this happens on the game's server, the part of the program that handles game logic (even in singleplayer mode). As a result, things the client does, such as drawing graphics, do not affect the tick rate no matter how slow or fast it runs.

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:

  • Hoppers (only if uncovered, as it tries to search for items above). Cover with any item with an inventory slot, such as a chest, ideally one with low overhead such as a dropper or composter. Alternatively, use water flow-based transport which is faster in bulk.
  • Redstone machinery. Add a switch to disable unnecessary updating and minimize air pockets to reduce lighting updates.[1]
  • Mob AI. Use torches to guide hostile mob spawning. Use more efficient farms for animals.
  • Some third-party Mods have been written to optimize or simplify certain parts of Minecraft logic to reduce lag. This wiki makes no statement of the applicability of these mods.

The MSPT value is displayed in the F3 debug screen as "ms ticks" in Java Edition. The frame time graph (Alt + F3) 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.

Chunk tick[edit]

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

In Java Edition, chunks with a load level of 31 (see Chunk#Level and load type) or below and with horizontal distance between its center and a player less than 128 blocks are ticked on every game tick.

In Bedrock Edition, all loading chunks are ticked on every game tick.

This may have various effects:

  • Mobs naturally spawn.
  • During a thunderstorm, lightning may strike somewhere in the chunk (1100000 chance).
  • 116 chance that one column is chosen for weather checks on the topmost block:
  • A certain number of blocks within the chunk receive random block ticks, as described below.

Random tick[edit]

Chunks consist of sixteen so-called sections (subchunks), each one a 16×16×16=4096 block cube. Sections are distributed vertically starting at Y=0. Every chunk tick, the number of block positions specified by /gamerule randomTickSpeed (defaults to 1‌[BE only] or 3‌[JE only]) are chosen at random from each section in the chunk. The blocks at those positions are given a "random tick". 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. The median time between ticks is 47.30 seconds (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.5% chance for the interval to be less than one second and a 1% chance for the interval to be over five minutes. On average, blocks are updated every 68.27 seconds (1365.33 game ticks). For the math behind these numbers, see the Wikipedia entries for the geometric distribution.

Scheduled tick[edit]

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, water schedules a tick when it needs to move, and stalactites[upcoming: JE 1.17] schedule a tick for a cauldron to fill with water or lava.

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

The maximum number of scheduled ticks per game tick is 65,536.

Redstone tick[edit]

A redstone tick describes two game ticks. This creates a 110 of a second delay in the signal of a redstone circuit; that is, the signal's time to travel from a location A to location B is increased by 0.1 seconds. A tick pertains only to the increase in signal time, thus, a signal's travel time can never be decreased in reference to ticks. In the context of redstone, "tick" almost always refers to redstone ticks. A redstone repeater has a delay of 1-4 redstone ticks. The default delay is 1 redstone tick, and pressing use item on the repeater increases it, visually indicated by the slider moving down the block.

Redstone ticks are actually not a "real" thing in Java Edition, but a term created by the community to make redstone easier since most redstone components have delays of multiples of 2 game ticks.