ChunkStatusFix2 .java

net.minecraft.util.datafix.fixes.ChunkStatusFix2 (class): members: RENAMES_AND_DOWNGRADES, makeRule. strings: "liquid_carved", "finalized", "lighted".

net.minecraft.util.datafix.fixesclass47 linescommonextends DataFix1.7 KB

API Surface (1)

TypeRewriteRule makeRule()

Fields & Constants (1)

RENAMES_AND_DOWNGRADES

String literals (21)

"structure_references"
"empty"
"biomes"
"base"
"surface"
"carved"
"carvers"
"liquid_carved"
"liquid_carvers"
"decorated"
"features"
"lighted"
"light"
"mobs_spawned"
"spawn"
"finalized"
"heightmaps"
"fullchunk"
"full"
"Level"
"Status"

Full Source

ChunkStatusFix2.java47 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.util.datafix.fixes;
2
3
import com.google.common.collect.ImmutableMap;
4
import com.mojang.datafixers.DSL;
5
import com.mojang.datafixers.DataFix;
6
import com.mojang.datafixers.OpticFinder;
7
import com.mojang.datafixers.TypeRewriteRule;
8
import com.mojang.datafixers.schemas.Schema;
9
import com.mojang.datafixers.types.Type;
10
import com.mojang.serialization.Dynamic;
11
import java.util.Map;
12
import java.util.Objects;
13
14
public class ChunkStatusFix2 extends DataFix {
15
	private static final Map<String, String> RENAMES_AND_DOWNGRADES = ImmutableMap.<String, String>builder()
16
		.put("structure_references", "empty")
17
		.put("biomes", "empty")
18
		.put("base", "surface")
19
		.put("carved", "carvers")
20
		.put("liquid_carved", "liquid_carvers")
21
		.put("decorated", "features")
22
		.put("lighted", "light")
23
		.put("mobs_spawned", "spawn")
24
		.put("finalized", "heightmaps")
25
		.put("fullchunk", "full")
26
		.build();
27
28
	public ChunkStatusFix2(final Schema schema, final boolean changesType) {
29
		super(schema, changesType);
30
	}
31
32
	@Override
33
	protected TypeRewriteRule makeRule() {
34
		Type<?> chunkType = this.getInputSchema().getType(References.CHUNK);
35
		Type<?> levelType = chunkType.findFieldType("Level");
36
		OpticFinder<?> levelF = DSL.fieldFinder("Level", levelType);
37
		return this.fixTypeEverywhereTyped(
38
			"ChunkStatusFix2", chunkType, this.getOutputSchema().getType(References.CHUNK), input -> input.updateTyped(levelF, level -> {
39
				Dynamic<?> tag = level.get(DSL.remainderFinder());
40
				String status = tag.get("Status").asString("empty");
41
				String newStatus = RENAMES_AND_DOWNGRADES.getOrDefault(status, "empty");
42
				return Objects.equals(status, newStatus) ? level : level.set(DSL.remainderFinder(), tag.set("Status", tag.createString(newStatus)));
43
			})
44
		);
45
	}
46
}
47

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