From f1dee4ff69e937602be9d8ceaf62ec4301892d55 Mon Sep 17 00:00:00 2001 From: Jake Potrebic Date: Mon, 28 Feb 2022 14:02:20 -0800 Subject: [PATCH] 1.18.2 compiles successfuly now --- ...ies-option-to-debug-dupe-uuid-issues.patch | 19 +++++++++---------- patches/server/Anti-Xray.patch | 3 ++- .../Asynchronous-chunk-IO-and-loading.patch | 8 ++++---- ...culate-regionfile-header-if-it-is-co.patch | 2 +- ...-profile-lookups-to-worldgen-threads.patch | 2 +- ...-Chunk-Post-Processing-deadlock-risk.patch | 4 ++-- ...t-isSectionEmpty-int-and-optimize-Pa.patch | 5 ++--- ...chunks-refusing-to-unload-at-low-TPS.patch | 6 +++--- ...og-when-the-async-catcher-is-tripped.patch | 2 +- .../Replace-player-chunk-loader-system.patch | 4 ++-- 10 files changed, 27 insertions(+), 28 deletions(-) diff --git a/patches/server/Add-Debug-Entities-option-to-debug-dupe-uuid-issues.patch b/patches/server/Add-Debug-Entities-option-to-debug-dupe-uuid-issues.patch index c6681ecef0..86535889ed 100644 --- a/patches/server/Add-Debug-Entities-option-to-debug-dupe-uuid-issues.patch +++ b/patches/server/Add-Debug-Entities-option-to-debug-dupe-uuid-issues.patch @@ -80,7 +80,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 private CraftEntity bukkitEntity; + public @org.jetbrains.annotations.Nullable net.minecraft.server.level.ChunkMap.TrackedEntity tracker; // Paper -+ public Throwable addedToWorldStack; // Paper - entity debug ++ public @Nullable Throwable addedToWorldStack; // Paper - entity debug public CraftEntity getBukkitEntity() { if (this.bukkitEntity == null) { this.bukkitEntity = CraftEntity.getEntity(this.level.getCraftServer(), this); @@ -114,22 +114,21 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 if (this.byUuid.containsKey(uUID)) { LOGGER.warn("Duplicate entity UUID {}: {}", uUID, entity); + // Paper start - extra debug info -+ if (entity instanceof net.minecraft.world.entity.Entity) { ++ if (entity instanceof net.minecraft.world.entity.Entity entityCast) { + if (net.minecraft.server.level.ServerLevel.DEBUG_ENTITIES) { -+ ((net.minecraft.world.entity.Entity) entity).addedToWorldStack = net.minecraft.server.level.ServerLevel.getAddToWorldStackTrace((net.minecraft.world.entity.Entity) entity); ++ entityCast.addedToWorldStack = net.minecraft.server.level.ServerLevel.getAddToWorldStackTrace(entityCast); + } + + T old = this.byUuid.get(entity.getUUID()); -+ if (old instanceof net.minecraft.world.entity.Entity && old != null && old.getId() != entity.getId() && ((net.minecraft.world.entity.Entity) old).valid) { -+ Logger logger = LogManager.getLogger(); -+ logger.error("Overwrote an existing entity " + old + " with " + entity); ++ if (old instanceof net.minecraft.world.entity.Entity oldCast && old != null && oldCast.getId() != entity.getId() && oldCast.valid) { ++ LOGGER.error("Overwrote an existing entity " + oldCast + " with " + entity); + if (net.minecraft.server.level.ServerLevel.DEBUG_ENTITIES) { -+ if (((net.minecraft.world.entity.Entity) old).addedToWorldStack != null) { -+ ((net.minecraft.world.entity.Entity) old).addedToWorldStack.printStackTrace(); ++ if (oldCast.addedToWorldStack != null) { ++ oldCast.addedToWorldStack.printStackTrace(); + } else { -+ logger.error("Oddly, the old entity was not added to the world in the normal way. Plugins?"); ++ LOGGER.error("Oddly, the old entity was not added to the world in the normal way. Plugins?"); + } -+ ((net.minecraft.world.entity.Entity) entity).addedToWorldStack.printStackTrace(); ++ entityCast.addedToWorldStack.printStackTrace(); + } + } + } diff --git a/patches/server/Anti-Xray.patch b/patches/server/Anti-Xray.patch index ced845cc62..75fd27adc5 100644 --- a/patches/server/Anti-Xray.patch +++ b/patches/server/Anti-Xray.patch @@ -277,6 +277,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import net.minecraft.server.level.ServerPlayerGameMode; +import net.minecraft.world.level.ChunkPos; +import net.minecraft.world.level.Level; ++import net.minecraft.world.level.biome.Biomes; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.EntityBlock; @@ -377,7 +378,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + } + -+ EmptyLevelChunk emptyChunk = new EmptyLevelChunk(level, new ChunkPos(0, 0)); ++ EmptyLevelChunk emptyChunk = new EmptyLevelChunk(level, new ChunkPos(0, 0), level.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY).getHolderOrThrow(Biomes.PLAINS)); + BlockPos zeroPos = new BlockPos(0, 0, 0); + + for (int i = 0; i < solidGlobal.length; i++) { diff --git a/patches/server/Asynchronous-chunk-IO-and-loading.patch b/patches/server/Asynchronous-chunk-IO-and-loading.patch index eb27a63b51..ef4ee57a0c 100644 --- a/patches/server/Asynchronous-chunk-IO-and-loading.patch +++ b/patches/server/Asynchronous-chunk-IO-and-loading.patch @@ -1676,7 +1676,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + data = ChunkSerializer.saveChunk(this.world, this.chunk, this.asyncSaveData); + PaperFileIOThread.LOGGER.info("Successfully serialized chunk data for task: " + this.toString() + " synchronously"); + } catch (final Throwable ex1) { -+ PaperFileIOThread.LOGGER.fatal("Failed to synchronously serialize unloading chunk data for task: " + this.toString() + "! Chunk data will be lost", ex1); ++ PaperFileIOThread.LOGGER.error("Failed to synchronously serialize unloading chunk data for task: " + this.toString() + "! Chunk data will be lost", ex1); + } + + ChunkSaveTask.this.complete(data); @@ -1933,7 +1933,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + globalWorkers[i].setName("Paper Async Chunk Task Thread #" + i); + globalWorkers[i].setPriority(Thread.NORM_PRIORITY - 1); + globalWorkers[i].setUncaughtExceptionHandler((final Thread thread, final Throwable throwable) -> { -+ PaperFileIOThread.LOGGER.fatal("Thread '" + thread.getName() + "' threw an uncaught exception!", throwable); ++ PaperFileIOThread.LOGGER.error("Thread '" + thread.getName() + "' threw an uncaught exception!", throwable); + }); + + globalWorkers[i].start(); @@ -1943,7 +1943,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + globalWorkers[threads - 1].setName("Paper Async Chunk Urgent Task Thread"); + globalWorkers[threads - 1].setPriority(Thread.NORM_PRIORITY+1); + globalWorkers[threads - 1].setUncaughtExceptionHandler((final Thread thread, final Throwable throwable) -> { -+ PaperFileIOThread.LOGGER.fatal("Thread '" + thread.getName() + "' threw an uncaught exception!", throwable); ++ PaperFileIOThread.LOGGER.error("Thread '" + thread.getName() + "' threw an uncaught exception!", throwable); + }); + globalWorkers[threads - 1].setLowestPriorityToPoll(PrioritizedTaskQueue.HIGHEST_PRIORITY); + globalWorkers[threads - 1].start(); @@ -1967,7 +1967,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + this.workers[i].setName("Async chunk loader thread #" + i + " for world: " + world.getWorld().getName()); + this.workers[i].setPriority(Thread.NORM_PRIORITY - 1); + this.workers[i].setUncaughtExceptionHandler((final Thread thread, final Throwable throwable) -> { -+ PaperFileIOThread.LOGGER.fatal("Thread '" + thread.getName() + "' threw an uncaught exception!", throwable); ++ PaperFileIOThread.LOGGER.error("Thread '" + thread.getName() + "' threw an uncaught exception!", throwable); + }); + + this.workers[i].start(); diff --git a/patches/server/Attempt-to-recalculate-regionfile-header-if-it-is-co.patch b/patches/server/Attempt-to-recalculate-regionfile-header-if-it-is-co.patch index 36b63e68c9..c483d34a65 100644 --- a/patches/server/Attempt-to-recalculate-regionfile-header-if-it-is-co.patch +++ b/patches/server/Attempt-to-recalculate-regionfile-header-if-it-is-co.patch @@ -743,7 +743,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + regionfile.fileLock.lock(); // otherwise we will unlock twice and only lock once. + return this.read(pos, regionfile); + } -+ net.minecraft.server.MinecraftServer.LOGGER.fatal("Can't recalculate regionfile header, regenerating chunk " + pos + " for " + regionfile.regionFile.toAbsolutePath()); ++ net.minecraft.server.MinecraftServer.LOGGER.error("Can't recalculate regionfile header, regenerating chunk " + pos + " for " + regionfile.regionFile.toAbsolutePath()); + return null; + } + } diff --git a/patches/server/Do-not-submit-profile-lookups-to-worldgen-threads.patch b/patches/server/Do-not-submit-profile-lookups-to-worldgen-threads.patch index fe95fc929c..7588070e4f 100644 --- a/patches/server/Do-not-submit-profile-lookups-to-worldgen-threads.patch +++ b/patches/server/Do-not-submit-profile-lookups-to-worldgen-threads.patch @@ -27,7 +27,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + Thread ret = new Thread(run); + ret.setName("Profile Lookup Executor #" + this.count.getAndIncrement()); + ret.setUncaughtExceptionHandler((Thread thread, Throwable throwable) -> { -+ LOGGER.fatal("Uncaught exception in thread " + thread.getName(), throwable); ++ LOGGER.error("Uncaught exception in thread " + thread.getName(), throwable); + }); + return ret; + } diff --git a/patches/server/Fix-Chunk-Post-Processing-deadlock-risk.patch b/patches/server/Fix-Chunk-Post-Processing-deadlock-risk.patch index c1bff5e2d9..3c67c95f26 100644 --- a/patches/server/Fix-Chunk-Post-Processing-deadlock-risk.patch +++ b/patches/server/Fix-Chunk-Post-Processing-deadlock-risk.patch @@ -37,14 +37,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 private final com.destroystokyo.paper.util.misc.PooledLinkedHashSets pooledLinkedPlayerHashSets = new com.destroystokyo.paper.util.misc.PooledLinkedHashSets<>(); @@ -0,0 +0,0 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider - return chunk; + }); }); }, (runnable) -> { - this.mainThreadMailbox.tell(ChunkTaskPriorityQueueSorter.message(holder, runnable)); + this.mainThreadMailbox.tell(ChunkTaskPriorityQueueSorter.message(holder, () -> ChunkMap.this.chunkLoadConversionCallbackExecutor.execute(runnable))); // Paper - delay running Chunk post processing until outside of the sorter to prevent a deadlock scenario when post processing causes another chunk request. }); + return completablefuture1; } - diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java diff --git a/patches/server/Fix-ChunkSnapshot-isSectionEmpty-int-and-optimize-Pa.patch b/patches/server/Fix-ChunkSnapshot-isSectionEmpty-int-and-optimize-Pa.patch index 115fc64b50..32f1a3ca54 100644 --- a/patches/server/Fix-ChunkSnapshot-isSectionEmpty-int-and-optimize-Pa.patch +++ b/patches/server/Fix-ChunkSnapshot-isSectionEmpty-int-and-optimize-Pa.patch @@ -10,12 +10,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/CraftChunk.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftChunk.java @@ -0,0 +0,0 @@ public class CraftChunk implements Chunk { - boolean[] sectionEmpty = new boolean[cs.length]; PalettedContainer>[] biome = (includeBiome || includeBiomeTempRain) ? new PalettedContainer[cs.length] : null; -- Registry iregistry = this.worldServer.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY); + Registry iregistry = this.worldServer.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY); - Codec> biomeCodec = PalettedContainer.codec(iregistry, iregistry.byNameCodec(), PalettedContainer.Strategy.SECTION_BIOMES, iregistry.getOrThrow(Biomes.PLAINS), null); // Paper - Anti-Xray - Add preset biomes -- + for (int i = 0; i < cs.length; i++) { - CompoundTag data = new CompoundTag(); diff --git a/patches/server/Fix-chunks-refusing-to-unload-at-low-TPS.patch b/patches/server/Fix-chunks-refusing-to-unload-at-low-TPS.patch index 506d0979ea..0267709f98 100644 --- a/patches/server/Fix-chunks-refusing-to-unload-at-low-TPS.patch +++ b/patches/server/Fix-chunks-refusing-to-unload-at-low-TPS.patch @@ -14,13 +14,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/level/ChunkMap.java +++ b/src/main/java/net/minecraft/server/level/ChunkMap.java @@ -0,0 +0,0 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider - - return chunk; + this.playerLoadedChunk(entityplayer, mutableobject, chunk); + }); }); - }, (runnable) -> { - this.mainThreadMailbox.tell(ChunkTaskPriorityQueueSorter.message(holder, () -> ChunkMap.this.chunkLoadConversionCallbackExecutor.execute(runnable))); // Paper - delay running Chunk post processing until outside of the sorter to prevent a deadlock scenario when post processing causes another chunk request. - }); + }, this.mainThreadExecutor); // Paper - queue to execute immediately so this doesn't delay chunk unloading + return completablefuture1; } - public int getTickingGenerated() { diff --git a/patches/server/Log-when-the-async-catcher-is-tripped.patch b/patches/server/Log-when-the-async-catcher-is-tripped.patch index c4c72fa392..1933accd2a 100644 --- a/patches/server/Log-when-the-async-catcher-is-tripped.patch +++ b/patches/server/Log-when-the-async-catcher-is-tripped.patch @@ -14,7 +14,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 { if ( (AsyncCatcher.enabled || io.papermc.paper.util.TickThread.STRICT_THREAD_CHECKS) && Thread.currentThread() != MinecraftServer.getServer().serverThread ) // Paper { -+ MinecraftServer.LOGGER.fatal("Thread " + Thread.currentThread().getName() + " failed main thread check: " + reason, new Throwable()); // Paper ++ MinecraftServer.LOGGER.error("Thread " + Thread.currentThread().getName() + " failed main thread check: " + reason, new Throwable()); // Paper throw new IllegalStateException( "Asynchronous " + reason + "!" ); } } diff --git a/patches/server/Replace-player-chunk-loader-system.patch b/patches/server/Replace-player-chunk-loader-system.patch index cff9215032..d523c0a650 100644 --- a/patches/server/Replace-player-chunk-loader-system.patch +++ b/patches/server/Replace-player-chunk-loader-system.patch @@ -1445,8 +1445,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - }); + // Paper - no-tick view distance - moved to Chunk neighbour update }); - }, (runnable) -> { - this.mainThreadMailbox.tell(ChunkTaskPriorityQueueSorter.message(holder, runnable)); + }, this.mainThreadExecutor); // Paper - queue to execute immediately so this doesn't delay chunk unloading + return completablefuture1; @@ -0,0 +0,0 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider int k = this.viewDistance;