function circleGetBlockAt(x, y, z, radius, fill, matFunc)
  -- print("x " .. x .. " z " .. z .. " r " .. radius)
  -- io.read()
	radius = radius + 0.5
	local dist = math.sqrt(x*x + z*z)
	if dist > radius then return nil end
	local offsets = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}}
	local allNeighborsUnderRadius = true
	local i
	for i = 1,4 do
		local offset = offsets[i]
		local neighborX, neighborZ = x + offset[1], z + offset[2]
		local neighborDist = math.sqrt(neighborX*neighborX + neighborZ*neighborZ)
		if neighborDist > radius then allNeighborsUnderRadius = false end
	end
	if allNeighborsUnderRadius and not fill then return nil end
	return matFunc(x, y, z)
end

function prov(radius, material, fill, height, numMaterials, materialFunc)
	local startX = 0 - radius
	local startY = 0
	local startZ = 0 - radius
	local sizeX = radius * 2 + 1
	local sizeY = 1
	local sizeZ = radius * 2 + 1
	if height ~= nil then sizeY = height end
	if numMaterials == nil then numMaterials = 1 end
	local provider = {}
	provider.startX = startX
	provider.startY = startY
	provider.startZ = startZ
	provider.sizeX = sizeX
	provider.sizeY = sizeY
	provider.sizeZ = sizeZ
	provider.numMaterials = numMaterials
	if materialFunc == nil then
		materialFunc = function()
			if material == nil then
				return 1
			else
				return material
			end
		end
	end
	provider.getBlockAt = function(x, y, z)
		return circleGetBlockAt(x, y, z, radius, fill, materialFunc)
	end
	return provider
end


