ChunkStatusFix .java

net.minecraft.util.datafix.fixes.ChunkStatusFix (class, 35 lines): members: makeRule. strings: "postprocessed", "fullchunk", "Status", "empty", "Level".

net.minecraft.util.datafix.fixesclass35 linescommonextends DataFix1.2 KB

API Surface (1)

TypeRewriteRule makeRule()

String literals (5)

"Level"
"Status"
"empty"
"postprocessed"
"fullchunk"

Full Source

ChunkStatusFix.java35 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.util.datafix.fixes;
2
3
import com.mojang.datafixers.DSL;
4
import com.mojang.datafixers.DataFix;
5
import com.mojang.datafixers.OpticFinder;
6
import com.mojang.datafixers.TypeRewriteRule;
7
import com.mojang.datafixers.schemas.Schema;
8
import com.mojang.datafixers.types.Type;
9
import com.mojang.serialization.Dynamic;
10
import java.util.Objects;
11
12
public class ChunkStatusFix extends DataFix {
13
	public ChunkStatusFix(final Schema schema, final boolean changesType) {
14
		super(schema, changesType);
15
	}
16
17
	@Override
18
	protected TypeRewriteRule makeRule() {
19
		Type<?> chunkType = this.getInputSchema().getType(References.CHUNK);
20
		Type<?> levelType = chunkType.findFieldType("Level");
21
		OpticFinder<?> levelF = DSL.fieldFinder("Level", levelType);
22
		return this.fixTypeEverywhereTyped(
23
			"ChunkStatusFix", chunkType, this.getOutputSchema().getType(References.CHUNK), input -> input.updateTyped(levelF, level -> {
24
				Dynamic<?> tag = level.get(DSL.remainderFinder());
25
				String status = tag.get("Status").asString("empty");
26
				if (Objects.equals(status, "postprocessed")) {
27
					tag = tag.set("Status", tag.createString("fullchunk"));
28
				}
29
30
				return level.set(DSL.remainderFinder(), tag);
31
			})
32
		);
33
	}
34
}
35

Decompiled Minecraft 26.3 source of ChunkStatusFix (net/minecraft/util/datafix/fixes/ChunkStatusFix.java) with Mojang official mappings, stored verbatim on the site.