SimulationChunkTracker .java

net.minecraft.server.level.SimulationChunkTracker (class): members: runAllUpdates, chunks, getLevelFromSource, ticketStorage, MAX_LEVEL, setLevel.

net.minecraft.server.levelclass47 linesserverextends ChunkTracker1.2 KB

API Surface (5)

int getLevelFromSource(final long to)
int getLevel(final ChunkPos node)
int getLevel(final long node)
void setLevel(final long node, final int level)
void runAllUpdates()

Fields & Constants (3)

MAX_LEVEL
chunks
ticketStorage

Code Graph: Dependencies (3)

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

Full Source

SimulationChunkTracker.java47 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.server.level;
2
3
import it.unimi.dsi.fastutil.longs.Long2ByteMap;
4
import it.unimi.dsi.fastutil.longs.Long2ByteOpenHashMap;
5
import net.minecraft.world.level.ChunkPos;
6
import net.minecraft.world.level.TicketStorage;
7
8
public class SimulationChunkTracker extends ChunkTracker {
9
	public static final int MAX_LEVEL = 33;
10
	protected final Long2ByteMap chunks = new Long2ByteOpenHashMap();
11
	private final TicketStorage ticketStorage;
12
13
	public SimulationChunkTracker(final TicketStorage ticketStorage) {
14
		super(34, 16, 256);
15
		this.ticketStorage = ticketStorage;
16
		ticketStorage.setSimulationChunkUpdatedListener(this::update);
17
		this.chunks.defaultReturnValue((byte)33);
18
	}
19
20
	@Override
21
	protected int getLevelFromSource(final long to) {
22
		return this.ticketStorage.getTicketLevelAt(to, true);
23
	}
24
25
	public int getLevel(final ChunkPos node) {
26
		return this.getLevel(node.pack());
27
	}
28
29
	@Override
30
	protected int getLevel(final long node) {
31
		return this.chunks.get(node);
32
	}
33
34
	@Override
35
	protected void setLevel(final long node, final int level) {
36
		if (level >= 33) {
37
			this.chunks.remove(node);
38
		} else {
39
			this.chunks.put(node, (byte)level);
40
		}
41
	}
42
43
	public void runAllUpdates() {
44
		this.runUpdates(Integer.MAX_VALUE);
45
	}
46
}
47

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