summaryrefslogtreecommitdiffstats
path: root/nms-patches/BiomeDecorator.patch
blob: b7929ee0ef27245aa25409115f3459901faaf849 (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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
--- ../work/decompile-8eb82bde/net/minecraft/server/BiomeDecorator.java	2014-12-12 19:26:13.625913570 +0000
+++ src/main/java/net/minecraft/server/BiomeDecorator.java	2014-12-12 19:15:22.000000000 +0000
@@ -132,7 +132,7 @@
             WorldGenTreeAbstract worldgentreeabstract = biomebase.a(this.b);
 
             worldgentreeabstract.e();
-            blockposition = this.a.getHighestBlockYAt(this.c.a(k, 0, l));
+            blockposition = this.getHighestBlockYAt(this.c.a(k, 0, l)); // CraftBukkit - Prevent crash
             if (worldgentreeabstract.generate(this.a, this.b, blockposition)) {
                 worldgentreeabstract.a(this.a, this.b, blockposition);
             }
@@ -141,7 +141,7 @@
         for (j = 0; j < this.K; ++j) {
             k = this.b.nextInt(16) + 8;
             l = this.b.nextInt(16) + 8;
-            this.v.generate(this.a, this.b, this.a.getHighestBlockYAt(this.c.a(k, 0, l)));
+            this.v.generate(this.a, this.b, this.getHighestBlockYAt(this.c.a(k, 0, l ))); // CraftBukkit - Prevent crash
         }
 
         int i1;
@@ -149,7 +149,7 @@
         for (j = 0; j < this.B; ++j) {
             k = this.b.nextInt(16) + 8;
             l = this.b.nextInt(16) + 8;
-            i1 = this.b.nextInt(this.a.getHighestBlockYAt(this.c.a(k, 0, l)).getY() + 32);
+            i1 = this.b.nextInt(this.getHighestBlockYAt(this.c.a(k, 0, l)).getY() + 32); // CraftBukkit - Prevent crash
             blockposition = this.c.a(k, i1, l);
             EnumFlowerVarient enumflowervarient = biomebase.a(this.b, blockposition);
             BlockFlowers blockflowers = enumflowervarient.a().a();
@@ -163,14 +163,14 @@
         for (j = 0; j < this.C; ++j) {
             k = this.b.nextInt(16) + 8;
             l = this.b.nextInt(16) + 8;
-            i1 = this.b.nextInt(this.a.getHighestBlockYAt(this.c.a(k, 0, l)).getY() * 2);
+            i1 = this.b.nextInt(this.getHighestBlockYAt(this.c.a(k, 0, l)).getY() * 2); // CraftBukkit - Prevent crash
             biomebase.b(this.b).generate(this.a, this.b, this.c.a(k, i1, l));
         }
 
         for (j = 0; j < this.D; ++j) {
             k = this.b.nextInt(16) + 8;
             l = this.b.nextInt(16) + 8;
-            i1 = this.b.nextInt(this.a.getHighestBlockYAt(this.c.a(k, 0, l)).getY() * 2);
+            i1 = this.b.nextInt(this.getHighestBlockYAt(this.c.a(k, 0, l)).getY() * 2); // CraftBukkit - Prevent crash
             (new WorldGenDeadBush()).generate(this.a, this.b, this.c.a(k, i1, l));
         }
 
@@ -179,7 +179,7 @@
         while (j < this.z) {
             k = this.b.nextInt(16) + 8;
             l = this.b.nextInt(16) + 8;
-            i1 = this.b.nextInt(this.a.getHighestBlockYAt(this.c.a(k, 0, l)).getY() * 2);
+            i1 = this.b.nextInt(this.getHighestBlockYAt(this.c.a(k, 0, l)).getY() * 2); // CraftBukkit - Prevent crash
             blockposition = this.c.a(k, i1, l);
 
             while (true) {
@@ -202,7 +202,7 @@
             if (this.b.nextInt(4) == 0) {
                 k = this.b.nextInt(16) + 8;
                 l = this.b.nextInt(16) + 8;
-                BlockPosition blockposition2 = this.a.getHighestBlockYAt(this.c.a(k, 0, l));
+                BlockPosition blockposition2 = this.getHighestBlockYAt(this.c.a(k, 0, l)); // CraftBukkit - Prevent crash
 
                 this.t.generate(this.a, this.b, blockposition2);
             }
@@ -210,7 +210,7 @@
             if (this.b.nextInt(8) == 0) {
                 k = this.b.nextInt(16) + 8;
                 l = this.b.nextInt(16) + 8;
-                i1 = this.b.nextInt(this.a.getHighestBlockYAt(this.c.a(k, 0, l)).getY() * 2);
+                i1 = this.b.nextInt(this.getHighestBlockYAt(this.c.a(k, 0, l)).getY() * 2); // CraftBukkit - Prevent crash
                 blockposition = this.c.a(k, i1, l);
                 this.u.generate(this.a, this.b, blockposition);
             }
@@ -219,42 +219,42 @@
         if (this.b.nextInt(4) == 0) {
             j = this.b.nextInt(16) + 8;
             k = this.b.nextInt(16) + 8;
-            l = this.b.nextInt(this.a.getHighestBlockYAt(this.c.a(j, 0, k)).getY() * 2);
+            l = this.b.nextInt(this.getHighestBlockYAt(this.c.a(j, 0, k)).getY() * 2); // CraftBukkit - Prevent crash
             this.t.generate(this.a, this.b, this.c.a(j, l, k));
         }
 
         if (this.b.nextInt(8) == 0) {
             j = this.b.nextInt(16) + 8;
             k = this.b.nextInt(16) + 8;
-            l = this.b.nextInt(this.a.getHighestBlockYAt(this.c.a(j, 0, k)).getY() * 2);
+            l = this.b.nextInt(this.getHighestBlockYAt(this.c.a(j, 0, k)).getY() * 2); // CraftBukkit - Prevent crash
             this.u.generate(this.a, this.b, this.c.a(j, l, k));
         }
 
         for (j = 0; j < this.F; ++j) {
             k = this.b.nextInt(16) + 8;
             l = this.b.nextInt(16) + 8;
-            i1 = this.b.nextInt(this.a.getHighestBlockYAt(this.c.a(k, 0, l)).getY() * 2);
+            i1 = this.b.nextInt(this.getHighestBlockYAt(this.c.a(k, 0, l)).getY() * 2); // CraftBukkit - Prevent crash
             this.w.generate(this.a, this.b, this.c.a(k, i1, l));
         }
 
         for (j = 0; j < 10; ++j) {
             k = this.b.nextInt(16) + 8;
             l = this.b.nextInt(16) + 8;
-            i1 = this.b.nextInt(this.a.getHighestBlockYAt(this.c.a(k, 0, l)).getY() * 2);
+            i1 = this.b.nextInt(this.getHighestBlockYAt(this.c.a(k, 0, l)).getY() * 2); // CraftBukkit - Prevent crash
             this.w.generate(this.a, this.b, this.c.a(k, i1, l));
         }
 
         if (this.b.nextInt(32) == 0) {
             j = this.b.nextInt(16) + 8;
             k = this.b.nextInt(16) + 8;
-            l = this.b.nextInt(this.a.getHighestBlockYAt(this.c.a(j, 0, k)).getY() * 2);
+            l = this.b.nextInt(this.getHighestBlockYAt(this.c.a(j, 0, k)).getY() * 2); // CraftBukkit - Prevent crash
             (new WorldGenPumpkin()).generate(this.a, this.b, this.c.a(j, l, k));
         }
 
         for (j = 0; j < this.G; ++j) {
             k = this.b.nextInt(16) + 8;
             l = this.b.nextInt(16) + 8;
-            i1 = this.b.nextInt(this.a.getHighestBlockYAt(this.c.a(k, 0, l)).getY() * 2);
+            i1 = this.b.nextInt(this.getHighestBlockYAt(this.c.a(k, 0, l)).getY() * 2); // CraftBukkit - Prevent crash
             this.x.generate(this.a, this.b, this.c.a(k, i1, l));
         }
 
@@ -274,6 +274,16 @@
 
     }
 
+    // CraftBukkit start - The heightMap can be wrong calculated and return Y = 0 which will crash the Server
+    private BlockPosition getHighestBlockYAt( BlockPosition blockPosition ) {
+        BlockPosition returnBlockPosition = this.a.getHighestBlockYAt( blockPosition );
+        if ( returnBlockPosition.getY() == 0 ) {
+            returnBlockPosition = returnBlockPosition.up( 1 );
+        }
+        return returnBlockPosition;
+    }
+    // CraftBukkit end
+
     protected void a(int i, WorldGenerator worldgenerator, int j, int k) {
         int l;