TickRateManager .java

net.minecraft.world.TickRateManager (class, 67 lines): members: millisecondsPerTick, setFrozenTicksToRun, nanosecondsPerTick, isSteppingForward, tickrate.

net.minecraft.worldclass67 linescommon1.6 KB

API Surface (12)

void setTickRate(final float rate)
float tickrate()
float millisecondsPerTick()
long nanosecondsPerTick()
boolean runsNormally()
boolean isSteppingForward()
void setFrozenTicksToRun(final int timeout)
int frozenTicksToRun()
void setFrozen(final boolean state)
boolean isFrozen()
void tick()
boolean isEntityFrozen(final Entity entity)

Fields & Constants (6)

MIN_TICKRATE
tickrate
nanosecondsPerTick
frozenTicksToRun
runGameElements
isFrozen

Code Graph: Dependencies (3)

Edges (calls / imports / inherits / references) resolved by graphify from the AST. Every chip opens the class source.

Full Source

TickRateManager.java67 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world;
2
3
import net.minecraft.util.TimeUtil;
4
import net.minecraft.world.entity.Entity;
5
import net.minecraft.world.entity.player.Player;
6
7
public class TickRateManager {
8
	public static final float MIN_TICKRATE = 1.0F;
9
	protected float tickrate = 20.0F;
10
	protected long nanosecondsPerTick = TimeUtil.NANOSECONDS_PER_SECOND / 20L;
11
	protected int frozenTicksToRun = 0;
12
	protected boolean runGameElements = true;
13
	protected boolean isFrozen = false;
14
15
	public void setTickRate(final float rate) {
16
		this.tickrate = Math.max(rate, 1.0F);
17
		this.nanosecondsPerTick = (long)((double)TimeUtil.NANOSECONDS_PER_SECOND / this.tickrate);
18
	}
19
20
	public float tickrate() {
21
		return this.tickrate;
22
	}
23
24
	public float millisecondsPerTick() {
25
		return (float)this.nanosecondsPerTick / (float)TimeUtil.NANOSECONDS_PER_MILLISECOND;
26
	}
27
28
	public long nanosecondsPerTick() {
29
		return this.nanosecondsPerTick;
30
	}
31
32
	public boolean runsNormally() {
33
		return this.runGameElements;
34
	}
35
36
	public boolean isSteppingForward() {
37
		return this.frozenTicksToRun > 0;
38
	}
39
40
	public void setFrozenTicksToRun(final int timeout) {
41
		this.frozenTicksToRun = timeout;
42
	}
43
44
	public int frozenTicksToRun() {
45
		return this.frozenTicksToRun;
46
	}
47
48
	public void setFrozen(final boolean state) {
49
		this.isFrozen = state;
50
	}
51
52
	public boolean isFrozen() {
53
		return this.isFrozen;
54
	}
55
56
	public void tick() {
57
		this.runGameElements = !this.isFrozen || this.frozenTicksToRun > 0;
58
		if (this.frozenTicksToRun > 0) {
59
			this.frozenTicksToRun--;
60
		}
61
	}
62
63
	public boolean isEntityFrozen(final Entity entity) {
64
		return !this.runsNormally() && !(entity instanceof Player) && entity.countPlayerPassengers() <= 0;
65
	}
66
}
67

Decompiled Minecraft 26.3 source of TickRateManager (net/minecraft/world/TickRateManager.java) with Mojang official mappings, stored verbatim on the site.