diff --git a/Spigot-Server-Patches/Add-exception-reporting-event.patch b/Spigot-Server-Patches/Add-exception-reporting-event.patch index 54fa0e2ed..202b0a787 100644 --- a/Spigot-Server-Patches/Add-exception-reporting-event.patch +++ b/Spigot-Server-Patches/Add-exception-reporting-event.patch @@ -63,8 +63,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ import org.apache.logging.log4j.Logger; import com.google.common.collect.Lists; // CraftBukkit - import org.bukkit.Bukkit; // CraftBukkit -+import org.bukkit.craftbukkit.util.CraftMagicNumbers; + import org.bukkit.Server; // CraftBukkit ++import org.bukkit.craftbukkit.util.CraftMagicNumbers; // Paper public class Chunk { diff --git a/Spigot-Server-Patches/Avoid-hopper-searches-if-there-are-no-items.patch b/Spigot-Server-Patches/Avoid-hopper-searches-if-there-are-no-items.patch index 1cd3a4444..750f9579c 100644 --- a/Spigot-Server-Patches/Avoid-hopper-searches-if-there-are-no-items.patch +++ b/Spigot-Server-Patches/Avoid-hopper-searches-if-there-are-no-items.patch @@ -30,7 +30,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // CraftBukkit start - Neighbor loaded cache for chunk lighting and entity ticking private int neighbors = 0x1 << 12; - + public long chunkKey; @@ -0,0 +0,0 @@ public class Chunk { entity.ad = k; entity.ae = this.locZ; diff --git a/Spigot-Server-Patches/Delay-Chunk-Unloads-based-on-Player-Movement.patch b/Spigot-Server-Patches/Delay-Chunk-Unloads-based-on-Player-Movement.patch index b82e92ed2..91dbe8f67 100644 --- a/Spigot-Server-Patches/Delay-Chunk-Unloads-based-on-Player-Movement.patch +++ b/Spigot-Server-Patches/Delay-Chunk-Unloads-based-on-Player-Movement.patch @@ -41,9 +41,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- 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 { + private boolean j; public final World world; public final int[] heightMap; - public final long chunkKey; // Paper + public Long scheduledForUnload; // Paper - delay chunk unloads public final int locX; public final int locZ; 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 ef72d0c47..dee4b9098 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 @@ -10,9 +10,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- 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 { + } + // CraftBukkit end - 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); @@ -43,69 +43,4 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 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 -+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java -@@ -0,0 +0,0 @@ public class ChunkProviderServer implements IChunkProvider { - continue; - } - -- Chunk neighbor = this.getChunkIfLoaded(chunk.locX + x, chunk.locZ + z); -+ Chunk neighbor = MCUtil.getLoadedChunkWithoutMarkingActive(this, chunk.locX + x, chunk.locZ + z); // Paper - if (neighbor != null) { - neighbor.setNeighborLoaded(-x, -z); - chunk.setNeighborLoaded(x, z); -@@ -0,0 +0,0 @@ public class ChunkProviderServer implements IChunkProvider { - continue; - } - -- Chunk neighbor = this.getChunkIfLoaded(chunk.locX + x, chunk.locZ + z); -+ Chunk neighbor = MCUtil.getLoadedChunkWithoutMarkingActive(this, chunk.locX + x, chunk.locZ + z); // Paper - if (neighbor != null) { - neighbor.setNeighborUnloaded(-x, -z); - chunk.setNeighborUnloaded(x, z); -diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -@@ -0,0 +0,0 @@ public class CraftWorld implements World { - continue; - } - -- net.minecraft.server.Chunk neighbor = world.getChunkProviderServer().getChunkIfLoaded(chunk.locX + x, chunk.locZ + z); -+ 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); -@@ -0,0 +0,0 @@ public class CraftWorld implements World { - continue; - } - -- net.minecraft.server.Chunk neighbor = world.getChunkProviderServer().getLoadedChunkAt(chunk.locX + x, chunk.locZ + z); -+ 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); -diff --git a/src/main/java/org/bukkit/craftbukkit/chunkio/ChunkIOProvider.java b/src/main/java/org/bukkit/craftbukkit/chunkio/ChunkIOProvider.java -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 -Date: Wed, 2 Mar 2016 23:55:20 -0600 -Subject: [PATCH] Don't create a chunk just to unload it - - -diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -@@ -0,0 +0,0 @@ public class CraftWorld implements World { - } - - private boolean unloadChunk0(int x, int z, boolean save, boolean safe) { -- net.minecraft.server.Chunk chunk = world.getChunkProviderServer().getChunkAt(x, z); -+ // Paper start - Don't create a chunk just to unload it -+ net.minecraft.server.Chunk chunk = world.getChunkProviderServer().getChunkIfLoaded(x, z); -+ if (chunk == null) { -+ return false; -+ } -+ // Paper end -+ - if (chunk.mustSave) { // If chunk had previously been queued to save, must do save to avoid loss of that data - save = true; - } --- \ No newline at end of file diff --git a/Spigot-Server-Patches/Fix-Chunk-Unload-Queue-Issues.patch b/Spigot-Server-Patches/Fix-Chunk-Unload-Queue-Issues.patch index fc35bf1b0..15d231533 100644 --- a/Spigot-Server-Patches/Fix-Chunk-Unload-Queue-Issues.patch +++ b/Spigot-Server-Patches/Fix-Chunk-Unload-Queue-Issues.patch @@ -26,43 +26,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- 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 { - Chunk chunk = (Chunk) this.chunks.get(olong); if (chunk != null && chunk.d) { + // CraftBukkit start - move unload logic to own method + chunk.setShouldUnload(false); // Paper - // CraftBukkit start - ChunkUnloadEvent event = new ChunkUnloadEvent(chunk.bukkitChunk); - this.world.getServer().getPluginManager().callEvent(event); -diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -@@ -0,0 +0,0 @@ public class CraftWorld implements World { - // Use the default variant of loadChunk when generate == true. - return world.getChunkProviderServer().getChunkAt(x, z) != null; - } -+ // Paper start - below is not updated for the new unload queue logic. -+ return world.getChunkProviderServer().getOrLoadChunkAt(x, z) != null; -+ /* - - world.getChunkProviderServer().unloadQueue.remove(ChunkCoordIntPair.a(x, z)); - net.minecraft.server.Chunk chunk = world.getChunkProviderServer().chunks.get(ChunkCoordIntPair.a(x, z)); -@@ -0,0 +0,0 @@ public class CraftWorld implements World { - chunk = world.getChunkProviderServer().getOrLoadChunkAt(x, z); - world.timings.syncChunkLoadTimer.stopTiming(); // Spigot - } -- return chunk != null; -+ return chunk != null;*/ // Paper end - } - - private void chunkLoadPostProcess(net.minecraft.server.Chunk chunk, int cx, int cz) { -@@ -0,0 +0,0 @@ public class CraftWorld implements World { - } - - // Already unloading? -- if (cps.unloadQueue.contains(ChunkCoordIntPair.a(chunk.locX, chunk.locZ))) { -+ if (chunk.isUnloading()) { // Paper - continue; - } - + if (!unloadChunk(chunk, true)) { + continue; + } -- \ No newline at end of file diff --git a/Spigot-Server-Patches/Lighting-Queue.patch b/Spigot-Server-Patches/Lighting-Queue.patch index bbedfff37..506fedabe 100644 --- a/Spigot-Server-Patches/Lighting-Queue.patch +++ b/Spigot-Server-Patches/Lighting-Queue.patch @@ -89,13 +89,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- 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 { - if (event.isCancelled()) { - continue; - } -+ chunk.lightingQueue.processUnload(); // Paper + if (event.isCancelled()) { + return false; + } ++ chunk.lightingQueue.processUnload(); // Paper - // Update neighbor counts - for (int x = -2; x < 3; x++) { + // Update neighbor counts + for (int x = -2; x < 3; x++) { diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java diff --git a/Spigot-Server-Patches/Optimize-Chunk-Access.patch b/Spigot-Server-Patches/Optimize-Chunk-Access.patch index 5586ba54c..ebeb5234d 100644 --- a/Spigot-Server-Patches/Optimize-Chunk-Access.patch +++ b/Spigot-Server-Patches/Optimize-Chunk-Access.patch @@ -8,26 +8,6 @@ getChunkAt is called for the same chunk multiple times in a row, often from getT Optimize this look up by using a Last Access cache. -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 { - private boolean j; - public final World world; - public final int[] heightMap; -+ public final long chunkKey; // Paper - public final int locX; - public final int locZ; - private boolean m; -@@ -0,0 +0,0 @@ public class Chunk { - this.world = world; - this.locX = i; - this.locZ = j; -+ this.chunkKey = org.bukkit.craftbukkit.util.LongHash.toLong(this.locX, this.locZ); // Paper - this.heightMap = new int[256]; - - for (int k = 0; k < this.entitySlices.length; ++k) { 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/work/CraftBukkit b/work/CraftBukkit index 9af379fc4..1953f52da 160000 --- a/work/CraftBukkit +++ b/work/CraftBukkit @@ -1 +1 @@ -Subproject commit 9af379fc4741a6fb487aaf4b5c7ffdbcbb12ca4f +Subproject commit 1953f52da1ece0feb56dea20592c1b86616b31a5 diff --git a/work/Spigot b/work/Spigot index c55900f72..c3e4052b6 160000 --- a/work/Spigot +++ b/work/Spigot @@ -1 +1 @@ -Subproject commit c55900f7285842593df7101bf7ee81516aacb0c5 +Subproject commit c3e4052b69acbcf52439c51ae8b0d65a4b1bb98a