206 lines
4.4 KiB
Markdown
206 lines
4.4 KiB
Markdown
---
|
||
sidebarDepth: 1
|
||
---
|
||
# 实体类型
|
||
|
||
## GetEngineType
|
||
|
||
<span style="display:inline;color:#ff5555">服务端</span><span style="display:inline;color:#7575f9">客户端</span>
|
||
|
||
### 服务端接口
|
||
|
||
<span id="s0"></span>
|
||
method in mod.server.component.engineTypeCompServer.EngineTypeComponentServer
|
||
|
||
- 描述
|
||
|
||
获取实体类型,主要用于判断实体是否属于某一类型的生物。
|
||
|
||
- 参数
|
||
|
||
无
|
||
|
||
- 返回值
|
||
|
||
| <div style="width: 4em">数据类型</div> | 说明 |
|
||
| :--- | :--- |
|
||
| int | 详见[EntityType枚举](../../枚举值/EntityType.md) |
|
||
|
||
- 示例
|
||
|
||
```python
|
||
import mod.server.extraServerApi as serverApi
|
||
from mod_log import logger as logger
|
||
comp = serverApi.GetEngineCompFactory().CreateEngineType(entityId)
|
||
entityType = comp.GetEngineType()
|
||
EntityTypeEnum = serverApi.GetMinecraftEnum().EntityType
|
||
# 判断是否是生物(Mob)
|
||
if entityType & EntityTypeEnum.Mob == EntityTypeEnum.Mob:
|
||
logger.info("{} is Mob".format(comp.GetEngineTypeStr()))
|
||
# 判断是否是弹射物(Projectile)
|
||
if entityType & EntityTypeEnum.Projectile == EntityTypeEnum.Projectile:
|
||
logger.info("{} is Projectile".format(comp.GetEngineTypeStr()))
|
||
```
|
||
|
||
|
||
|
||
### 客户端接口
|
||
|
||
<span id="c0"></span>
|
||
method in mod.client.component.engineTypeCompClient.EngineTypeComponentClient
|
||
|
||
- 描述
|
||
|
||
获取实体类型,主要用于判断实体是否属于某一类型的生物。
|
||
|
||
- 参数
|
||
|
||
无
|
||
|
||
- 返回值
|
||
|
||
| <div style="width: 4em">数据类型</div> | 说明 |
|
||
| :--- | :--- |
|
||
| int | 详见[EntityType枚举](../../枚举值/EntityType.md) |
|
||
|
||
- 示例
|
||
|
||
```python
|
||
import mod.client.extraClientApi as clientApi
|
||
from mod_log import logger as logger
|
||
comp = clientApi.GetEngineCompFactory().CreateEngineType(entityId)
|
||
entityType = comp.GetEngineType()
|
||
EntityTypeEnum = clientApi.GetMinecraftEnum().EntityType
|
||
# 判断是否是生物(Mob)
|
||
if entityType & EntityTypeEnum.Mob == EntityTypeEnum.Mob:
|
||
logger.info("{} is Mob".format(comp.GetEngineTypeStr()))
|
||
# 判断是否是弹射物(Projectile)
|
||
if entityType & EntityTypeEnum.Projectile == EntityTypeEnum.Projectile:
|
||
logger.info("{} is Projectile".format(comp.GetEngineTypeStr()))
|
||
```
|
||
|
||
|
||
|
||
## GetEngineTypeStr
|
||
|
||
<span style="display:inline;color:#ff5555">服务端</span><span style="display:inline;color:#7575f9">客户端</span>
|
||
|
||
### 服务端接口
|
||
|
||
<span id="s0"></span>
|
||
method in mod.server.component.engineTypeCompServer.EngineTypeComponentServer
|
||
|
||
- 描述
|
||
|
||
获取实体的类型名称
|
||
|
||
- 参数
|
||
|
||
无
|
||
|
||
- 返回值
|
||
|
||
| <div style="width: 4em">数据类型</div> | 说明 |
|
||
| :--- | :--- |
|
||
| str | 实体类型名称,如minecraft:husk |
|
||
|
||
- 示例
|
||
|
||
```python
|
||
import mod.server.extraServerApi as serverApi
|
||
comp = serverApi.GetEngineCompFactory().CreateEngineType(entityId)
|
||
comp.GetEngineTypeStr()
|
||
```
|
||
|
||
|
||
|
||
### 客户端接口
|
||
|
||
<span id="c0"></span>
|
||
method in mod.client.component.engineTypeCompClient.EngineTypeComponentClient
|
||
|
||
- 描述
|
||
|
||
获取实体的类型名称
|
||
|
||
- 参数
|
||
|
||
无
|
||
|
||
- 返回值
|
||
|
||
| <div style="width: 4em">数据类型</div> | 说明 |
|
||
| :--- | :--- |
|
||
| str | 实体类型名称,如minecraft:husk |
|
||
|
||
- 示例
|
||
|
||
```python
|
||
import mod.client.extraClientApi as clientApi
|
||
comp = clientApi.GetEngineCompFactory().CreateEngineType(entityId)
|
||
strType = comp.GetEngineTypeStr()
|
||
```
|
||
|
||
|
||
|
||
## GetEntityDefinitions
|
||
|
||
<span style="display:inline;color:#ff5555">服务端</span>
|
||
|
||
method in mod.server.component.entityDefinitionsCompServer.EntityDefinitionsCompServer
|
||
|
||
- 描述
|
||
|
||
获取实体的命名空间ID及其当前和之前的定义组件群
|
||
|
||
- 参数
|
||
|
||
无
|
||
|
||
- 返回值
|
||
|
||
| <div style="width: 4em">数据类型</div> | 说明 |
|
||
| :--- | :--- |
|
||
| list(str) | 实体的命名空间ID及其当前和之前的定义组件群的list |
|
||
|
||
- 示例
|
||
|
||
```python
|
||
import mod.server.extraServerApi as serverApi
|
||
comp = serverApi.GetEngineCompFactory().CreateEntityDefinitions(entityId)
|
||
result = comp.GetEntityDefinitions()
|
||
```
|
||
|
||
|
||
|
||
## GetEntityNBTTags
|
||
|
||
<span style="display:inline;color:#ff5555">服务端</span>
|
||
|
||
method in mod.server.component.entityDefinitionsCompServer.EntityDefinitionsCompServer
|
||
|
||
- 描述
|
||
|
||
获取实体的NBT标签
|
||
|
||
- 参数
|
||
|
||
无
|
||
|
||
- 返回值
|
||
|
||
| <div style="width: 4em">数据类型</div> | 说明 |
|
||
| :--- | :--- |
|
||
| dict或None | 实体NBT标签的dict |
|
||
|
||
- 示例
|
||
|
||
```python
|
||
import mod.server.extraServerApi as serverApi
|
||
comp = serverApi.GetEngineCompFactory().CreateEntityDefinitions(entityId)
|
||
result = comp.GetEntityNBTTags()
|
||
```
|
||
|
||
|
||
|