3
0

Cap chunk generation to 1 chunk per tick (configurable)

This commit is contained in:
Sergey Shatunov
2016-03-16 12:01:28 +07:00
parent 232bc98881
commit 8d2ba00f70
9 changed files with 261 additions and 60 deletions

View File

@ -15,40 +15,15 @@
public class BiomeDecorator
{
public World currentWorld;
@@ -61,6 +69,8 @@
@@ -61,6 +69,7 @@
public int clayPerChunk;
public int bigMushroomsPerChunk;
public boolean generateLakes;
+ private final List<Chunk> chunksToUnload = new ArrayList<Chunk>(); // Spigot
+ private final java.util.concurrent.locks.Lock decorateLock = new java.util.concurrent.locks.ReentrantLock();
private static final String __OBFID = "CL_00000164";
public BiomeDecorator()
@@ -92,12 +102,8 @@
public void decorateChunk(World p_150512_1_, Random p_150512_2_, BiomeGenBase p_150512_3_, int p_150512_4_, int p_150512_5_)
{
- if (this.currentWorld != null)
- {
- throw new RuntimeException("Already decorating!!");
- }
- else
- {
+ decorateLock.lock();
+ try {
this.currentWorld = p_150512_1_;
this.randomGenerator = p_150512_2_;
this.chunk_X = p_150512_4_;
@@ -105,6 +111,8 @@
this.genDecorations(p_150512_3_);
this.currentWorld = null;
this.randomGenerator = null;
+ } finally {
+ decorateLock.unlock();
}
}
@@ -194,7 +202,7 @@
@@ -194,7 +196,7 @@
{
k = this.chunk_X + this.randomGenerator.nextInt(16) + 8;
l = this.chunk_Z + this.randomGenerator.nextInt(16) + 8;
@ -57,7 +32,7 @@
WorldGenerator worldgenerator = p_150513_1_.getRandomWorldGenForGrass(this.randomGenerator);
worldgenerator.generate(this.currentWorld, this.randomGenerator, k, i1, l);
}
@@ -204,7 +212,7 @@
@@ -204,7 +206,7 @@
{
k = this.chunk_X + this.randomGenerator.nextInt(16) + 8;
l = this.chunk_Z + this.randomGenerator.nextInt(16) + 8;
@ -66,7 +41,7 @@
(new WorldGenDeadBush(Blocks.deadbush)).generate(this.currentWorld, this.randomGenerator, k, i1, l);
}
@@ -214,7 +222,7 @@
@@ -214,7 +216,7 @@
k = this.chunk_X + this.randomGenerator.nextInt(16) + 8;
l = this.chunk_Z + this.randomGenerator.nextInt(16) + 8;
@ -75,7 +50,7 @@
{
;
}
@@ -229,7 +237,7 @@
@@ -229,7 +231,7 @@
{
k = this.chunk_X + this.randomGenerator.nextInt(16) + 8;
l = this.chunk_Z + this.randomGenerator.nextInt(16) + 8;
@ -84,7 +59,7 @@
this.mushroomBrownGen.generate(this.currentWorld, this.randomGenerator, k, i1, l);
}
@@ -237,7 +245,7 @@
@@ -237,7 +239,7 @@
{
k = this.chunk_X + this.randomGenerator.nextInt(16) + 8;
l = this.chunk_Z + this.randomGenerator.nextInt(16) + 8;
@ -93,7 +68,7 @@
this.mushroomRedGen.generate(this.currentWorld, this.randomGenerator, k, i1, l);
}
}
@@ -246,7 +254,7 @@
@@ -246,7 +248,7 @@
{
j = this.chunk_X + this.randomGenerator.nextInt(16) + 8;
k = this.chunk_Z + this.randomGenerator.nextInt(16) + 8;
@ -102,7 +77,7 @@
this.mushroomBrownGen.generate(this.currentWorld, this.randomGenerator, j, l, k);
}
@@ -254,7 +262,7 @@
@@ -254,7 +256,7 @@
{
j = this.chunk_X + this.randomGenerator.nextInt(16) + 8;
k = this.chunk_Z + this.randomGenerator.nextInt(16) + 8;
@ -111,7 +86,7 @@
this.mushroomRedGen.generate(this.currentWorld, this.randomGenerator, j, l, k);
}
@@ -263,7 +271,7 @@
@@ -263,7 +265,7 @@
{
k = this.chunk_X + this.randomGenerator.nextInt(16) + 8;
l = this.chunk_Z + this.randomGenerator.nextInt(16) + 8;
@ -120,7 +95,7 @@
this.reedGen.generate(this.currentWorld, this.randomGenerator, k, i1, l);
}
@@ -271,7 +279,7 @@
@@ -271,7 +273,7 @@
{
k = this.chunk_X + this.randomGenerator.nextInt(16) + 8;
l = this.chunk_Z + this.randomGenerator.nextInt(16) + 8;
@ -129,7 +104,7 @@
this.reedGen.generate(this.currentWorld, this.randomGenerator, k, i1, l);
}
@@ -280,7 +288,7 @@
@@ -280,7 +282,7 @@
{
j = this.chunk_X + this.randomGenerator.nextInt(16) + 8;
k = this.chunk_Z + this.randomGenerator.nextInt(16) + 8;
@ -138,7 +113,7 @@
(new WorldGenPumpkin()).generate(this.currentWorld, this.randomGenerator, j, l, k);
}
@@ -289,7 +297,7 @@
@@ -289,7 +291,7 @@
{
k = this.chunk_X + this.randomGenerator.nextInt(16) + 8;
l = this.chunk_Z + this.randomGenerator.nextInt(16) + 8;
@ -147,7 +122,7 @@
this.cactusGen.generate(this.currentWorld, this.randomGenerator, k, i1, l);
}
@@ -313,6 +321,7 @@
@@ -313,6 +315,7 @@
}
}
@ -155,7 +130,7 @@
MinecraftForge.EVENT_BUS.post(new DecorateBiomeEvent.Post(currentWorld, randomGenerator, chunk_X, chunk_Z));
}
@@ -360,6 +369,31 @@
@@ -360,6 +363,31 @@
MinecraftForge.ORE_GEN_BUS.post(new OreGenEvent.Post(currentWorld, randomGenerator, chunk_X, chunk_Z));
}