diff --git a/paper-server/nms-patches/net/minecraft/server/level/PlayerChunkMap.patch b/paper-server/nms-patches/net/minecraft/server/level/PlayerChunkMap.patch index afd3fef088..074a44d2fd 100644 --- a/paper-server/nms-patches/net/minecraft/server/level/PlayerChunkMap.patch +++ b/paper-server/nms-patches/net/minecraft/server/level/PlayerChunkMap.patch @@ -1,15 +1,18 @@ --- a/net/minecraft/server/level/PlayerChunkMap.java +++ b/net/minecraft/server/level/PlayerChunkMap.java -@@ -95,6 +95,8 @@ +@@ -95,6 +95,11 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -+import org.bukkit.entity.Player; // CraftBukkit ++// CraftBukkit start ++import net.minecraft.world.level.levelgen.GeneratorSettings; ++import org.bukkit.entity.Player; ++// CraftBukkit end + public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.e { private static final byte CHUNK_TYPE_REPLACEABLE = -1; -@@ -133,6 +135,27 @@ +@@ -133,6 +138,27 @@ private final Queue unloadQueue; int viewDistance; @@ -37,7 +40,7 @@ public PlayerChunkMap(WorldServer worldserver, Convertable.ConversionSession convertable_conversionsession, DataFixer datafixer, DefinedStructureManager definedstructuremanager, Executor executor, IAsyncTaskHandler iasynctaskhandler, ILightAccess ilightaccess, ChunkGenerator chunkgenerator, WorldLoadListener worldloadlistener, ChunkStatusUpdateListener chunkstatusupdatelistener, Supplier supplier, int i, boolean flag) { super(convertable_conversionsession.getDimensionPath(worldserver.dimension()).resolve("region"), datafixer, flag); this.visibleChunkMap = this.updatingChunkMap.clone(); -@@ -326,9 +349,12 @@ +@@ -326,9 +352,12 @@ return completablefuture1.thenApply((list1) -> { List list2 = Lists.newArrayList(); @@ -52,7 +55,7 @@ final Either either = (Either) iterator.next(); Optional optional = either.left(); -@@ -435,7 +461,7 @@ +@@ -435,7 +464,7 @@ this.flushWorker(); } else { this.visibleChunkMap.values().stream().filter(PlayerChunk::wasAccessibleSinceLastSave).forEach((playerchunk) -> { @@ -61,7 +64,7 @@ if (ichunkaccess instanceof ProtoChunkExtension || ichunkaccess instanceof Chunk) { this.save(ichunkaccess); -@@ -488,7 +514,7 @@ +@@ -488,7 +517,7 @@ private void scheduleUnload(long i, PlayerChunk playerchunk) { CompletableFuture completablefuture = playerchunk.getChunkToSave(); @@ -70,7 +73,7 @@ CompletableFuture completablefuture1 = playerchunk.getChunkToSave(); if (completablefuture1 != completablefuture) { -@@ -664,7 +690,21 @@ +@@ -664,7 +693,21 @@ private static void postLoadProtoChunk(WorldServer worldserver, List list) { if (!list.isEmpty()) { @@ -93,7 +96,7 @@ } } -@@ -894,7 +934,8 @@ +@@ -894,7 +937,8 @@ return ichunkaccess instanceof Chunk ? Optional.of((Chunk) ichunkaccess) : Optional.empty(); }); @@ -103,7 +106,7 @@ return chunk.getBlockEntities().size(); }).orElse(0), tickingtracker.getTicketDebugString(i), tickingtracker.getLevel(i), optional1.map((chunk) -> { return chunk.getBlockTicks().count(); -@@ -907,7 +948,7 @@ +@@ -907,7 +951,7 @@ private static String printFuture(CompletableFuture> completablefuture) { try { @@ -112,16 +115,16 @@ return either != null ? (String) either.map((chunk) -> { return "done"; -@@ -925,7 +966,7 @@ +@@ -925,7 +969,7 @@ private NBTTagCompound readChunk(ChunkCoordIntPair chunkcoordintpair) throws IOException { NBTTagCompound nbttagcompound = this.read(chunkcoordintpair); - return nbttagcompound == null ? null : this.upgradeChunkTag(this.level.dimension(), this.overworldDataStorage, nbttagcompound, this.generator.getTypeNameForDataFixer()); -+ return nbttagcompound == null ? null : this.upgradeChunkTag(this.level.getTypeKey(), this.overworldDataStorage, nbttagcompound, this.generator.getTypeNameForDataFixer(), chunkcoordintpair, level); // CraftBukkit ++ return nbttagcompound == null ? null : this.upgradeChunkTag(GeneratorSettings.levelToLevelStem(this.level.getTypeKey()), this.overworldDataStorage, nbttagcompound, this.generator.getTypeNameForDataFixer(), chunkcoordintpair, level); // CraftBukkit } boolean anyPlayerCloseEnoughForSpawning(ChunkCoordIntPair chunkcoordintpair) { -@@ -1349,7 +1390,7 @@ +@@ -1349,7 +1393,7 @@ public final Set seenBy = Sets.newIdentityHashSet(); public EntityTracker(Entity entity, int i, int j, boolean flag) { @@ -130,7 +133,7 @@ this.entity = entity; this.range = i; this.lastSectionPos = SectionPosition.of(entity); -@@ -1402,12 +1443,20 @@ +@@ -1402,12 +1446,20 @@ public void updatePlayer(EntityPlayer entityplayer) { if (entityplayer != this.entity) { diff --git a/paper-server/nms-patches/net/minecraft/util/worldupdate/WorldUpgrader.patch b/paper-server/nms-patches/net/minecraft/util/worldupdate/WorldUpgrader.patch index f30ef34c84..c374c11ead 100644 --- a/paper-server/nms-patches/net/minecraft/util/worldupdate/WorldUpgrader.patch +++ b/paper-server/nms-patches/net/minecraft/util/worldupdate/WorldUpgrader.patch @@ -5,7 +5,7 @@ import org.apache.logging.log4j.Logger; +// CraftBukkit start -+import net.minecraft.world.level.dimension.DimensionManager; ++import net.minecraft.world.level.dimension.WorldDimension; +// CraftBukkit end + public class WorldUpgrader { @@ -16,7 +16,7 @@ private volatile int converted; private volatile int skipped; - private final Object2FloatMap> progressMap = Object2FloatMaps.synchronize(new Object2FloatOpenCustomHashMap(SystemUtils.identityStrategy())); -+ private final Object2FloatMap> progressMap = Object2FloatMaps.synchronize(new Object2FloatOpenCustomHashMap(SystemUtils.identityStrategy())); // CraftBukkit ++ private final Object2FloatMap> progressMap = Object2FloatMaps.synchronize(new Object2FloatOpenCustomHashMap(SystemUtils.identityStrategy())); // CraftBukkit private volatile IChatBaseComponent status = new ChatMessage("optimizeWorld.stage.counting"); private static final Pattern REGEX = Pattern.compile("^r\\.(-?[0-9]+)\\.(-?[0-9]+)\\.mca$"); private final WorldPersistentData overworldDataStorage; @@ -26,14 +26,14 @@ this.totalChunks = 0; - Builder, ListIterator> builder = ImmutableMap.builder(); - ImmutableSet> immutableset = this.worldGenSettings.levels(); -+ Builder, ListIterator> builder = ImmutableMap.builder(); // CraftBukkit -+ ImmutableSet> immutableset = this.worldGenSettings.levels(); // CraftBukkit ++ Builder, ListIterator> builder = ImmutableMap.builder(); // CraftBukkit ++ ImmutableSet> immutableset = ImmutableSet.of(levelStorage.dimensionType); // CraftBukkit List list; for (UnmodifiableIterator unmodifiableiterator = immutableset.iterator(); unmodifiableiterator.hasNext(); this.totalChunks += list.size()) { - ResourceKey resourcekey = (ResourceKey) unmodifiableiterator.next(); -+ ResourceKey resourcekey = (ResourceKey) unmodifiableiterator.next(); // CraftBukkit ++ ResourceKey resourcekey = (ResourceKey) unmodifiableiterator.next(); // CraftBukkit list = this.getAllChunkPos(resourcekey); builder.put(resourcekey, list.listIterator()); @@ -43,21 +43,21 @@ float f = (float) this.totalChunks; - ImmutableMap, ListIterator> immutablemap = builder.build(); - Builder, IChunkLoader> builder1 = ImmutableMap.builder(); -+ ImmutableMap, ListIterator> immutablemap = builder.build(); // CraftBukkit -+ Builder, IChunkLoader> builder1 = ImmutableMap.builder(); // CraftBukkit ++ ImmutableMap, ListIterator> immutablemap = builder.build(); // CraftBukkit ++ Builder, IChunkLoader> builder1 = ImmutableMap.builder(); // CraftBukkit UnmodifiableIterator unmodifiableiterator1 = immutableset.iterator(); while (unmodifiableiterator1.hasNext()) { - ResourceKey resourcekey1 = (ResourceKey) unmodifiableiterator1.next(); - Path path = this.levelStorage.getDimensionPath(resourcekey1); -+ ResourceKey resourcekey1 = (ResourceKey) unmodifiableiterator1.next(); // CraftBukkit ++ ResourceKey resourcekey1 = (ResourceKey) unmodifiableiterator1.next(); // CraftBukkit + Path path = this.levelStorage.getDimensionPath((ResourceKey) null); // CraftBukkit builder1.put(resourcekey1, new IChunkLoader(path.resolve("region"), this.dataFixer, true)); } - ImmutableMap, IChunkLoader> immutablemap1 = builder1.build(); -+ ImmutableMap, IChunkLoader> immutablemap1 = builder1.build(); // CraftBukkit ++ ImmutableMap, IChunkLoader> immutablemap1 = builder1.build(); // CraftBukkit long i = SystemUtils.getMillis(); this.status = new ChatMessage("optimizeWorld.stage.upgrading"); @@ -66,12 +66,16 @@ for (UnmodifiableIterator unmodifiableiterator2 = immutableset.iterator(); unmodifiableiterator2.hasNext(); f1 += f2) { - ResourceKey resourcekey2 = (ResourceKey) unmodifiableiterator2.next(); -+ ResourceKey resourcekey2 = (ResourceKey) unmodifiableiterator2.next(); // CraftBukkit ++ ResourceKey resourcekey2 = (ResourceKey) unmodifiableiterator2.next(); // CraftBukkit ListIterator listiterator = (ListIterator) immutablemap.get(resourcekey2); IChunkLoader ichunkloader = (IChunkLoader) immutablemap1.get(resourcekey2); -@@ -141,7 +145,7 @@ - ChunkGenerator chunkgenerator = ((WorldDimension) this.worldGenSettings.dimensions().get(GeneratorSettings.levelToLevelStem(resourcekey2))).generator(); +@@ -138,10 +142,10 @@ + + if (nbttagcompound != null) { + int j = IChunkLoader.getVersion(nbttagcompound); +- ChunkGenerator chunkgenerator = ((WorldDimension) this.worldGenSettings.dimensions().get(GeneratorSettings.levelToLevelStem(resourcekey2))).generator(); ++ ChunkGenerator chunkgenerator = ((WorldDimension) this.worldGenSettings.dimensions().get(resourcekey2)).generator(); // CraftBukkit NBTTagCompound nbttagcompound1 = ichunkloader.upgradeChunkTag(resourcekey2, () -> { return this.overworldDataStorage; - }, nbttagcompound, chunkgenerator.getTypeNameForDataFixer()); @@ -85,7 +89,7 @@ - private List getAllChunkPos(ResourceKey resourcekey) { - File file = this.levelStorage.getDimensionPath(resourcekey).toFile(); -+ private List getAllChunkPos(ResourceKey resourcekey) { // CraftBukkit ++ private List getAllChunkPos(ResourceKey resourcekey) { // CraftBukkit + File file = this.levelStorage.getDimensionPath((ResourceKey) null).toFile(); // CraftBukkit File file1 = new File(file, "region"); File[] afile = file1.listFiles((file2, s) -> { diff --git a/paper-server/nms-patches/net/minecraft/world/level/chunk/storage/IChunkLoader.patch b/paper-server/nms-patches/net/minecraft/world/level/chunk/storage/IChunkLoader.patch index 610585e48d..99a27f30d6 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/chunk/storage/IChunkLoader.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/chunk/storage/IChunkLoader.patch @@ -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 resourcekey, Supplier supplier, NBTTagCompound nbttagcompound, Optional>> optional, ChunkCoordIntPair pos, @Nullable GeneratorAccess generatoraccess) throws IOException { ++ public NBTTagCompound upgradeChunkTag(ResourceKey resourcekey, Supplier supplier, NBTTagCompound nbttagcompound, Optional>> 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 resourcekey, Optional>> optional) { -+ public static void injectDatafixingContext(NBTTagCompound nbttagcompound, ResourceKey resourcekey, Optional>> optional) { // CraftBukkit ++ public static void injectDatafixingContext(NBTTagCompound nbttagcompound, ResourceKey resourcekey, Optional>> optional) { // CraftBukkit NBTTagCompound nbttagcompound1 = new NBTTagCompound(); nbttagcompound1.putString("dimension", resourcekey.location().toString()); diff --git a/paper-server/nms-patches/net/minecraft/world/level/levelgen/GeneratorSettings.patch b/paper-server/nms-patches/net/minecraft/world/level/levelgen/GeneratorSettings.patch index d959185597..0980087a0e 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/levelgen/GeneratorSettings.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/levelgen/GeneratorSettings.patch @@ -34,31 +34,16 @@ } } -@@ -159,17 +164,19 @@ - } - } - -- public ImmutableSet> levels() { -+ // CraftBukkit start -+ public ImmutableSet> levels() { - return (ImmutableSet) this.dimensions().entrySet().stream().map(Entry::getKey).map(GeneratorSettings::levelStemToLevel).collect(ImmutableSet.toImmutableSet()); - } - -- public static ResourceKey levelStemToLevel(ResourceKey resourcekey) { -- return ResourceKey.create(IRegistry.DIMENSION_REGISTRY, resourcekey.location()); -+ public static ResourceKey levelStemToLevel(ResourceKey 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 levelToLevelStem(ResourceKey resourcekey) { -+ public static ResourceKey levelToLevelStem(ResourceKey resourcekey) { ++ public static ResourceKey levelToLevelStem(ResourceKey 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(); diff --git a/paper-server/nms-patches/net/minecraft/world/level/levelgen/structure/PersistentStructureLegacy.patch b/paper-server/nms-patches/net/minecraft/world/level/levelgen/structure/PersistentStructureLegacy.patch index 2a9a079a88..380b7109c6 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/levelgen/structure/PersistentStructureLegacy.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/levelgen/structure/PersistentStructureLegacy.patch @@ -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 resourcekey, @Nullable WorldPersistentData worldpersistentdata) { - if (resourcekey == World.OVERWORLD) { -+ public static PersistentStructureLegacy getLegacyStructureHandler(ResourceKey resourcekey, @Nullable WorldPersistentData worldpersistentdata) { // CraftBukkit -+ if (resourcekey == DimensionManager.OVERWORLD_LOCATION) { // CraftBukkit ++ public static PersistentStructureLegacy getLegacyStructureHandler(ResourceKey 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 { diff --git a/paper-server/nms-patches/net/minecraft/world/level/storage/Convertable.patch b/paper-server/nms-patches/net/minecraft/world/level/storage/Convertable.patch index ab6b63169f..f8540f5f17 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/storage/Convertable.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/storage/Convertable.patch @@ -42,7 +42,7 @@ private final String levelId; private final Map resources = Maps.newHashMap(); + // CraftBukkit start -+ private final ResourceKey dimensionType; ++ public final ResourceKey dimensionType; - public ConversionSession(String s) throws IOException { + public ConversionSession(String s, ResourceKey dimensionType) throws IOException {