fCraft.Map.SetBlock C# (CSharp) Method

SetBlock() public method

Sets a block at given coordinates. Checks bounds.
public SetBlock ( Vector3I coords, Block type ) : void
coords Vector3I Coordinate vector (X,Y,Z).
type Block Block type to set.
return void
        public void SetBlock( Vector3I coords, Block type )
        {
            if ( coords.X < Width && coords.Y < Length && coords.Z < Height && coords.X >= 0 && coords.Y >= 0 && coords.Z >= 0 && ( byte )type < 50 ) {
                Blocks[Index( coords )] = ( byte )type;
                HasChangedSinceSave = true;
            }
        }

Same methods

Map::SetBlock ( int x, int y, int z, Block type ) : void

Usage Example

Example #1
0
        internal static void GenerateFlatgrass(Map map, bool hollow)
        {
            for (int i = 0; i < map.widthX; i++)
            {
                for (int j = 0; j < map.widthY; j++)
                {
                    if (!hollow)
                    {
                        for (int k = 1; k < map.height / 2 - 1; k++)
                        {
                            if (k < map.height / 2 - 5)
                            {
                                map.SetBlock(i, j, k, Block.Stone);
                            }
                            else
                            {
                                map.SetBlock(i, j, k, Block.Dirt);
                            }
                        }
                    }
                    map.SetBlock(i, j, map.height / 2 - 1, Block.Grass);
                }
            }

            map.MakeFloodBarrier();
        }
All Usage Examples Of fCraft.Map::SetBlock