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

81 lines
2.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
sidebarDepth: 1
---
# 属性
## GetBlockBasicInfo
<span style="display:inline;color:#ff5555">服务端</span>
method in mod.server.component.blockInfoCompServer.BlockInfoComponentServer
- 描述
获取方块基本信息
- 参数
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- | :--- |
| blockName | str | 方块identifier |
- 返回值
| <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- |
| dict | <a href="../../../../mcguide/20-玩法开发/10-基本概念/1-我的世界基础概念.html#方块基本信息字典#方块基本信息字典">方块基本信息字典</a> |
- 备注
- 基本信息字典中部分字段只在自定义方块时加上指定组件才会取到数据,具体见<a href="../../../../mcguide/20-玩法开发/10-基本概念/1-我的世界基础概念.html#方块基本信息字典#方块基本信息字典">方块基本信息字典</a>
- 示例
```python
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateBlockInfo(levelId)
blockDict = comp.GetBlockBasicInfo("minecraft:stone")
```
## SetBlockBasicInfo
<span style="display:inline;color:#ff5555">服务端</span>
method in mod.server.component.blockInfoCompServer.BlockInfoComponentServer
- 描述
设置方块基本信息
- 参数
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- | :--- |
| blockName | str | 方块identifier |
| infoDict | dict | 方块的<a href="../../../../mcguide/20-玩法开发/10-基本概念/1-我的世界基础概念.html#方块基本信息字典#方块基本信息字典">方块基本信息字典</a> |
| auxValue | int | 方块附加值默认是0 |
- 返回值
| <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- |
| bool | 设置是否成功 |
- 备注
- 目前本接口支持的属性有 destroyTime:硬度explosionResistance:爆炸抗性loot:掉落属性tier:挖掘属性solid:是否实心当方块json配置里有对应的组件才能修改
- 示例
```python
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}})
```