146 lines
3.2 KiB
Markdown
146 lines
3.2 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()
|
||
```
|
||
|
||
|
||
|