summaryrefslogtreecommitdiffstats
path: root/nms-patches/RegionFile.patch
blob: 19df82ef9e9285ac991def3d9c8c87e07cd0fe29 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
--- /home/matt/mc-dev-private//net/minecraft/server/RegionFile.java	2015-02-26 22:40:23.063608134 +0000
+++ src/main/java/net/minecraft/server/RegionFile.java	2015-02-26 22:40:23.063608134 +0000
@@ -90,6 +90,45 @@
 
     }
 
+    // CraftBukkit start - This is a copy (sort of) of the method below it, make sure they stay in sync
+    public synchronized boolean chunkExists(int i, int j) {
+        if (this.d(i, j)) {
+            return false;
+        } else {
+            try {
+                int k = this.e(i, j);
+
+                if (k == 0) {
+                    return false;
+                } else {
+                    int l = k >> 8;
+                    int i1 = k & 255;
+
+                    if (l + i1 > this.f.size()) {
+                        return false;
+                    }
+
+                    this.c.seek((long) (l * 4096));
+                    int j1 = this.c.readInt();
+
+                    if (j1 > 4096 * i1 || j1 <= 0) {
+                        return false;
+                    }
+
+                    byte b0 = this.c.readByte();
+                    if (b0 == 1 || b0 == 2) {
+                        return true;
+                    }
+                }
+            } catch (IOException ioexception) {
+                return false;
+            }
+        }
+
+        return false;
+    }
+    // CraftBukkit end
+
     public synchronized DataInputStream a(int i, int j) {
         if (this.d(i, j)) {
             return null;