GameTestTicker .java

net.minecraft.gametest.framework.GameTestTicker (class): members: SINGLETON, setRunner, testInfos, runner, State, clear, add, state, tick, LOGGER.

net.minecraft.gametest.frameworkclass63 linescommon1.6 KB

API Surface (4)

void add(final GameTestInfo testInfo)
void clear()
void setRunner(final GameTestRunner runner)
void tick()

Fields & Constants (5)

SINGLETON
LOGGER
testInfos
runner
state

String literals (1)

"The runner was already set in GameTestTicker"

Code Graph: Dependencies (3)

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

Full Source

GameTestTicker.java63 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.gametest.framework;
2
3
import com.google.common.collect.Lists;
4
import com.mojang.logging.LogUtils;
5
import java.util.Collection;
6
import net.minecraft.util.Util;
7
import org.jspecify.annotations.Nullable;
8
import org.slf4j.Logger;
9
10
public class GameTestTicker {
11
	public static final GameTestTicker SINGLETON = new GameTestTicker();
12
	private static final Logger LOGGER = LogUtils.getLogger();
13
	private final Collection<GameTestInfo> testInfos = Lists.newCopyOnWriteArrayList();
14
	private @Nullable GameTestRunner runner;
15
	private GameTestTicker.State state = GameTestTicker.State.IDLE;
16
17
	private GameTestTicker() {
18
	}
19
20
	public void add(final GameTestInfo testInfo) {
21
		this.testInfos.add(testInfo);
22
	}
23
24
	public void clear() {
25
		if (this.state != GameTestTicker.State.IDLE) {
26
			this.state = GameTestTicker.State.HALTING;
27
		} else {
28
			this.testInfos.clear();
29
			if (this.runner != null) {
30
				this.runner.stop();
31
				this.runner = null;
32
			}
33
		}
34
	}
35
36
	public void setRunner(final GameTestRunner runner) {
37
		if (this.runner != null) {
38
			Util.logAndPauseIfInIde("The runner was already set in GameTestTicker");
39
		}
40
41
		this.runner = runner;
42
	}
43
44
	public void tick() {
45
		if (this.runner != null) {
46
			this.state = GameTestTicker.State.RUNNING;
47
			this.testInfos.forEach(i -> i.tick(this.runner));
48
			this.testInfos.removeIf(GameTestInfo::isDone);
49
			GameTestTicker.State finishingState = this.state;
50
			this.state = GameTestTicker.State.IDLE;
51
			if (finishingState == GameTestTicker.State.HALTING) {
52
				this.clear();
53
			}
54
		}
55
	}
56
57
	private enum State {
58
		IDLE,
59
		RUNNING,
60
		HALTING;
61
	}
62
}
63

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