SPIGOT-6802: Fix major issues with --forceUpgrade

More to come

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot
2021-11-23 17:13:52 +11:00
parent 90f6dfa935
commit 820ad30036
6 changed files with 46 additions and 54 deletions

View File

@@ -9,7 +9,7 @@
+import net.minecraft.server.level.WorldServer;
+import net.minecraft.world.level.GeneratorAccess;
+import net.minecraft.world.level.chunk.ChunkStatus;
+import net.minecraft.world.level.dimension.DimensionManager;
+import net.minecraft.world.level.dimension.WorldDimension;
+// CraftBukkit end
+
public class IChunkLoader implements AutoCloseable {
@@ -46,7 +46,7 @@
+ return false;
+ }
+
+ public NBTTagCompound upgradeChunkTag(ResourceKey<DimensionManager> resourcekey, Supplier<WorldPersistentData> supplier, NBTTagCompound nbttagcompound, Optional<ResourceKey<Codec<? extends ChunkGenerator>>> optional, ChunkCoordIntPair pos, @Nullable GeneratorAccess generatoraccess) throws IOException {
+ public NBTTagCompound upgradeChunkTag(ResourceKey<WorldDimension> resourcekey, Supplier<WorldPersistentData> supplier, NBTTagCompound nbttagcompound, Optional<ResourceKey<Codec<? extends ChunkGenerator>>> optional, ChunkCoordIntPair pos, @Nullable GeneratorAccess generatoraccess) throws IOException {
+ // CraftBukkit end
int i = getVersion(nbttagcompound);
@@ -70,7 +70,7 @@
}
- public static void injectDatafixingContext(NBTTagCompound nbttagcompound, ResourceKey<World> resourcekey, Optional<ResourceKey<Codec<? extends ChunkGenerator>>> optional) {
+ public static void injectDatafixingContext(NBTTagCompound nbttagcompound, ResourceKey<DimensionManager> resourcekey, Optional<ResourceKey<Codec<? extends ChunkGenerator>>> optional) { // CraftBukkit
+ public static void injectDatafixingContext(NBTTagCompound nbttagcompound, ResourceKey<WorldDimension> resourcekey, Optional<ResourceKey<Codec<? extends ChunkGenerator>>> optional) { // CraftBukkit
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
nbttagcompound1.putString("dimension", resourcekey.location().toString());

View File

@@ -34,31 +34,16 @@
}
}
@@ -159,17 +164,19 @@
}
}
- public ImmutableSet<ResourceKey<World>> levels() {
+ // CraftBukkit start
+ public ImmutableSet<ResourceKey<DimensionManager>> levels() {
return (ImmutableSet) this.dimensions().entrySet().stream().map(Entry::getKey).map(GeneratorSettings::levelStemToLevel).collect(ImmutableSet.toImmutableSet());
}
- public static ResourceKey<World> levelStemToLevel(ResourceKey<WorldDimension> resourcekey) {
- return ResourceKey.create(IRegistry.DIMENSION_REGISTRY, resourcekey.location());
+ public static ResourceKey<DimensionManager> levelStemToLevel(ResourceKey<WorldDimension> resourcekey) {
+ return ResourceKey.create(IRegistry.DIMENSION_TYPE_REGISTRY, resourcekey.location());
@@ -167,7 +172,7 @@
return ResourceKey.create(IRegistry.DIMENSION_REGISTRY, resourcekey.location());
}
- public static ResourceKey<WorldDimension> levelToLevelStem(ResourceKey<World> resourcekey) {
+ public static ResourceKey<WorldDimension> levelToLevelStem(ResourceKey<DimensionManager> resourcekey) {
+ public static ResourceKey<WorldDimension> levelToLevelStem(ResourceKey<DimensionManager> resourcekey) { // CraftBukkit
return ResourceKey.create(IRegistry.LEVEL_STEM_REGISTRY, resourcekey.location());
}
+ // CraftBukkit end
public boolean isDebug() {
return this.overworld() instanceof ChunkProviderDebug;
@@ -246,7 +253,7 @@
@@ -246,7 +251,7 @@
switch (b0) {
case 0:
JsonObject jsonobject = !s.isEmpty() ? ChatDeserializer.parse(s) : new JsonObject();

View File

@@ -5,7 +5,7 @@
import net.minecraft.world.level.storage.WorldPersistentData;
+// CraftBukkit start
+import net.minecraft.world.level.dimension.DimensionManager;
+import net.minecraft.world.level.dimension.WorldDimension;
+// CraftBukkit end
+
public class PersistentStructureLegacy {
@@ -17,18 +17,18 @@
- public static PersistentStructureLegacy getLegacyStructureHandler(ResourceKey<World> resourcekey, @Nullable WorldPersistentData worldpersistentdata) {
- if (resourcekey == World.OVERWORLD) {
+ public static PersistentStructureLegacy getLegacyStructureHandler(ResourceKey<DimensionManager> resourcekey, @Nullable WorldPersistentData worldpersistentdata) { // CraftBukkit
+ if (resourcekey == DimensionManager.OVERWORLD_LOCATION) { // CraftBukkit
+ public static PersistentStructureLegacy getLegacyStructureHandler(ResourceKey<WorldDimension> resourcekey, @Nullable WorldPersistentData worldpersistentdata) { // CraftBukkit
+ if (resourcekey == WorldDimension.OVERWORLD) { // CraftBukkit
return new PersistentStructureLegacy(worldpersistentdata, ImmutableList.of("Monument", "Stronghold", "Village", "Mineshaft", "Temple", "Mansion"), ImmutableList.of("Village", "Mineshaft", "Mansion", "Igloo", "Desert_Pyramid", "Jungle_Pyramid", "Swamp_Hut", "Stronghold", "Monument"));
} else {
ImmutableList immutablelist;
- if (resourcekey == World.NETHER) {
+ if (resourcekey == DimensionManager.NETHER_LOCATION) { // CraftBukkit
+ if (resourcekey == WorldDimension.NETHER) { // CraftBukkit
immutablelist = ImmutableList.of("Fortress");
return new PersistentStructureLegacy(worldpersistentdata, immutablelist, immutablelist);
- } else if (resourcekey == World.END) {
+ } else if (resourcekey == DimensionManager.END_LOCATION) { // CraftBukkit
+ } else if (resourcekey == WorldDimension.END) { // CraftBukkit
immutablelist = ImmutableList.of("EndCity");
return new PersistentStructureLegacy(worldpersistentdata, immutablelist, immutablelist);
} else {

View File

@@ -42,7 +42,7 @@
private final String levelId;
private final Map<SavedFile, Path> resources = Maps.newHashMap();
+ // CraftBukkit start
+ private final ResourceKey<WorldDimension> dimensionType;
+ public final ResourceKey<WorldDimension> dimensionType;
- public ConversionSession(String s) throws IOException {
+ public ConversionSession(String s, ResourceKey<WorldDimension> dimensionType) throws IOException {