Fixed world generator not saving generated values.

This commit is contained in:
Harrison Deng 2020-04-24 22:10:59 -05:00
parent c5e3c08546
commit d0facd268a

View File

@ -49,26 +49,27 @@ public class IslandWorldGenerator {
// gets the bedrock.
int bedrockHeight = bedrockGenerator.getBedrockHeight(worldX, worldZ);
// Sets the biome.
//Sets the biome.
Biome currentBiome = biomeGenerator.GenerateBiome(chunkX, chunkZ, localX, localZ);
if (currentBiome == null) throw new IllegalStateException("Biome generated was null!");
for (int y = 0; y < maxHeight; y++) {
biomeGrid.setBiome(localX, y, localZ, currentBiome);
}
// get height shader.
int height;
//get height shader.
int height = 0;
try {
height = heightShader.getAltitude(worldX, worldZ, currentBiome);
} catch (InvalidAlgorithmParameterException e) {
e.printStackTrace();
height = maxHeight;
}
if (height == 0) throw new IllegalStateException("Height generated was null!");
//set general shape
chunk.setRegion(localX, 0, localZ, localX, height, localZ, Material.STONE);
chunk.setRegion(localX, 0, localZ, localX + 1, height, localZ + 1, Material.STONE);
//set bedrock last
chunk.setRegion(localX, 0, localZ, localX, bedrockHeight, localZ, Material.BEDROCK);
chunk.setRegion(localX, 0, localZ, localX + 1, bedrockHeight, localZ + 1, Material.BEDROCK);
}
}