SnbtDatafixer .java

net.minecraft.data.structures.SnbtDatafixer (class): members: main. strings: ".snbt". imports: DetectedVersion, Bootstrap, CachedOutput, NbtUtils.

net.minecraft.data.structuresclass41 linescommon1.3 KB

API Surface (1)

void main(final String[] args)

String literals (1)

".snbt"

Code Graph: Dependencies (9)

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

Full Source

SnbtDatafixer.java41 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.data.structures;
2
3
import com.mojang.brigadier.exceptions.CommandSyntaxException;
4
import java.io.IOException;
5
import java.nio.file.Files;
6
import java.nio.file.Path;
7
import java.nio.file.Paths;
8
import java.util.stream.Stream;
9
import net.minecraft.DetectedVersion;
10
import net.minecraft.SharedConstants;
11
import net.minecraft.data.CachedOutput;
12
import net.minecraft.nbt.CompoundTag;
13
import net.minecraft.nbt.NbtUtils;
14
import net.minecraft.server.Bootstrap;
15
16
public class SnbtDatafixer {
17
	public static void main(final String[] args) throws IOException {
18
		SharedConstants.setVersion(DetectedVersion.BUILT_IN);
19
		Bootstrap.bootStrap();
20
21
		for (String dir : args) {
22
			updateInDirectory(dir);
23
		}
24
	}
25
26
	private static void updateInDirectory(final String structureDir) throws IOException {
27
		try (Stream<Path> walk = Files.walk(Paths.get(structureDir))) {
28
			walk.filter(path -> path.toString().endsWith(".snbt")).forEach(path -> {
29
				try {
30
					String snbt = Files.readString(path);
31
					CompoundTag readSnbt = NbtUtils.snbtToStructure(snbt);
32
					CompoundTag updatedTag = StructureUpdater.update(path.toString(), readSnbt);
33
					NbtToSnbt.writeSnbt(CachedOutput.NO_CACHE, path, NbtUtils.structureToSnbt(updatedTag));
34
				} catch (CommandSyntaxException | IOException e) {
35
					throw new RuntimeException(e);
36
				}
37
			});
38
		}
39
	}
40
}
41

Decompiled Minecraft 26.3 source of SnbtDatafixer (net/minecraft/data/structures/SnbtDatafixer.java) with Mojang official mappings, stored verbatim on the site.