--!native --!optimize 2 local TerrainGen = {} local deflate = require("./TerrainGen/Deflate") local DSS = game:GetService("DataStoreService") local WORLDNAME = "DEFAULT" local WORLDID = "b73bb5a6-297d-4352-b637-daec7e8c8f3e" local Store = DSS:GetDataStore("BlockscraftWorldV1", WORLDID) local ChunkManager = require(game:GetService("ReplicatedStorage"):WaitForChild("Shared").ChunkManager) local Chunk = require(game:GetService("ReplicatedStorage"):WaitForChild("Shared").ChunkManager.Chunk) TerrainGen.ServerChunkCache = {} :: {[typeof("")]: typeof(Chunk.new(0,0,0))} -- Load a chunk from the DataStore or generate it if not found function TerrainGen:GetChunk(x, y, z) local key = `{x},{y},{z}` if TerrainGen.ServerChunkCache[key] then return TerrainGen.ServerChunkCache[key] end -- Generate a new chunk if it doesn't exist local chunk = Chunk.new(x, y, z) if y == 1 then for cx = 1, 8 do for cz = 1, 8 do --local perlin = math.noise(((x*8)+cx)/100,((z*8)+cz)/100) chunk:CreateBlock(cx, 1, cz, { id = 1, state = {} }) --chunk:CreateBlock(x, 2, z, { id = 1, state = {} }) end end end if y == 0 then for cx = 1, 8 do for cy = 1, 8 do for cz = 1, 8 do --local perlin = math.noise(((x*8)+cx)/100,((z*8)+cz)/100) chunk:CreateBlock(cx, cy, cz, { id = 2, state = {} }) --chunk:CreateBlock(x, 2, z, { id = 1, state = {} }) end end end end TerrainGen.ServerChunkCache[key] = chunk return chunk end -- Fake Chunk function TerrainGen:GetFakeChunk(x, y, z) -- Generate a new chunk if it doesn't exist local chunk = Chunk.new(x, y, z) for cy = 1,8 do for cx = 1, 8 do for cz = 1, 8 do --local perlin = math.noise(((x*8)+cx)/100,((z*8)+cz)/100) chunk:CreateBlock(cx, cy, cz, { id = -2, state = {} }) --chunk:CreateBlock(x, 2, z, { id = 1, state = {} }) end end end return chunk end TerrainGen.CM = ChunkManager return TerrainGen