private void SetBlock(ChunkSubspacePosition position, BlockDefinition definition, bool triggerLightingUpdate) { lock (padlock) { if (position.x < 0 || position.x >= SIZE || position.y < 0 || position.y >= SIZE || position.z < 0 || position.z >= SIZE) { return; } if (triggerLightingUpdate) { BlockSpacePosition blockPosition = position.GetBlockSpacePosition(this); RenderService.MarkChunksWithinMaxLightRadiusForMeshUpdate(blockPosition); } else { PutInChunkProcessingList(); } dirty = true; if (MeshGenerationIsInProgress()) { BlockModification modification; modification.position = position; modification.definition = definition; modificationList.Enqueue(modification); } else { BlockDefinition prevDefinition; prevDefinition = blocks[position.x, position.y, position.z].GetDefinition(); blocks[position.x, position.y, position.z].Set(definition); if (definition.IsActive() == false) { FlushBlockRemoval(position, definition, prevDefinition); } else { FlushBlockSet(position, definition, prevDefinition); } } } }