From 0c789715527a61e7be2ac18c156ff6dda2a59a20 Mon Sep 17 00:00:00 2001 From: Aikar Date: Fri, 13 May 2016 22:27:20 -0400 Subject: [PATCH] More cases of avoiding marking active for chunks, to stop potential leaks --- ...hunks-as-active-for-neighbor-updates.patch | 38 +++++++++++++++++++ Spigot-Server-Patches/MC-Utils.patch | 7 ++-- 2 files changed, 42 insertions(+), 3 deletions(-) diff --git a/Spigot-Server-Patches/Do-not-mark-chunks-as-active-for-neighbor-updates.patch b/Spigot-Server-Patches/Do-not-mark-chunks-as-active-for-neighbor-updates.patch index d4eeb8a46a..c64b01e39c 100644 --- a/Spigot-Server-Patches/Do-not-mark-chunks-as-active-for-neighbor-updates.patch +++ b/Spigot-Server-Patches/Do-not-mark-chunks-as-active-for-neighbor-updates.patch @@ -5,6 +5,44 @@ Subject: [PATCH] Do not mark chunks as active for neighbor updates Fixes chunk unload issues +diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/server/Chunk.java ++++ b/src/main/java/net/minecraft/server/Chunk.java +@@ -0,0 +0,0 @@ public class Chunk { + + public void loadNearby(IChunkProvider ichunkprovider, ChunkGenerator chunkgenerator) { + world.timings.syncChunkLoadPostTimer.startTiming(); // Spigot +- Chunk chunk = ichunkprovider.getLoadedChunkAt(this.locX, this.locZ - 1); +- Chunk chunk1 = ichunkprovider.getLoadedChunkAt(this.locX + 1, this.locZ); +- Chunk chunk2 = ichunkprovider.getLoadedChunkAt(this.locX, this.locZ + 1); +- Chunk chunk3 = ichunkprovider.getLoadedChunkAt(this.locX - 1, this.locZ); ++ Chunk chunk = MCUtil.getLoadedChunkWithoutMarkingActive(ichunkprovider,this.locX, this.locZ - 1); // Paper ++ Chunk chunk1 = MCUtil.getLoadedChunkWithoutMarkingActive(ichunkprovider,this.locX + 1, this.locZ); // Paper ++ Chunk chunk2 = MCUtil.getLoadedChunkWithoutMarkingActive(ichunkprovider,this.locX, this.locZ + 1); // Paper ++ Chunk chunk3 = MCUtil.getLoadedChunkWithoutMarkingActive(ichunkprovider,this.locX - 1, this.locZ); // Paper + +- if (chunk1 != null && chunk2 != null && ichunkprovider.getLoadedChunkAt(this.locX + 1, this.locZ + 1) != null) { ++ if (chunk1 != null && chunk2 != null && MCUtil.getLoadedChunkWithoutMarkingActive(ichunkprovider,this.locX + 1, this.locZ + 1) != null) { // Paper + this.a(chunkgenerator); + } + +- if (chunk3 != null && chunk2 != null && ichunkprovider.getLoadedChunkAt(this.locX - 1, this.locZ + 1) != null) { ++ if (chunk3 != null && chunk2 != null && MCUtil.getLoadedChunkWithoutMarkingActive(ichunkprovider,this.locX - 1, this.locZ + 1) != null) { // Paper + chunk3.a(chunkgenerator); + } + +- if (chunk != null && chunk1 != null && ichunkprovider.getLoadedChunkAt(this.locX + 1, this.locZ - 1) != null) { ++ if (chunk != null && chunk1 != null && MCUtil.getLoadedChunkWithoutMarkingActive(ichunkprovider,this.locX + 1, this.locZ - 1) != null) { // Paper + chunk.a(chunkgenerator); + } + + if (chunk != null && chunk3 != null) { +- Chunk chunk4 = ichunkprovider.getLoadedChunkAt(this.locX - 1, this.locZ - 1); ++ Chunk chunk4 = MCUtil.getLoadedChunkWithoutMarkingActive(ichunkprovider,this.locX - 1, this.locZ - 1); // Paper + + if (chunk4 != null) { + chunk4.a(chunkgenerator); diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/server/ChunkProviderServer.java diff --git a/Spigot-Server-Patches/MC-Utils.patch b/Spigot-Server-Patches/MC-Utils.patch index a37383c88d..cc9a602842 100644 --- a/Spigot-Server-Patches/MC-Utils.patch +++ b/Spigot-Server-Patches/MC-Utils.patch @@ -18,7 +18,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import javax.annotation.Nullable; +import java.util.regex.Pattern; + -+public class MCUtil { ++public final class MCUtil { + private static final Pattern REPLACE_QUOTES = Pattern.compile("\""); + + private MCUtil() {} @@ -141,6 +141,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + @Nullable public static Chunk getLoadedChunkWithoutMarkingActive(World world, int x, int z) { + return ((ChunkProviderServer) world.chunkProvider).chunks.get(ChunkCoordIntPair.a(x, z)); + } ++ + /** + * Gets a chunk without changing its boolean for should unload + * @param provider @@ -148,8 +149,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @param z + * @return + */ -+ @Nullable public static Chunk getLoadedChunkWithoutMarkingActive(ChunkProviderServer provider, int x, int z) { -+ return provider.chunks.get(ChunkCoordIntPair.a(x, z)); ++ @Nullable public static Chunk getLoadedChunkWithoutMarkingActive(IChunkProvider provider, int x, int z) { ++ return ((ChunkProviderServer)provider).chunks.get(ChunkCoordIntPair.a(x, z)); + } +} diff --git a/src/main/java/net/minecraft/server/NBTTagCompound.java b/src/main/java/net/minecraft/server/NBTTagCompound.java