コード例 #1
0
        /// <summary>
        /// Gets the block type at the given world position.
        ///
        /// For ungenerated or unloaded chunks, the Ungenerated block type is return.
        /// </summary>
        /// <param name="blockPosition">The position of the block.</param>
        /// <param name="createChunk">Whether or not to create (or load) the chunk if it doesn't currently exist.</param>
        /// <returns>The block type.</returns>
        internal ushort GetBlock(BlockPosition blockPos, bool createChunk = false)
        {
            var chunkPos = blockPos.ToChunkPosition(World.ChunkSize);

            blockPos &= World.ChunkSize.Mask;

            return(GetChunk(chunkPos, createChunk)?.GetBlockID(blockPos) ?? 0);
        }
コード例 #2
0
        /// <summary>
        /// Sets the block at the given position.
        /// </summary>
        /// <param name="blockPos">The block position.</param>
        /// <param name="blockID">The block ID to assign.</param>
        internal void SetBlock(BlockPosition blockPos, ushort blockID)
        {
            var chunkPos = blockPos.ToChunkPosition(World.ChunkSize);

            blockPos &= World.ChunkSize.Mask;

            var chunk = GetChunk(chunkPos, true);

            if (chunk.GetBlockID(blockPos) == blockID)
            {
                return;
            }

            chunk.SetBlockID(blockPos, blockID);
            RemeshEffectedChunks(blockPos, chunkPos);
        }