function sphereGetBlockAt(x, y, z, radius, fill, matFunc)
   -- print("x " .. x .. " y " .. y .. " z " .. z .. " r " .. radius)
   -- io.read()
	if y == -3 then
		-- print("x " .. x .. " y " .. y .. " z " .. z .. " r " .. radius)
		-- io.read()
	end
	radius = radius + 0.5
	local dist = math.sqrt(x*x + y*y + z*z)
	if dist > radius then return nil end
	local offsets = {{1, 0, 0}, {-1, 0, 0}, {0, 1, 0}, {0, -1, 0}, {0, 0, 1}, {0, 0, -1}}
	local allNeighborsUnderRadius = true
	local i
	for i = 1,6 do
		local offset = offsets[i]
		local neighborX, neighborY, neighborZ = x + offset[1], y + offset[2], z + offset[3]
		local neighborDist = math.sqrt(neighborX*neighborX + neighborY*neighborY + 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, dome, fill, numMaterials, materialFunc)
	local startX = 0 - radius
	local startY = 0 - radius
	local startZ = 0 - radius
	local sizeX = radius * 2 + 1
	local sizeY = radius * 2 + 1
	local sizeZ = radius * 2 + 1
	if numMaterials == nil then numMaterials = 1 end
	if dome ~= nil and dome then
		startY = 0
		sizeY = radius + 1
	end
	if fill == nil then fill = false 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 sphereGetBlockAt(x, y, z, radius, fill, materialFunc)
	end
	return provider
end


