From 6a5746f5478d30edd1a530233fd42ed18ffd985d Mon Sep 17 00:00:00 2001 From: CraftBukkit/Spigot Date: Wed, 3 Dec 2014 00:24:19 +0100 Subject: [PATCH] Default to Y=1 when a Y=0 BlockPosition is found to be used in the BiomeDecorator. This prevents the "n must be positive" Crash due to the fact that sometimes the heightMap can be wrong calculated. Fixes SPIGOT-91 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit By: Fabian Faßbender --- paper-server/nms-patches/BiomeDecorator.patch | 139 ++++++++++++++++++ 1 file changed, 139 insertions(+) create mode 100644 paper-server/nms-patches/BiomeDecorator.patch diff --git a/paper-server/nms-patches/BiomeDecorator.patch b/paper-server/nms-patches/BiomeDecorator.patch new file mode 100644 index 000000000..91b04ca2e --- /dev/null +++ b/paper-server/nms-patches/BiomeDecorator.patch @@ -0,0 +1,139 @@ +--- ../work/decompile-8eb82bde//net/minecraft/server/BiomeDecorator.java Tue Dec 2 23:22:43 2014 ++++ src/main/java/net/minecraft/server/BiomeDecorator.java Tue Dec 2 23:22:34 2014 +@@ -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)); + } + +@@ -273,6 +273,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;