---
sidebarDepth: 1
---
# 床
## GetBedColor
服务端
method in mod.server.component.blockInfoCompServer.BlockInfoComponentServer
- 描述
获取床(方块)的颜色
- 参数
| 参数名 |
数据类型
| 说明 |
| :--- | :--- | :--- |
| pos | tuple(int,int,int) | 床的位置坐标(床占地两格,任意一个格子都可以) |
| dimensionId | int | 床所在维度 |
- 返回值
| 数据类型
| 说明 |
| :--- | :--- |
| int | [ItemColor枚举](../../枚举值/ItemColor.md) |
- 备注
- 当输入的坐标位置的方块不是床的时候,返回-1
- 示例
```python
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateBlockInfo(playerId)
pos = (-1, 4, 34)
dimensionId = 0
color = comp.GetBedColor(pos, dimensionId)
print "GetBedColor color={}".format(color)
```
## SetBedColor
服务端
method in mod.server.component.blockInfoCompServer.BlockInfoComponentServer
- 描述
设置床(方块)的颜色
- 参数
| 参数名 | 数据类型
| 说明 |
| :--- | :--- | :--- |
| pos | tuple(int,int,int) | 床的位置坐标(床占地两格,任意一个格子都可以) |
| color | int | [ItemColor枚举](../../枚举值/ItemColor.md) |
| dimensionId | int | 床所在维度 |
- 返回值
| 数据类型
| 说明 |
| :--- | :--- |
| bool | 是否设置成功 |
- 示例
```python
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateBlockInfo(playerId)
pos = (-1, 4, 34)
dimensionId = 0
suc = comp.SetBedColor(pos, serverApi.GetMinecraftEnum().ItemColor.Blue, dimensionId)
print "SetBedColor suc={}".format(suc)
```