-- this is basically the same as the worldcode
genZoneContChunkTile :: Int -> Int -> Int -> Int -> Int -> Int -> Int -> Int -> Int -> Int -> Int -> Int -> Int -> [Biome] -> [Int] -> [Int] -> (Int, Int) -> (Int, Int)
genZoneContChunkTile gridw gridh zonew zoneh x y it c j w x0 y0 z0 types sizes rrands (t, i)
  | (randstate == BValley) && (zoneDistance zonew zoneh x y i j w x0         y0         z0 t' < fromIntegral(8*(maxdist-cfudge))) = (t, i)
  | (randstate == BValley) && (zoneDistance zonew zoneh x y i j w (x0+gridw) y0         z0 t' < fromIntegral(8*(maxdist-cfudge))) = (t, i)
  | (randstate == BValley) && (zoneDistance zonew zoneh x y i j w x0         (y0+gridh) z0 t' < fromIntegral(8*(maxdist-cfudge))) = (t, i)
  | (randstate == BValley) && (zoneDistance zonew zoneh x y i j w (x0-gridw) y0         z0 t' < fromIntegral(8*(maxdist-cfudge))) = (t, i)
  | (randstate == BValley) && (zoneDistance zonew zoneh x y i j w x0         (y0-gridh) z0 t' < fromIntegral(8*(maxdist-cfudge))) = (t, i)
  | (randstate == BValley) && (zoneDistance zonew zoneh x y i j w x0         y0         z0 t' <= fromIntegral((maxdist)*4))       = (r, i)
  | (randstate == BValley) && (zoneDistance zonew zoneh x y i j w (x0+gridw) y0         z0 t' <= fromIntegral((maxdist)*4))       = (r, i)
  | (randstate == BValley) && (zoneDistance zonew zoneh x y i j w x0         (y0+gridh) z0 t' <= fromIntegral((maxdist)*4))       = (r, i)
  | (randstate == BValley) && (zoneDistance zonew zoneh x y i j w (x0-gridw) y0         z0 t' <= fromIntegral((maxdist)*4))       = (r, i)
  | (randstate == BValley) && (zoneDistance zonew zoneh x y i j w x0         (y0-gridh) z0 t' <= fromIntegral((maxdist)*4))       = (r, i)
  | (randstate == BCrags)  && (zoneDistance zonew zoneh x y i j w x0         y0         z0 t' < fromIntegral((maxdist-cfudge)))   = (t, i)
  | (randstate == BCrags)  && (zoneDistance zonew zoneh x y i j w (x0+gridw) y0         z0 t' < fromIntegral((maxdist-cfudge)))   = (t, i)
  | (randstate == BCrags)  && (zoneDistance zonew zoneh x y i j w x0         (y0+gridh) z0 t' < fromIntegral((maxdist-cfudge)))   = (t, i)
  | (randstate == BCrags)  && (zoneDistance zonew zoneh x y i j w (x0-gridw) y0         z0 t' < fromIntegral((maxdist-cfudge)))   = (t, i)
  | (randstate == BCrags)  && (zoneDistance zonew zoneh x y i j w x0         (y0-gridh) z0 t' < fromIntegral((maxdist-cfudge)))   = (t, i)
  |                            zoneDistance zonew zoneh x y i j w x0         y0         z0 t' <= fromIntegral(maxdist)            = (r, i)
  |                            zoneDistance zonew zoneh x y i j w (x0+gridw) y0         z0 t' <= fromIntegral(maxdist)            = (r, i)
  |                            zoneDistance zonew zoneh x y i j w x0         (y0+gridh) z0 t' <= fromIntegral(maxdist)            = (r, i)
  |                            zoneDistance zonew zoneh x y i j w (x0-gridw) y0         z0 t' <= fromIntegral(maxdist)            = (r, i)
  |                            zoneDistance zonew zoneh x y i j w x0         (y0-gridh) z0 t' <= fromIntegral(maxdist)            = (r, i)
  | otherwise                                                                                                       = (t, i)
  where
    randstate = types !! c
    r         = biomeToInt randstate
    maxdist   = 1000 * ((sizes) !! c)
    cfudge    = 2      * ((rrands !! c) - 1)
    t'        = fromIntegral t

-- a simple conversion function to abstract biome numbers
genZoneContChunkTile :: Int -> Int -> Int -> Int -> Int -> Int -> Int -> Int -> Int -> Int -> Int -> Int -> Int -> [Biome] -> [Int] -> [Int] -> (Int, Int) -> (Int, Int)
genZoneContChunkTile gridw gridh zonew zoneh x y it c j w x0 y0 z0 types sizes rrands (t, i)
  | (randstate == BValley) && (zoneDistance zonew zoneh x y i j w x0         y0         z0 t' < fromIntegral(8*(maxdist-cfudge))) = (t, i)
  | (randstate == BValley) && (zoneDistance zonew zoneh x y i j w (x0+gridw) y0         z0 t' < fromIntegral(8*(maxdist-cfudge))) = (t, i)
  | (randstate == BValley) && (zoneDistance zonew zoneh x y i j w x0         (y0+gridh) z0 t' < fromIntegral(8*(maxdist-cfudge))) = (t, i)
  | (randstate == BValley) && (zoneDistance zonew zoneh x y i j w (x0-gridw) y0         z0 t' < fromIntegral(8*(maxdist-cfudge))) = (t, i)
  | (randstate == BValley) && (zoneDistance zonew zoneh x y i j w x0         (y0-gridh) z0 t' < fromIntegral(8*(maxdist-cfudge))) = (t, i)
  | (randstate == BValley) && (zoneDistance zonew zoneh x y i j w x0         y0         z0 t' <= fromIntegral((maxdist)*4))       = (r, i)
  | (randstate == BValley) && (zoneDistance zonew zoneh x y i j w (x0+gridw) y0         z0 t' <= fromIntegral((maxdist)*4))       = (r, i)
  | (randstate == BValley) && (zoneDistance zonew zoneh x y i j w x0         (y0+gridh) z0 t' <= fromIntegral((maxdist)*4))       = (r, i)
  | (randstate == BValley) && (zoneDistance zonew zoneh x y i j w (x0-gridw) y0         z0 t' <= fromIntegral((maxdist)*4))       = (r, i)
  | (randstate == BValley) && (zoneDistance zonew zoneh x y i j w x0         (y0-gridh) z0 t' <= fromIntegral((maxdist)*4))       = (r, i)
  | (randstate == BCrags)  && (zoneDistance zonew zoneh x y i j w x0         y0         z0 t' < fromIntegral((maxdist-cfudge)))   = (t, i)
  | (randstate == BCrags)  && (zoneDistance zonew zoneh x y i j w (x0+gridw) y0         z0 t' < fromIntegral((maxdist-cfudge)))   = (t, i)
  | (randstate == BCrags)  && (zoneDistance zonew zoneh x y i j w x0         (y0+gridh) z0 t' < fromIntegral((maxdist-cfudge)))   = (t, i)
  | (randstate == BCrags)  && (zoneDistance zonew zoneh x y i j w (x0-gridw) y0         z0 t' < fromIntegral((maxdist-cfudge)))   = (t, i)
  | (randstate == BCrags)  && (zoneDistance zonew zoneh x y i j w x0         (y0-gridh) z0 t' < fromIntegral((maxdist-cfudge)))   = (t, i)
  |                            zoneDistance zonew zoneh x y i j w x0         y0         z0 t' <= fromIntegral(maxdist)            = (r, i)
  |                            zoneDistance zonew zoneh x y i j w (x0+gridw) y0         z0 t' <= fromIntegral(maxdist)            = (r, i)
  |                            zoneDistance zonew zoneh x y i j w x0         (y0+gridh) z0 t' <= fromIntegral(maxdist)            = (r, i)
  |                            zoneDistance zonew zoneh x y i j w (x0-gridw) y0         z0 t' <= fromIntegral(maxdist)            = (r, i)
  |                            zoneDistance zonew zoneh x y i j w x0         (y0-gridh) z0 t' <= fromIntegral(maxdist)            = (r, i)
  | otherwise                                                                                                       = (t, i)
  where
    randstate = types !! c
    r         = biomeToInt randstate
    maxdist   = 1000 * ((sizes) !! c)
    cfudge    = 2      * ((rrands !! c) - 1)
    t'        = fromIntegral t

-- a simple conversion function to abstract biome numbers
genZoneContChunkTile gridw gridh zonew zoneh x y it c j w x0 y0 z0 types sizes rrands (t, i)
  | (randstate == BValley) && (zoneDistance zonew zoneh x y i j w x0         y0         z0 t' < fromIntegral(8*(maxdist-cfudge))) = (t, i)
  | (randstate == BValley) && (zoneDistance zonew zoneh x y i j w (x0+gridw) y0         z0 t' < fromIntegral(8*(maxdist-cfudge))) = (t, i)
  | (randstate == BValley) && (zoneDistance zonew zoneh x y i j w x0         (y0+gridh) z0 t' < fromIntegral(8*(maxdist-cfudge))) = (t, i)
  | (randstate == BValley) && (zoneDistance zonew zoneh x y i j w (x0-gridw) y0         z0 t' < fromIntegral(8*(maxdist-cfudge))) = (t, i)
  | (randstate == BValley) && (zoneDistance zonew zoneh x y i j w x0         (y0-gridh) z0 t' < fromIntegral(8*(maxdist-cfudge))) = (t, i)
  | (randstate == BValley) && (zoneDistance zonew zoneh x y i j w x0         y0         z0 t' <= fromIntegral((maxdist)*4))       = (r, i)
  | (randstate == BValley) && (zoneDistance zonew zoneh x y i j w (x0+gridw) y0         z0 t' <= fromIntegral((maxdist)*4))       = (r, i)
  | (randstate == BValley) && (zoneDistance zonew zoneh x y i j w x0         (y0+gridh) z0 t' <= fromIntegral((maxdist)*4))       = (r, i)
  | (randstate == BValley) && (zoneDistance zonew zoneh x y i j w (x0-gridw) y0         z0 t' <= fromIntegral((maxdist)*4))       = (r, i)
  | (randstate == BValley) && (zoneDistance zonew zoneh x y i j w x0         (y0-gridh) z0 t' <= fromIntegral((maxdist)*4))       = (r, i)
  | (randstate == BCrags)  && (zoneDistance zonew zoneh x y i j w x0         y0         z0 t' < fromIntegral((maxdist-cfudge)))   = (t, i)
  | (randstate == BCrags)  && (zoneDistance zonew zoneh x y i j w (x0+gridw) y0         z0 t' < fromIntegral((maxdist-cfudge)))   = (t, i)
  | (randstate == BCrags)  && (zoneDistance zonew zoneh x y i j w x0         (y0+gridh) z0 t' < fromIntegral((maxdist-cfudge)))   = (t, i)
  | (randstate == BCrags)  && (zoneDistance zonew zoneh x y i j w (x0-gridw) y0         z0 t' < fromIntegral((maxdist-cfudge)))   = (t, i)
  | (randstate == BCrags)  && (zoneDistance zonew zoneh x y i j w x0         (y0-gridh) z0 t' < fromIntegral((maxdist-cfudge)))   = (t, i)
  |                            zoneDistance zonew zoneh x y i j w x0         y0         z0 t' <= fromIntegral(maxdist)            = (r, i)
  |                            zoneDistance zonew zoneh x y i j w (x0+gridw) y0         z0 t' <= fromIntegral(maxdist)            = (r, i)
  |                            zoneDistance zonew zoneh x y i j w x0         (y0+gridh) z0 t' <= fromIntegral(maxdist)            = (r, i)
  |                            zoneDistance zonew zoneh x y i j w (x0-gridw) y0         z0 t' <= fromIntegral(maxdist)            = (r, i)
  |                            zoneDistance zonew zoneh x y i j w x0         (y0-gridh) z0 t' <= fromIntegral(maxdist)            = (r, i)
  | otherwise                                                                                                       = (t, i)
  where
    randstate = types !! c
    r         = biomeToInt randstate
    maxdist   = 1000 * ((sizes) !! c)
    cfudge    = 2      * ((rrands !! c) - 1)
    t'        = fromIntegral t

-- a simple conversion function to abstract biome numbers