2024-04-24 01:15:00 +10:00

109 lines
4.8 KiB
Diff

--- a/net/minecraft/world/level/storage/Convertable.java
+++ b/net/minecraft/world/level/storage/Convertable.java
@@ -77,6 +77,10 @@
import net.minecraft.world.level.validation.PathAllowList;
import org.slf4j.Logger;
+// CraftBukkit start
+import net.minecraft.world.level.dimension.WorldDimension;
+// CraftBukkit end
+
public class Convertable {
static final Logger LOGGER = LogUtils.getLogger();
@@ -148,7 +152,7 @@
}
public static WorldDataConfiguration readDataConfig(Dynamic<?> dynamic) {
- DataResult dataresult = WorldDataConfiguration.CODEC.parse(dynamic);
+ DataResult<WorldDataConfiguration> dataresult = WorldDataConfiguration.CODEC.parse(dynamic); // CraftBukkit - decompile error
Logger logger = Convertable.LOGGER;
Objects.requireNonNull(logger);
@@ -167,6 +171,7 @@
WorldDimensions.b worlddimensions_b = generatorsettings.dimensions().bake(iregistry);
Lifecycle lifecycle = worlddimensions_b.lifecycle().add(iregistrycustom_dimension.allRegistriesLifecycle());
WorldDataServer worlddataserver = WorldDataServer.parse(dynamic1, worldsettings, worlddimensions_b.specialWorldProperty(), generatorsettings.options(), lifecycle);
+ worlddataserver.pdc = ((Dynamic<NBTBase>) dynamic1).getElement("BukkitValues", null); // CraftBukkit - Add PDC to world
return new LevelDataAndDimensions(worlddataserver, worlddimensions_b);
}
@@ -409,27 +414,41 @@
return this.backupDir;
}
- public Convertable.ConversionSession validateAndCreateAccess(String s) throws IOException, ContentValidationException {
+ public Convertable.ConversionSession validateAndCreateAccess(String s, ResourceKey<WorldDimension> dimensionType) throws IOException, ContentValidationException { // CraftBukkit
Path path = this.getLevelPath(s);
List<ForbiddenSymlinkInfo> list = this.worldDirValidator.validateDirectory(path, true);
if (!list.isEmpty()) {
throw new ContentValidationException(path, list);
} else {
- return new Convertable.ConversionSession(s, path);
+ return new Convertable.ConversionSession(s, path, dimensionType); // CraftBukkit
}
}
- public Convertable.ConversionSession createAccess(String s) throws IOException {
+ public Convertable.ConversionSession createAccess(String s, ResourceKey<WorldDimension> dimensionType) throws IOException { // CraftBukkit
Path path = this.getLevelPath(s);
- return new Convertable.ConversionSession(s, path);
+ return new Convertable.ConversionSession(s, path, dimensionType); // CraftBukkit
}
public DirectoryValidator getWorldDirValidator() {
return this.worldDirValidator;
}
+ // CraftBukkit start
+ public static Path getStorageFolder(Path path, ResourceKey<WorldDimension> dimensionType) {
+ if (dimensionType == WorldDimension.OVERWORLD) {
+ return path;
+ } else if (dimensionType == WorldDimension.NETHER) {
+ return path.resolve("DIM-1");
+ } else if (dimensionType == WorldDimension.END) {
+ return path.resolve("DIM1");
+ } else {
+ return path.resolve("dimensions").resolve(dimensionType.location().getNamespace()).resolve(dimensionType.location().getPath());
+ }
+ }
+ // CraftBukkit end
+
public static record a(List<Convertable.b> levels) implements Iterable<Convertable.b> {
public boolean isEmpty() {
@@ -488,8 +507,12 @@
public final Convertable.b levelDirectory;
private final String levelId;
private final Map<SavedFile, Path> resources = Maps.newHashMap();
+ // CraftBukkit start
+ public final ResourceKey<WorldDimension> dimensionType;
- ConversionSession(final String s, final Path path) throws IOException {
+ ConversionSession(final String s, final Path path, final ResourceKey<WorldDimension> dimensionType) throws IOException {
+ this.dimensionType = dimensionType;
+ // CraftBukkit end
this.levelId = s;
this.levelDirectory = new Convertable.b(path);
this.lock = SessionLock.create(path);
@@ -529,7 +552,7 @@
}
public Path getLevelPath(SavedFile savedfile) {
- Map map = this.resources;
+ Map<SavedFile, Path> map = this.resources; // CraftBukkit - decompile error
Convertable.b convertable_b = this.levelDirectory;
Objects.requireNonNull(this.levelDirectory);
@@ -537,7 +560,7 @@
}
public Path getDimensionPath(ResourceKey<World> resourcekey) {
- return DimensionManager.getStorageFolder(resourcekey, this.levelDirectory.path());
+ return getStorageFolder(this.levelDirectory.path(), this.dimensionType); // CraftBukkit
}
private void checkLock() {