Try to generate random numbers outside the loop.
for (int i = 0; i < Chunk.ChunkWidth; i++)
{
for (int j = 0; j < Chunk.ChunkHeight; j++)
{
if (Chunk.ChunkY > 0)
{
int r = RandomNumber(0, 4);
if (r == 0)
Block.MakeBlock(BlockMaterial.Material_Dirt);
if (r == 1)
Block.MakeBlock(BlockMaterial.Material_Grass);
if (r == 2)
Block.MakeBlock(BlockMaterial.Material_Stone);
}
else
{
Block.MakeBlock(BlockMaterial.Material_Air);
}
Chunk.SetBlock(i, j, Block);
}
}
}
private int RandomNumber(int min, int max)
{
Random random = new Random();
return random.Next(min, max);
}
Debug your program and check what
RandomNumber
function returns.