mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-01 20:50:41 +01:00
60 lines
3.2 KiB
Diff
60 lines
3.2 KiB
Diff
From e903a62a93d1db04232d902a7de96e40953609bb Mon Sep 17 00:00:00 2001
|
|
From: Thinkofdeath <thethinkofdeath@gmail.com>
|
|
Date: Tue, 18 Mar 2014 09:49:30 +0000
|
|
Subject: [PATCH] Remove the lastChunkAccessed if it is unloaded.
|
|
|
|
This fixes an issue where a chunk would be unloaded but remain in lastChunkAccessed meaning calls on getChunkAt could return a chunk that is no longer loaded, this caused an issue where the chunk could be reloaded whilst in use reverting any block changes. This caused findEndPortal to return null even after createEndPortal which would crash the server trying to teleport to a null location.
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
|
index 7f19bec..a9ef533 100644
|
|
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
|
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
|
@@ -315,6 +315,13 @@ public class ChunkProviderServer implements IChunkProvider {
|
|
long chunkcoordinates = this.unloadQueue.popFirst();
|
|
Chunk chunk = this.chunks.get(chunkcoordinates);
|
|
if (chunk == null) continue;
|
|
+ // Spigot start - Remove the chunk from the cache if it is unloaded
|
|
+ Chunk result = world.lastChunkAccessed;
|
|
+ if ( result != null && result.locX == chunk.locX && result.locZ == chunk.locZ )
|
|
+ {
|
|
+ world.lastChunkAccessed = null;
|
|
+ }
|
|
+ // Spigot end
|
|
|
|
ChunkUnloadEvent event = new ChunkUnloadEvent(chunk.bukkitChunk);
|
|
server.getPluginManager().callEvent(event);
|
|
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
|
|
index 8aa11c2..26c97af 100644
|
|
--- a/src/main/java/net/minecraft/server/World.java
|
|
+++ b/src/main/java/net/minecraft/server/World.java
|
|
@@ -153,7 +153,7 @@ public abstract class World implements IBlockAccess {
|
|
public boolean pvpMode;
|
|
public boolean keepSpawnInMemory = true;
|
|
public ChunkGenerator generator;
|
|
- Chunk lastChunkAccessed;
|
|
+ public Chunk lastChunkAccessed; // Spigot - Make public
|
|
int lastXAccessed = Integer.MIN_VALUE;
|
|
int lastZAccessed = Integer.MIN_VALUE;
|
|
final Object chunkLock = new Object();
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
|
index 466c687..a7393db 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
|
@@ -187,6 +187,14 @@ public class CraftWorld implements World {
|
|
world.chunkProviderServer.saveChunkNOP(chunk);
|
|
}
|
|
|
|
+ // Spigot start - Remove the chunk from the cache if it is unloaded
|
|
+ net.minecraft.server.Chunk result = world.lastChunkAccessed;
|
|
+ if ( result != null && result.locX == chunk.locX && result.locZ == chunk.locZ )
|
|
+ {
|
|
+ world.lastChunkAccessed = null;
|
|
+ }
|
|
+ // Spigot end
|
|
+
|
|
world.chunkProviderServer.unloadQueue.remove(x, z);
|
|
world.chunkProviderServer.chunks.remove(LongHash.toLong(x, z));
|
|
|
|
--
|
|
1.8.5.2.msysgit.0
|
|
|