Paper/CraftBukkit-Patches/0016-Sync-Free-Chunk-Reference-Cache.patch

36 Zeilen
1.4 KiB
Diff

2013-06-20 10:52:23 +02:00
From 27aa389075a5b22ffad6e7c8d4d42b9315aa1bc0 Mon Sep 17 00:00:00 2001
From: Mike Primm <mike@primmhome.com>
Date: Wed, 16 Jan 2013 15:27:22 -0600
Subject: [PATCH] Sync Free Chunk Reference Cache
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
2013-06-20 10:52:23 +02:00
index e353caa..a81e06d 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
2013-06-20 10:52:23 +02:00
@@ -301,15 +301,13 @@ public abstract class World implements IBlockAccess {
// CraftBukkit start
public Chunk getChunkAt(int i, int j) {
- Chunk result = null;
- synchronized (this.chunkLock) {
- if (this.lastChunkAccessed == null || this.lastXAccessed != i || this.lastZAccessed != j) {
- this.lastChunkAccessed = this.chunkProvider.getOrCreateChunk(i, j);
- this.lastXAccessed = i;
- this.lastZAccessed = j;
- }
- result = this.lastChunkAccessed;
+ //synchronized (this.chunkLock) {
+ Chunk result = this.lastChunkAccessed; // Exploit fact that read is atomic
+ if (result == null || result.x != i || result.z != j) {
+ result = this.chunkProvider.getOrCreateChunk(i, j);
+ this.lastChunkAccessed = result; // Exploit fact that write is atomic
}
+ //}
return result;
}
// CraftBukkit end
--
1.8.1.2