Fixed an NPE with getWeightedTerrainSettings
This commit is contained in:
parent
0bf145cfd5
commit
9266fae15a
2 changed files with 12 additions and 49 deletions
|
@ -341,15 +341,19 @@ public class ChunkProviderGenerateBOP implements IChunkProvider
|
||||||
{
|
{
|
||||||
float weight = radialFalloff5x5[i + 2 + (j + 2) * 5];
|
float weight = radialFalloff5x5[i + 2 + (j + 2) * 5];
|
||||||
TerrainSettings biomeSettings = this.biomeTerrainSettings.get(biomes[localX + i + 2 + (localZ + j + 2) * 10]);
|
TerrainSettings biomeSettings = this.biomeTerrainSettings.get(biomes[localX + i + 2 + (localZ + j + 2) * 10]);
|
||||||
settings.avgHeight += weight * biomeSettings.avgHeight;
|
|
||||||
settings.variationAbove += weight * biomeSettings.variationAbove;
|
if (biomeSettings != null)
|
||||||
settings.variationBelow += weight * biomeSettings.variationBelow;
|
|
||||||
settings.minHeight += weight * biomeSettings.minHeight;
|
|
||||||
settings.maxHeight += weight * biomeSettings.maxHeight;
|
|
||||||
settings.sidewaysNoiseAmount += weight * biomeSettings.sidewaysNoiseAmount;
|
|
||||||
for (int k = 0; k < settings.octaveWeights.length; k++)
|
|
||||||
{
|
{
|
||||||
settings.octaveWeights[k] += weight * biomeSettings.octaveWeights[k];
|
settings.avgHeight += weight * biomeSettings.avgHeight;
|
||||||
|
settings.variationAbove += weight * biomeSettings.variationAbove;
|
||||||
|
settings.variationBelow += weight * biomeSettings.variationBelow;
|
||||||
|
settings.minHeight += weight * biomeSettings.minHeight;
|
||||||
|
settings.maxHeight += weight * biomeSettings.maxHeight;
|
||||||
|
settings.sidewaysNoiseAmount += weight * biomeSettings.sidewaysNoiseAmount;
|
||||||
|
for (int k = 0; k < settings.octaveWeights.length; k++)
|
||||||
|
{
|
||||||
|
settings.octaveWeights[k] += weight * biomeSettings.octaveWeights[k];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -271,45 +271,4 @@ public class WorldChunkManagerBOP extends WorldChunkManager
|
||||||
return new GenLayer[] {riverMixFinal, biomesFinal, riverMixFinal};
|
return new GenLayer[] {riverMixFinal, biomesFinal, riverMixFinal};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean areBiomesViable(int x, int z, int radius, List<BiomeGenBase> allowedBiomes)
|
|
||||||
{
|
|
||||||
IntCache.resetIntCache();
|
|
||||||
int minX = x - (radius >> 2);
|
|
||||||
int minY = z - (radius >> 2);
|
|
||||||
int maxX = x + (radius >> 2);
|
|
||||||
int maxY = z + (radius >> 2);
|
|
||||||
|
|
||||||
int areaWidth = maxX - minX + 1; //Find difference between the min and the max X. Add 1 as the result cannot be 0
|
|
||||||
int areaHeight = maxY - minY + 1; //Find difference between the min and the max Y. Add 1 as the result cannot be 0
|
|
||||||
int[] biomeIds = this.genBiomes.getInts(minX, minY, areaWidth, areaHeight); //Create an array of the biome ids within the desired area
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
//Ensure entire area contains only desired biomes
|
|
||||||
for (int index = 0; index < areaWidth * areaHeight; ++index)
|
|
||||||
{
|
|
||||||
BiomeGenBase biomegenbase = BiomeGenBase.getBiome(biomeIds[index]);
|
|
||||||
|
|
||||||
if (!allowedBiomes.contains(biomegenbase))
|
|
||||||
{
|
|
||||||
return false; //Stop checking, we have found an undesirable biome
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
catch (Throwable throwable)
|
|
||||||
{
|
|
||||||
CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Invalid Biome id");
|
|
||||||
CrashReportCategory crashreportcategory = crashreport.makeCategory("Layer");
|
|
||||||
crashreportcategory.addCrashSection("Layer", this.genBiomes.toString());
|
|
||||||
crashreportcategory.addCrashSection("x", Integer.valueOf(x));
|
|
||||||
crashreportcategory.addCrashSection("z", Integer.valueOf(z));
|
|
||||||
crashreportcategory.addCrashSection("radius", Integer.valueOf(radius));
|
|
||||||
crashreportcategory.addCrashSection("allowed", allowedBiomes);
|
|
||||||
throw new ReportedException(crashreport);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue