Fix stoopid NPE

This commit is contained in:
dfsek 2020-11-16 16:54:55 -07:00
parent cab91ec15b
commit 00c933c06e
3 changed files with 6 additions and 3 deletions

View File

@ -22,6 +22,7 @@ public class AirSpawn extends Requirement {
BiomeConfig c = wc.getBiome(b);
if(y <= c.getOcean().getSeaLevel()) return false;
ElevationEquation elevationEquation = ((UserDefinedGenerator) b.getGenerator()).getElevationEquation();
return b.getGenerator().getNoise(getNoise(), getWorld(), x, (int) (y - elevationEquation.getNoise(x, z, getWorld())), z) <= 0;
int yf = y - ((elevationEquation == null) ? 0 : (int) elevationEquation.getNoise(x, z, getWorld()));
return b.getGenerator().getNoise(getNoise(), getWorld(), x, yf, z) <= 0;
}
}

View File

@ -17,6 +17,7 @@ public class LandSpawn extends Requirement {
TerraWorld tw = TerraWorld.getWorld(getWorld());
UserDefinedBiome b = (UserDefinedBiome) tw.getGrid().getBiome(x, z, GenerationPhase.POPULATE);
ElevationEquation elevationEquation = ((UserDefinedGenerator) b.getGenerator()).getElevationEquation();
return b.getGenerator().getNoise(getNoise(), getWorld(), x, (int) (y - elevationEquation.getNoise(x, z, getWorld())), z) > 0;
int yf = y - ((elevationEquation == null) ? 0 : (int) elevationEquation.getNoise(x, z, getWorld()));
return b.getGenerator().getNoise(getNoise(), getWorld(), x, yf, z) > 0;
}
}

View File

@ -20,6 +20,7 @@ public class OceanSpawn extends Requirement {
BiomeConfig c = tw.getConfig().getBiome(b);
if(y > c.getOcean().getSeaLevel()) return false;
ElevationEquation elevationEquation = ((UserDefinedGenerator) b.getGenerator()).getElevationEquation();
return b.getGenerator().getNoise(getNoise(), getWorld(), x, (int) (y - elevationEquation.getNoise(x, z, getWorld())), z) <= 0;
int yf = y - ((elevationEquation == null) ? 0 : (int) elevationEquation.getNoise(x, z, getWorld()));
return b.getGenerator().getNoise(getNoise(), getWorld(), x, yf, z) <= 0;
}
}