Fix Biome Decoration Crashes

We don't really know what affect this will have on the terrain generation, but its better than crashing and not having terrain generate at all!
This commit is contained in:
md_5 2014-01-05 09:35:15 +11:00
parent 885ae9871e
commit cd0c975a6d

View File

@ -1,33 +1,15 @@
From 60f931b9efb9140650ffb140af1dee18f557f8fe Mon Sep 17 00:00:00 2001
From: Dan Mulloy <dmulloy2@live.com>
Date: Sun, 22 Dec 2013 18:40:53 -0500
From eed402ce73fec9890879e3ed03ec3ba4e4a2c9e6 Mon Sep 17 00:00:00 2001
From: md_5 <git@md-5.net>
Date: Sun, 5 Jan 2014 09:35:01 +1100
Subject: [PATCH] Fix Biome Decoration Crashes
We don't really know what affect this will have on the terrain generation, but its better than crashing and not having terrain generate at all!
diff --git a/src/main/java/net/minecraft/server/BiomeDecorator.java b/src/main/java/net/minecraft/server/BiomeDecorator.java
index b048d6c..2a5333a 100644
index b048d6c..962d719 100644
--- a/src/main/java/net/minecraft/server/BiomeDecorator.java
+++ b/src/main/java/net/minecraft/server/BiomeDecorator.java
@@ -1,5 +1,10 @@
package net.minecraft.server;
+// Spigot Start
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+// Spigot End
import java.util.Random;
public class BiomeDecorator {
@@ -39,6 +44,7 @@ public class BiomeDecorator {
protected int G;
protected int H;
public boolean I;
+ private final List<Chunk> chunksToUnload = new ArrayList<Chunk>(); // Spigot
public BiomeDecorator() {
this.f = new WorldGenSand(Blocks.SAND, 7);
@@ -147,7 +153,7 @@ public class BiomeDecorator {
@@ -147,7 +147,7 @@ public class BiomeDecorator {
for (j = 0; j < this.z; ++j) {
k = this.c + this.b.nextInt(16) + 8;
l = this.d + this.b.nextInt(16) + 8;
@ -36,17 +18,16 @@ index b048d6c..2a5333a 100644
WorldGenerator worldgenerator = biomebase.b(this.b);
worldgenerator.a(this.a, this.b, k, i1, l);
@@ -156,15 +162,15 @@ public class BiomeDecorator {
@@ -156,7 +156,7 @@ public class BiomeDecorator {
for (j = 0; j < this.A; ++j) {
k = this.c + this.b.nextInt(16) + 8;
l = this.d + this.b.nextInt(16) + 8;
- i1 = this.b.nextInt(this.a.getHighestBlockYAt(k, l) * 2);
- (new WorldGenDeadBush(Blocks.DEAD_BUSH)).a(this.a, this.b, k, i1, l);
+ i1 = this.b.nextInt(this.getHighestBlockYAt(k, l) * 2);
+ (new WorldGenDeadBush(Blocks.DEAD_BUSH)).a(this.a, this.b, k, i1, l); // Spigot
+ i1 = this.b.nextInt(this.getHighestBlockYAt(k, l) * 2); // Spigot
(new WorldGenDeadBush(Blocks.DEAD_BUSH)).a(this.a, this.b, k, i1, l);
}
for (j = 0; j < this.w; ++j) {
@@ -164,7 +164,7 @@ public class BiomeDecorator {
k = this.c + this.b.nextInt(16) + 8;
l = this.d + this.b.nextInt(16) + 8;
@ -55,15 +36,7 @@ index b048d6c..2a5333a 100644
;
}
@@ -175,14 +181,14 @@ public class BiomeDecorator {
if (this.b.nextInt(4) == 0) {
k = this.c + this.b.nextInt(16) + 8;
l = this.d + this.b.nextInt(16) + 8;
- i1 = this.a.getHighestBlockYAt(k, l);
+ i1 = this.getHighestBlockYAt(k, l); // Spigot
this.q.a(this.a, this.b, k, i1, l);
}
@@ -182,7 +182,7 @@ public class BiomeDecorator {
if (this.b.nextInt(8) == 0) {
k = this.c + this.b.nextInt(16) + 8;
l = this.d + this.b.nextInt(16) + 8;
@ -72,7 +45,7 @@ index b048d6c..2a5333a 100644
this.r.a(this.a, this.b, k, i1, l);
}
}
@@ -190,42 +196,42 @@ public class BiomeDecorator {
@@ -190,42 +190,42 @@ public class BiomeDecorator {
if (this.b.nextInt(4) == 0) {
j = this.c + this.b.nextInt(16) + 8;
k = this.d + this.b.nextInt(16) + 8;
@ -121,42 +94,17 @@ index b048d6c..2a5333a 100644
this.u.a(this.a, this.b, k, i1, l);
}
@@ -244,6 +250,7 @@ public class BiomeDecorator {
(new WorldGenLiquids(Blocks.LAVA)).a(this.a, this.b, k, l, i1);
}
}
+ this.unloadChunks(); // Spigot - unload chunks we force loaded
}
protected void a(int i, WorldGenerator worldgenerator, int j, int k) {
@@ -276,4 +283,28 @@ public class BiomeDecorator {
@@ -276,4 +276,11 @@ public class BiomeDecorator {
this.a(1, this.n, 0, 16);
this.b(1, this.o, 16, 16);
}
+
+ // Spigot start - force load chunks
+ private int getHighestBlockYAt(int i, int j)
+ // Spigot Start
+ private int getHighestBlockYAt(int x, int z)
+ {
+ // Make sure the chunk is loaded
+ if ( !this.a.isChunkLoaded( i >> 4, j >> 4 ) )
+ {
+ // If not, load it, then add it to our unload list
+ this.chunksToUnload.add( this.a.getChunkAt( i >> 4, j >> 4 ) );
+ return Math.max( 1, this.a.getHighestBlockYAt( x, z ) );
+ }
+
+ return this.a.getHighestBlockYAt( i, j );
+ }
+
+ private void unloadChunks()
+ {
+ Iterator<Chunk> iter = this.chunksToUnload.iterator();
+ while ( iter.hasNext() )
+ {
+ this.a.getWorld().unloadChunk( iter.next().bukkitChunk );
+ iter.remove();
+ }
+ }
+ // Spigot end
+ // Spigot End
}
--
1.8.3.2