Files
netease-modsdk-wiki/docs/mcdocs/1-ModAPI/接口/方块/床.md
2025-03-17 13:24:39 +08:00

78 lines
1.8 KiB
Markdown

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