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

2.3 KiB
Raw Blame History

sidebarDepth
sidebarDepth
1

属性

GetBlockBasicInfo

服务端

method in mod.server.component.blockInfoCompServer.BlockInfoComponentServer

  • 描述

    获取方块基本信息

  • 参数

    参数名
    数据类型
    说明
    blockName str 方块identifier
  • 返回值

    数据类型
    说明
    dict 方块基本信息字典
  • 备注

    • 基本信息字典中部分字段只在自定义方块时加上指定组件才会取到数据,具体见方块基本信息字典
  • 示例

import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateBlockInfo(levelId)
blockDict = comp.GetBlockBasicInfo("minecraft:stone")

SetBlockBasicInfo

服务端

method in mod.server.component.blockInfoCompServer.BlockInfoComponentServer

  • 描述

    设置方块基本信息

  • 参数

    参数名
    数据类型
    说明
    blockName str 方块identifier
    infoDict dict 方块的方块基本信息字典
    auxValue int 方块附加值默认是0
  • 返回值

    数据类型
    说明
    bool 设置是否成功
  • 备注

    • 目前本接口支持的属性有 destroyTime:硬度explosionResistance:爆炸抗性loot:掉落属性tier:挖掘属性solid:是否实心当方块json配置里有对应的组件才能修改
  • 示例

import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateBlockInfo(levelId)
blockDict = comp.SetBlockBasicInfo("minecraft:stone", {"blockLightEmission":1,
"blockLightAbsorption":1,
"solid":False,
"tier":{"level":3}})