Files
netease-modsdk-wiki/docs/mcdocs/1-ModAPI/接口/方块/床.md
2025-03-18 14:46:12 +08:00

1.9 KiB

sidebarDepth
sidebarDepth
1

GetBedColor

服务端

method in mod.server.component.blockInfoCompServer.BlockInfoComponentServer

  • 描述

    获取床(方块)的颜色

  • 参数

    参数名
    数据类型
    说明
    pos tuple(int,int,int) 床的位置坐标(床占地两格,任意一个格子都可以)
    dimensionId int 床所在维度
  • 返回值

    数据类型
    说明
    int ItemColor枚举
  • 备注

    • 当输入的坐标位置的方块不是床的时候,返回-1
  • 示例

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枚举
    dimensionId int 床所在维度
  • 返回值

    数据类型
    说明
    bool 是否设置成功
  • 示例

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)