public void Initialize(Vector3i position, World world) { this.position = position; this.size = world.GetChunkSize(); this.blockDatabase = world.blockDatabase; this.worldPosition = position.Multiply(this.size); this.blocks = new Block[this.size, this.size, this.size]; Dictionary <Vector3i, byte> blocks; bool hasChanges = world.HasChunkChanges(this.position, out blocks); for (int x = 0; x < this.size; x++) { for (int z = 0; z < this.size; z++) { int terrainHeight = GetHeight(x + this.worldPosition.x, z + this.worldPosition.z, world.GetWorldSeed()); for (int y = 0; y < this.size; y++) { byte blockType; this.blocks [x, y, z] = new Block(); if (hasChanges && blocks.TryGetValue(new Vector3i(x, y, z), out blockType)) { //print ("OK"); } else { blockType = 0; if (y < terrainHeight) { blockType = GetType(x + this.worldPosition.x, y + this.worldPosition.y, z + this.worldPosition.z, world.GetWorldSeed()); } } this.blocks [x, y, z].type = blockType; this.blocks [x, y, z].health = this.blockDatabase.blockMaterials [blockType].hardness; } } } MeshArchitect meshArchitect = new MeshArchitect(this.size, this.blocks, this.blockDatabase); GetComponent <MeshRenderer> ().material = this.blockDatabase.materialAtlas; UpdateMesh(meshArchitect); }