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. // gets the bedrock.
int bedrockHeight = bedrockGenerator.getBedrockHeight(worldX, worldZ); int bedrockHeight = bedrockGenerator.getBedrockHeight(worldX, worldZ);
// Sets the biome. //Sets the biome.
Biome currentBiome = biomeGenerator.GenerateBiome(chunkX, chunkZ, localX, localZ); 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++) { for (int y = 0; y < maxHeight; y++) {
biomeGrid.setBiome(localX, y, localZ, currentBiome); biomeGrid.setBiome(localX, y, localZ, currentBiome);
} }
// get height shader. //get height shader.
int height; int height = 0;
try { try {
height = heightShader.getAltitude(worldX, worldZ, currentBiome); height = heightShader.getAltitude(worldX, worldZ, currentBiome);
} catch (InvalidAlgorithmParameterException e) { } catch (InvalidAlgorithmParameterException e) {
e.printStackTrace(); e.printStackTrace();
height = maxHeight; height = maxHeight;
} }
if (height == 0) throw new IllegalStateException("Height generated was null!");
//set general shape //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 //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);
} }
} }