ChunkStatus .java

net.minecraft.world.level.chunk.status.ChunkStatus (class, 113 lines): members: MAX_STRUCTURE_DISTANCE, STRUCTURE_REFERENCES, WORLDGEN_HEIGHTMAPS, TERRAIN.

net.minecraft.world.level.chunk.statusclass113 linescommon4.3 KB

API Surface (13)

List<ChunkStatus> getStatusList()
int getIndex()
ChunkStatus getParent()
ChunkType getChunkType()
ChunkStatus byName(final String key)
EnumSet<Heightmap.Types> heightmapsAfter()
boolean isOrAfter(final ChunkStatus step)
boolean isAfter(final ChunkStatus step)
boolean isOrBefore(final ChunkStatus step)
boolean isBefore(final ChunkStatus step)
ChunkStatus max(final ChunkStatus a, final ChunkStatus b)
String toString()
String getName()

Fields & Constants (19)

MAX_STRUCTURE_DISTANCE
WORLDGEN_HEIGHTMAPS
FINAL_HEIGHTMAPS
EMPTY
STRUCTURE_STARTS
STRUCTURE_REFERENCES
BIOMES
TERRAIN
FEATURES
INITIALIZE_LIGHT
LIGHT
SPAWN
FULL
CODEC
index
parent
chunkType
heightmapsAfter
heightmaps

String literals (10)

"empty"
"structure_starts"
"structure_references"
"biomes"
"terrain"
"features"
"initialize_light"
"light"
"spawn"
"full"

Code Graph: Dependencies (5)

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

Full Source

ChunkStatus.java113 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.level.chunk.status;
2
3
import com.google.common.annotations.VisibleForTesting;
4
import com.google.common.collect.Lists;
5
import com.mojang.serialization.Codec;
6
import java.util.Collections;
7
import java.util.EnumSet;
8
import java.util.List;
9
import net.minecraft.core.Registry;
10
import net.minecraft.core.registries.BuiltInRegistries;
11
import net.minecraft.resources.Identifier;
12
import net.minecraft.world.level.levelgen.Heightmap;
13
import org.jspecify.annotations.Nullable;
14
15
public class ChunkStatus {
16
	public static final int MAX_STRUCTURE_DISTANCE = 8;
17
	private static final EnumSet<Heightmap.Types> WORLDGEN_HEIGHTMAPS = EnumSet.of(Heightmap.Types.OCEAN_FLOOR_WG, Heightmap.Types.WORLD_SURFACE_WG);
18
	public static final EnumSet<Heightmap.Types> FINAL_HEIGHTMAPS = EnumSet.of(
19
		Heightmap.Types.OCEAN_FLOOR, Heightmap.Types.WORLD_SURFACE, Heightmap.Types.MOTION_BLOCKING, Heightmap.Types.MOTION_BLOCKING_NO_LEAVES
20
	);
21
	public static final ChunkStatus EMPTY = register("empty", null, WORLDGEN_HEIGHTMAPS, ChunkType.PROTOCHUNK);
22
	public static final ChunkStatus STRUCTURE_STARTS = register("structure_starts", EMPTY, WORLDGEN_HEIGHTMAPS, ChunkType.PROTOCHUNK);
23
	public static final ChunkStatus STRUCTURE_REFERENCES = register("structure_references", STRUCTURE_STARTS, WORLDGEN_HEIGHTMAPS, ChunkType.PROTOCHUNK);
24
	public static final ChunkStatus BIOMES = register("biomes", STRUCTURE_REFERENCES, WORLDGEN_HEIGHTMAPS, ChunkType.PROTOCHUNK);
25
	public static final ChunkStatus TERRAIN = register("terrain", BIOMES, FINAL_HEIGHTMAPS, ChunkType.PROTOCHUNK);
26
	public static final ChunkStatus FEATURES = register("features", TERRAIN, FINAL_HEIGHTMAPS, ChunkType.PROTOCHUNK);
27
	public static final ChunkStatus INITIALIZE_LIGHT = register("initialize_light", FEATURES, FINAL_HEIGHTMAPS, ChunkType.PROTOCHUNK);
28
	public static final ChunkStatus LIGHT = register("light", INITIALIZE_LIGHT, FINAL_HEIGHTMAPS, ChunkType.PROTOCHUNK);
29
	public static final ChunkStatus SPAWN = register("spawn", LIGHT, FINAL_HEIGHTMAPS, ChunkType.PROTOCHUNK);
30
	public static final ChunkStatus FULL = register("full", SPAWN, FINAL_HEIGHTMAPS, ChunkType.LEVELCHUNK);
31
	public static final Codec<ChunkStatus> CODEC = BuiltInRegistries.CHUNK_STATUS.byNameCodec();
32
	private final int index;
33
	private final ChunkStatus parent;
34
	private final ChunkType chunkType;
35
	private final EnumSet<Heightmap.Types> heightmapsAfter;
36
37
	private static ChunkStatus register(
38
		final String name, final @Nullable ChunkStatus parent, final EnumSet<Heightmap.Types> heightmaps, final ChunkType chunkType
39
	) {
40
		return Registry.register(BuiltInRegistries.CHUNK_STATUS, name, new ChunkStatus(parent, heightmaps, chunkType));
41
	}
42
43
	public static List<ChunkStatus> getStatusList() {
44
		List<ChunkStatus> list = Lists.newArrayList();
45
46
		ChunkStatus status;
47
		for (status = FULL; status.getParent() != status; status = status.getParent()) {
48
			list.add(status);
49
		}
50
51
		list.add(status);
52
		Collections.reverse(list);
53
		return list;
54
	}
55
56
	@VisibleForTesting
57
	protected ChunkStatus(final @Nullable ChunkStatus parent, final EnumSet<Heightmap.Types> heightmapsAfter, final ChunkType chunkType) {
58
		this.parent = parent == null ? this : parent;
59
		this.chunkType = chunkType;
60
		this.heightmapsAfter = heightmapsAfter;
61
		this.index = parent == null ? 0 : parent.getIndex() + 1;
62
	}
63
64
	public int getIndex() {
65
		return this.index;
66
	}
67
68
	public ChunkStatus getParent() {
69
		return this.parent;
70
	}
71
72
	public ChunkType getChunkType() {
73
		return this.chunkType;
74
	}
75
76
	public static ChunkStatus byName(final String key) {
77
		return BuiltInRegistries.CHUNK_STATUS.getValue(Identifier.tryParse(key));
78
	}
79
80
	public EnumSet<Heightmap.Types> heightmapsAfter() {
81
		return this.heightmapsAfter;
82
	}
83
84
	public boolean isOrAfter(final ChunkStatus step) {
85
		return this.getIndex() >= step.getIndex();
86
	}
87
88
	public boolean isAfter(final ChunkStatus step) {
89
		return this.getIndex() > step.getIndex();
90
	}
91
92
	public boolean isOrBefore(final ChunkStatus step) {
93
		return this.getIndex() <= step.getIndex();
94
	}
95
96
	public boolean isBefore(final ChunkStatus step) {
97
		return this.getIndex() < step.getIndex();
98
	}
99
100
	public static ChunkStatus max(final ChunkStatus a, final ChunkStatus b) {
101
		return a.isAfter(b) ? a : b;
102
	}
103
104
	@Override
105
	public String toString() {
106
		return this.getName();
107
	}
108
109
	public String getName() {
110
		return BuiltInRegistries.CHUNK_STATUS.getKey(this).toString();
111
	}
112
}
113

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