public void SetBlock(Block block, Chunk chunk, BlockPos pos) { if (chunk == null) { return; } block.Modified = false; chunk.SetBlock(pos, block, false); }
/// <summary> /// Gets the chunk and sets the block at the given coordinates, updates the chunk and its /// neighbors if the update chunk flag is true or not set. Uses global coordinates, to use /// local coordinates use the chunk's SetBlock function. /// </summary> /// <param name="pos">Global position of the block</param> /// <param name="block">The block be placed</param> /// <param name="updateChunk">Optional parameter, set to false not update the chunk despite the change</param> public void SetBlock(BlockPos pos, Block block, bool updateChunk = true) { Chunk chunk = GetChunk(pos); if (chunk != null) { BlockPos localPos = pos - chunk.Position; chunk.SetBlock(localPos, block, updateChunk); if (updateChunk) { UpdateAdjacentChunks(pos); } } //else //Debug.LogError("No chunk at " + pos); }