Improved code structure for shading map.

World layering improved by adjusting desert sand thickness and lowering overall mountain peak height.
This commit is contained in:
Harrison Deng 2020-05-16 18:23:14 -05:00
parent 7d985f4489
commit 262a83c7e9
2 changed files with 19 additions and 7 deletions

View File

@ -68,13 +68,23 @@ public class IslandMapItem extends MapRenderer implements VariedItem {
for (int y = 0; y < 128; y ++) {
int actualX = blocksPerPixel * (x - Byte.MAX_VALUE/2) + map.getCenterX();
int actualZ = blocksPerPixel * (y - Byte.MAX_VALUE/2) + map.getCenterZ();
byte baseColorVal = canvas.getBasePixel(x, y);
Color baseColor = MapPalette.getColor(baseColorVal);
Point2 pCoords = new Point2(actualX, actualZ);
IslandInformation info = islandInformationManager.getIslandInformation(pCoords, false);
if (info != null) {
Color mixed = new Color((int) Math.min(255, baseColor.getRed() * 1.5f), (int) Math.min(255, baseColor.getGreen() * 0.7f), (int) Math.min(255, baseColor.getBlue() * 0.44f));
canvas.setPixel(x, y, MapPalette.matchColor(mixed));
byte baseColorVal = canvas.getBasePixel(x, y);
Color mainColor = new Color(255, 120, 70);
Color baseColor = null;
if (baseColorVal != 0) {
baseColor = MapPalette.getColor(baseColorVal);
} else {
baseColor = new Color(1f, 1f, 1f);
}
Color resultingColor = new Color(
(mainColor.getRed() * baseColor.getRed())/(255f * 255f),
(mainColor.getGreen() * baseColor.getGreen())/(255f * 255f),
(mainColor.getBlue() * baseColor.getBlue())/(255f * 255f)
);
canvas.setPixel(x, y, MapPalette.matchColor(resultingColor));
}
}
}

View File

@ -80,7 +80,7 @@ public class WorldLayerShader {
}
}
} else if (mainBiomeName.contains("mountain")) {
if (y > (maxHeight * 0.48d) - getNormalizedNoise(worldX, worldZ, 2.2f) * 8d) {
if (y > (maxHeight * 0.36d) - getNormalizedNoise(worldX, worldZ, 2.2f) * 8d) {
res = Material.STONE.createBlockData();
} else if (y > highestPoint - getSurfaceThickness(worldX, worldZ, mainBiome)) {
res = getSurfaceMaterial(mainBiome).createBlockData();
@ -98,7 +98,7 @@ public class WorldLayerShader {
return Material.SAND;
} else if (biome == Biome.ICE_SPIKES) {
return Material.SNOW_BLOCK;
} else if (biomeName.contains("ocean")) {
} else if (biomeName.contains("ocean") || biomeName.contains("gravelly")) {
return Material.GRAVEL;
} else if (biomeName.contains("stone")) {
return Material.STONE;
@ -109,8 +109,10 @@ public class WorldLayerShader {
public int getSurfaceThickness(int worldX, int worldZ, Biome biome) {
String biomeName = biome.toString().toLowerCase();
if (biomeName.contains("beach")) {
if (biomeName.contains("beach") || biomeName.contains("desert")) {
return (int) (getNormalizedNoise(worldX, worldZ, 1.3f) * 5) + 4;
} else if (biomeName.contains("gravelly")) {
return (int) (getNormalizedNoise(worldX, worldZ, 1.3f) * 5);
}
return 1;
}