diff --git a/Spigot-Server-Patches/Fix-chunk-unload-leak-issues-due-to-neighbor-updates.patch b/Spigot-Server-Patches/Do-not-mark-chunks-as-active-for-neighbor-updates.patch similarity index 74% rename from Spigot-Server-Patches/Fix-chunk-unload-leak-issues-due-to-neighbor-updates.patch rename to Spigot-Server-Patches/Do-not-mark-chunks-as-active-for-neighbor-updates.patch index ac5539427..d4eeb8a46 100644 --- a/Spigot-Server-Patches/Fix-chunk-unload-leak-issues-due-to-neighbor-updates.patch +++ b/Spigot-Server-Patches/Do-not-mark-chunks-as-active-for-neighbor-updates.patch @@ -1,32 +1,20 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Aikar Date: Thu, 12 May 2016 01:55:17 -0400 -Subject: [PATCH] Fix chunk unload leak issues due to neighbor updates +Subject: [PATCH] Do not mark chunks as active for neighbor updates +Fixes chunk unload issues 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 +++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java -@@ -0,0 +0,0 @@ public class ChunkProviderServer implements IChunkProvider { - } - - } -+ // Paper start -+ @Nullable -+ public Chunk getLoadedChunkAtWithoutMarkingActive(int i, int j) { -+ return this.chunks.get(ChunkCoordIntPair.a(i, j)); -+ } -+ // Paper end - - @Nullable - public Chunk getLoadedChunkAt(int i, int j) { @@ -0,0 +0,0 @@ public class ChunkProviderServer implements IChunkProvider { continue; } - Chunk neighbor = this.getLoadedChunkAt(chunk.locX + x, chunk.locZ + z); -+ Chunk neighbor = this.getLoadedChunkAtWithoutMarkingActive(chunk.locX + x, chunk.locZ + z); // Paper ++ Chunk neighbor = MCUtil.getLoadedChunkWithoutMarkingActive(this, chunk.locX + x, chunk.locZ + z); // Paper if (neighbor != null) { neighbor.setNeighborLoaded(-x, -z); chunk.setNeighborLoaded(x, z); @@ -35,7 +23,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } - Chunk neighbor = this.chunks.get(ChunkCoordIntPair.a(chunk.locX + x, chunk.locZ + z)); -+ Chunk neighbor = this.getLoadedChunkAtWithoutMarkingActive(chunk.locX + x, chunk.locZ + z); // Paper ++ Chunk neighbor = MCUtil.getLoadedChunkWithoutMarkingActive(this, chunk.locX + x, chunk.locZ + z); // Paper if (neighbor != null) { neighbor.setNeighborUnloaded(-x, -z); chunk.setNeighborUnloaded(x, z); @@ -48,7 +36,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } - net.minecraft.server.Chunk neighbor = world.getChunkProviderServer().getLoadedChunkAt(chunk.locX + x, chunk.locZ + z); -+ net.minecraft.server.Chunk neighbor = world.getChunkProviderServer().getLoadedChunkAtWithoutMarkingActive(chunk.locX + x, chunk.locZ + z); // Paper ++ net.minecraft.server.Chunk neighbor = net.minecraft.server.MCUtil.getLoadedChunkWithoutMarkingActive(world, chunk.locX + x, chunk.locZ + z); // Paper if (neighbor != null) { neighbor.setNeighborUnloaded(-xx, -zz); chunk.setNeighborUnloaded(xx, zz); @@ -57,7 +45,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } - net.minecraft.server.Chunk neighbor = world.getChunkProviderServer().getLoadedChunkAt(chunk.locX + x, chunk.locZ + z); -+ net.minecraft.server.Chunk neighbor = world.getChunkProviderServer().getLoadedChunkAtWithoutMarkingActive(chunk.locX + x, chunk.locZ + z); // Paper ++ net.minecraft.server.Chunk neighbor = net.minecraft.server.MCUtil.getLoadedChunkWithoutMarkingActive(world, chunk.locX + x, chunk.locZ + z); // Paper if (neighbor != null) { neighbor.setNeighborLoaded(-x, -z); chunk.setNeighborLoaded(x, z); @@ -65,12 +53,20 @@ diff --git a/src/main/java/org/bukkit/craftbukkit/chunkio/ChunkIOProvider.java b index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/chunkio/ChunkIOProvider.java +++ b/src/main/java/org/bukkit/craftbukkit/chunkio/ChunkIOProvider.java +@@ -0,0 +0,0 @@ import net.minecraft.server.Chunk; + import net.minecraft.server.ChunkCoordIntPair; + import net.minecraft.server.ChunkRegionLoader; + import net.minecraft.server.NBTTagCompound; +- + import org.bukkit.Server; + import org.bukkit.craftbukkit.util.AsynchronousExecutor; + @@ -0,0 +0,0 @@ class ChunkIOProvider implements AsynchronousExecutor.CallBackProvider 0) { + return true; + } diff --git a/Spigot-Server-Patches/MC-Utils.patch b/Spigot-Server-Patches/MC-Utils.patch index 34d573961..a37383c88 100644 --- a/Spigot-Server-Patches/MC-Utils.patch +++ b/Spigot-Server-Patches/MC-Utils.patch @@ -15,6 +15,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + +import org.bukkit.Location; + ++import javax.annotation.Nullable; +import java.util.regex.Pattern; + +public class MCUtil { @@ -129,6 +130,27 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + final int modZ = pos.getZ() & 15; + return (modX == 0 || modX == 15 || modZ == 0 || modZ == 15); + } ++ ++ /** ++ * Gets a chunk without changing its boolean for should unload ++ * @param world ++ * @param x ++ * @param z ++ * @return ++ */ ++ @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 ++ * @param x ++ * @param z ++ * @return ++ */ ++ @Nullable public static Chunk getLoadedChunkWithoutMarkingActive(ChunkProviderServer provider, int x, int z) { ++ return 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 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644