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

184 lines
5.1 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>
- 历史原因,<a href="../../../../mcguide/20-玩法开发/10-基本概念/1-我的世界基础概念.html#方块基本信息字典#方块基本信息字典">方块基本信息字典</a>中的tier中的digger值类型为int。shovel(铲)为 0 pickaxe(镐)为 1 hatchet(斧)为 2 hoe(锄)为 3。
- 示例
```python
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateBlockInfo(levelId)
blockDict = comp.GetBlockBasicInfo("minecraft:stone")
```
## GetBlockTags
<span style="display:inline;color:#ff5555">服务端</span>
method in mod.server.component.blockInfoCompServer.BlockInfoComponentServer
- 描述
获取方块在tags:*中定义的tags列表
- 参数
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- | :--- |
| blockName | str | 方块identifierge |
- 返回值
| <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- |
| list(str) | 方块tags列表 |
- 示例
```python
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateBlockInfo(levelId)
comp.GetBlockTags("minecraft:stone")
```
## GetLoadBlocks
<span style="display:inline;color:#ff5555">服务端</span>
method in mod.server.component.blockInfoCompServer.BlockInfoComponentServer
- 描述
获取已经加载的方块id
- 参数
- 返回值
| <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- |
| List | 方块id列表 |
- 示例
```python
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateBlockInfo(levelId)
suc = comp.GetLoadBlocks()
```
## 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}})
```
## SetChestLootTable
<span style="display:inline;color:#ff5555">服务端</span>
method in mod.server.component.blockInfoCompServer.BlockInfoComponentServer
- 描述
设置箱子战利品表
- 参数
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- | :--- |
| blockPos | tuple(int,int,int) | 方块的坐标 |
| dimensionId | int | 方块所在的维度 |
| lootTable | str | 战利品表位置字符串,如"loot_tables/entities/zombie.json" |
| isIgnoreSpilt | bool | 是否屏蔽随机分堆默认为False |
- 返回值
| <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- |
| bool | 是否设置成功 |
- 备注
- 仅支持未打开过的箱子,若箱子已经打开过,则设置失败
- 维度需要已经加载。如有玩家在相应维度上,则算维度已加载,若完全没玩家在对应维度上,则维度未加载
- 末影箱仍是箱子的一种,但是末影箱本身并不直接存储物品。因此虽然设置战利品表返回成功,实际在打开末影箱时,并不会用到战利品表!
- 示例
```python
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateBlockInfo(levelId)
suc = comp.SetChestLootTable(blockPos, dimensionId, lootTable)
```