(Re)added shorelines and fixed both deep and transitional ocean generation.

This commit is contained in:
Harrison Deng 2020-05-09 00:26:50 -05:00
parent 3ab1e05569
commit d8c0961e2b
3 changed files with 24 additions and 47 deletions

View File

@ -16,7 +16,7 @@ public class LandBiomeInfo implements Weightable, BiomeInfo {
* @param biome the main biome this object represents.
* @param transitionBiome the transition biome to go with this biome. May be null.
* @param hill the hill biome that goes with this biome. May be null.
* @param shore the preferred shore that goes with this biome. May be null.
* @param shore the shore that goes with this biome. May be null.
* @param weight the weight, relative to the others, chance this biome spawns.
*/
public LandBiomeInfo(Biome biome, Biome transitionBiome, Biome hill, Biome shore, float weight) {
@ -28,6 +28,13 @@ public class LandBiomeInfo implements Weightable, BiomeInfo {
this.transitionBiome = transitionBiome;
}
/**
* Creates a land biome information object.
* Leaves the transition biome and hill biomes as null.
* The shore is set to beach.
* @param biome The biome this object represents.
* @param weight The probability of selecting this biome.
*/
public LandBiomeInfo(Biome biome, float weight) {
this(biome, null, null, Biome.BEACH, weight);
}
@ -39,26 +46,20 @@ public class LandBiomeInfo implements Weightable, BiomeInfo {
return weight;
}
/**
* @return the biome
*/
public Biome getBiome() {
return biome;
}
/**
* @return the hill biome. Will return the normal biome if there is no special hill biome for this biome.
*/
public Biome getHillBiome() {
if (hillBiome == null) return getBiome();
if (hillBiome == null) return getMainBiome();
return hillBiome;
}
/**
* @return the shore biome. Should not have shore if null is returned.
* @return the shore biome. Will return the normal biome if there is no shore specificied.
*/
public Biome getPreferredShore() {
return preferredShore;
public Biome getShoreBiome() {
if (preferredShore != null) return preferredShore;
return getMainBiome();
}
/**

View File

@ -19,7 +19,6 @@ public class IslandWorldMap {
private final float ISLAND_PERCENT = 0.36f;
private final double NOISE_FREQ = 1.78D;
private final double NOISE_AMP = 0.47D;
private final float SHORE_PORTION = 0.095f;
private final float SHALLOW_PORTION = 0.06f;
private final double SCALE = 0.005D;
private final DepthFirstSearch dfs;
@ -64,22 +63,6 @@ public class IslandWorldMap {
isSameIsland(worldX, worldZ, worldX, worldZ - 1));
}
/**
* These coordinates are considered to be the shore if:
* It is a part of an island,
* the island value is less than the shore factor.
* @param worldX the X coordinate of location in world.
* @param worldZ the Z coordinate of location in world.
* @return
*/
public boolean isShore(int worldX, int worldZ) {
if (!isIsland(worldX, worldZ)) return false;
if (isLand(worldX, worldZ) && getWorldValue(worldX, worldZ) <= SHORE_PORTION) {
return true;
}
return false;
}
/**
* Considers these coordinates to be part of an island if:
* It is land, or if it is a shallow portion of land.

View File

@ -33,6 +33,7 @@ public class IslandWorldChunkGenerator extends ChunkGenerator implements Listene
private final float TRANSITION_DEPTH_PORTION = 0.1f;
private final float DEEP_OCEAN_PORTION = 0.5f;
private final float HILL_BIOME_PORTION = 0.4f;
private final float SHORE_PORTION = 0.095f;
private final int BEDROCK_HEIGHT = 5;
private volatile GeneratorModes generatorType;
private volatile boolean initialized = false;
@ -110,35 +111,27 @@ public class IslandWorldChunkGenerator extends ChunkGenerator implements Listene
double islandVal = islandMap.getWorldValue(worldX, worldZ);
if (islandVal >= HILL_BIOME_PORTION) {
currentBiome = biomeInfo.getHillBiome();
for (int y = 0; y < worldInfo.getWorldHeight(); y++) {
biomeGrid.setBiome(localX, y, localZ, biomeInfo.getHillBiome());
}
} else {
currentBiome = biomeInfo.getBiome();
for (int y = 0; y < worldInfo.getWorldHeight(); y++) {
biomeGrid.setBiome(localX, y, localZ, biomeInfo.getBiome());
if (islandVal <= SHORE_PORTION) {
currentBiome = biomeInfo.getShoreBiome();
} else {
currentBiome = biomeInfo.getMainBiome();
}
}
} else {
OceanBiomeInfo biomeInfo = (OceanBiomeInfo) localBiomeInfos[localX][localZ];
double oceanVal = islandMap.getWorldValue(worldX, worldZ);
if (oceanVal >= TRANSITION_DEPTH_PORTION) {
if (oceanVal >= -TRANSITION_DEPTH_PORTION) {
currentBiome = biomeInfo.getTransitionOcean();
for (int y = 0; y < worldInfo.getWorldHeight(); y++) {
biomeGrid.setBiome(localX, y, localZ, biomeInfo.getTransitionOcean());
}
} else if (oceanVal >= DEEP_OCEAN_PORTION) {
} else if (oceanVal >= -DEEP_OCEAN_PORTION) {
currentBiome = biomeInfo.getOcean();
for (int y = 0; y < worldInfo.getWorldHeight(); y++) {
biomeGrid.setBiome(localX, y, localZ, biomeInfo.getOcean());
}
} else {
currentBiome = biomeInfo.getDeepAlternative();
for (int y = 0; y < worldInfo.getWorldHeight(); y++) {
biomeGrid.setBiome(localX, y, localZ, biomeInfo.getDeepAlternative());
}
}
}
for (int y = 0; y < worldInfo.getWorldHeight(); y++) {
biomeGrid.setBiome(localX, y, localZ, currentBiome);
}
BiomeInfo currentBiomeInfo = localBiomeInfos[localX][localZ];
int terrainHeight = heightShader.getTerrainHeight(worldX, worldZ, currentBiomeInfo);
@ -199,7 +192,7 @@ public class IslandWorldChunkGenerator extends ChunkGenerator implements Listene
@Override
public boolean shouldGenerateStructures() {
return true;
return false;
}
@Override