WorldGenSettingsDisallowOldCustomWorldsFix .java

net.minecraft.util.datafix.fixes.WorldGenSettingsDisallowOldCustomWorldsFix (class, 36 lines): members: makeRule. strings: "dimensions". imports: Type.

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

API Surface (1)

TypeRewriteRule makeRule()

String literals (3)

"dimensions"
"WorldGenSettingsDisallowOldCustomWorldsFix_"
"Unable load old custom worlds."

Code Graph: Dependencies (1)

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

Full Source

WorldGenSettingsDisallowOldCustomWorldsFix.java36 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.util.datafix.fixes;
2
3
import com.mojang.datafixers.DataFix;
4
import com.mojang.datafixers.OpticFinder;
5
import com.mojang.datafixers.TypeRewriteRule;
6
import com.mojang.datafixers.schemas.Schema;
7
import com.mojang.datafixers.types.Type;
8
import net.minecraft.nbt.NbtFormatException;
9
10
public class WorldGenSettingsDisallowOldCustomWorldsFix extends DataFix {
11
	public WorldGenSettingsDisallowOldCustomWorldsFix(final Schema outputSchema) {
12
		super(outputSchema, false);
13
	}
14
15
	@Override
16
	protected TypeRewriteRule makeRule() {
17
		Type<?> worldGenSettingsType = this.getInputSchema().getType(References.WORLD_GEN_SETTINGS);
18
		OpticFinder<?> dimensionsFinder = worldGenSettingsType.findField("dimensions");
19
		return this.fixTypeEverywhereTyped(
20
			"WorldGenSettingsDisallowOldCustomWorldsFix_" + this.getOutputSchema().getVersionKey(),
21
			worldGenSettingsType,
22
			input -> input.updateTyped(dimensionsFinder, dimensions -> {
23
				dimensions.write().map(tag -> tag.getMapValues().map(map -> {
24
					map.forEach((key, value) -> {
25
						if (value.get("type").asString().result().isEmpty()) {
26
							throw new NbtFormatException("Unable load old custom worlds.");
27
						}
28
					});
29
					return map;
30
				}));
31
				return dimensions;
32
			})
33
		);
34
	}
35
}
36

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