summaryrefslogtreecommitdiffstats
path: root/nms-patches/CommandSpreadPlayers.patch
blob: c1af65a4773631e965eb0208a6230a8cc6098b68 (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
--- a/net/minecraft/server/CommandSpreadPlayers.java
+++ b/net/minecraft/server/CommandSpreadPlayers.java
@@ -269,7 +269,7 @@
                 }
 
                 blockposition = blockposition.down();
-            } while (iblockaccess.getType(blockposition).isAir());
+            } while (getType(iblockaccess, blockposition).isAir()); // CraftBukkit
 
             return blockposition.getY() + 1;
         }
@@ -285,7 +285,7 @@
                 }
 
                 blockposition = blockposition.down();
-                iblockdata = iblockaccess.getType(blockposition);
+                iblockdata = getType(iblockaccess, blockposition); // CraftBukkit
             } while (iblockdata.isAir());
 
             Material material = iblockdata.getMaterial();
@@ -297,5 +297,12 @@
             this.a = MathHelper.a(random, d0, d2);
             this.b = MathHelper.a(random, d1, d3);
         }
+
+        // CraftBukkit start - add a version of getType which force loads chunks
+        private static IBlockData getType(IBlockAccess iblockaccess, BlockPosition position) {
+            ((ChunkProviderServer) ((World) iblockaccess).chunkProvider).getChunkAt(position.getX() >> 4, position.getZ() >> 4, true, true);
+            return iblockaccess.getType(position);
+        }
+        // CraftBukkit end
     }
 }