package Hexel.generation.terrainGenerator;
import Hexel.blocks.types.Block;
import Hexel.blocks.types.BlockDirt;
import Hexel.blocks.types.BlockEmpty;
import Hexel.blocks.types.BlockGlass;
import Hexel.blocks.types.BlockSeed;
import Hexel.blocks.types.BlockStone;
import Hexel.blocks.types.BlockWater;
import Hexel.generation.terrainGenerator.heightMaps.FractalHexagonalTypeHeightMap;
import Hexel.generation.terrainGenerator.heightMaps.TypeFractalHeightMapGenerator;
import Hexel.generation.terrainGenerator.typeMaps.ContinentMapGenerator;
import Hexel.generation.terrainGenerator.typeMaps.DrawTypeMap;
import Hexel.generation.terrainGenerator.typeMaps.TypeHeightMapGenerator;
import Hexel.math.Vector2i;
import Hexel.util.Util;
public class VariedTerrainMap implements TerrainMap {
public FractalHexagonalTypeHeightMap tfmg;
private int seed;
public VariedTerrainMap(int seed){
this.seed = seed;
tfmg = new FractalHexagonalTypeHeightMap(seed);
}
@Override
public Block getBlock(int x, int y, int z, Vector2i tmp) {
int tz = 0;
int height = tfmg.getHeight(x, y, tmp, null);
// if (height < -10)
// height = -10;
int waterLevel = tfmg.getWaterHeight(x, y, tmp);
if (z < height){
return BlockDirt.Make(BlockDirt.MAX_HEALTH, false);
}
else if (z == height){
return BlockDirt.Make(BlockDirt.MAX_HEALTH, true);
}
else if (z <= waterLevel){
return BlockWater.Make(0, 0, 8);
}
else if (z == height+1){
int hash = 3;
hash = 97 * hash + x;
hash = 97 * hash + y;
hash = 97 * hash + z;
if (Util.hashToDouble(hash+this.seed) < .01 ) {
return BlockSeed.Make(50, BlockSeed.MAX_HEALTH);
}
else {
return BlockEmpty.Make(0);
}
}
else {
return BlockEmpty.Make(0);
}
}
@Override
public int getHeightMapAt(int x, int y, Vector2i tmp) {
int height = tfmg.getHeight(x, y, tmp, null);
// if (height < -10)
// height = -10;
return height;
}
}