This commit is contained in:
boybook
2025-12-01 20:59:16 +08:00
parent 12738a142c
commit 760c2dd9ad
5535 changed files with 21070 additions and 2021 deletions

View File

@@ -297,6 +297,7 @@ method in mod.server.component.blockCompServer.BlockCompServer
- 备注
- 注意该pattern不限定方向只要能在任一平面上组合成功就能合成对应的实体。
- 如示例代码所示,不需要放方块的位置需要显式定义为空气方块
- 如示例代码所示,如果填了空格,表示该位置可以匹配任意方块
- 当引擎中已注册过相同的pattern和defines时该接口不会更新result_actor_name并返回False
- namespace:name:aux_value当aux_value不填或者填*时为通配如果有具体aux_value时只匹配特定方块
如'minecraft:wood'、'minecraft:wood:*'均通配木头,而'minecraft:wood:0'只匹配橡木。
@@ -318,6 +319,11 @@ defines ={
}
comp.RegisterBlockPatterns(pattern,defines,'minecraft:chicken')
#该例子左中右下放铁块,上面放金块,会生成一只鸡
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateBlock(playerId)
value = comp.RegisterBlockPatterns(['# #'],{'#': 'minecraft:iron_block'},'minecraft:cat')
#该例子中,玩家左右放俩铁块,无论中间是空气还是任意方块,均可生成一只猫
```

View File

@@ -19,6 +19,7 @@ sidebarDepth: 1
- [指令](#指令)
- [消息](#消息)
- [记分板](#记分板)
- [行为](#行为)
### 地图
@@ -328,3 +329,9 @@ sidebarDepth: 1
| [GetAllScoreboardObjects](记分板.md#getallscoreboardobjects) | <span style="display:inline;color:#ff5555">服务端</span> | 获取所有记分板项 |
| [GetAllScoreboardObjects](记分板.md#getallscoreboardobjects) | <span style="display:inline;color:#7575f9">客户端</span> | 获取所有记分板项 |
### 行为
| 接口 | <div style="width: 3em"></div> | 描述 |
| --- | --- | --- |
| [UseItemAttackEntity](行为.md#useitemattackentity) | <span style="display:inline;color:#ff5555">服务端</span> | 使用指定物品攻击某个实体。 |

View File

@@ -0,0 +1,56 @@
---
sidebarDepth: 1
---
# 行为
## UseItemAttackEntity
<span style="display:inline;color:#ff5555">服务端</span>
method in mod.server.component.gameCompServer.GameComponentServer
- 描述
使用指定物品攻击某个实体。
- 参数
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- | :--- |
| itemDict | dict | 物品字典数据 |
| entityId | str | 攻击实体id |
| cause | str | 伤害类型默认值是EntityAttack详见Minecraft枚举值文档的[ActorDamageCause](../../枚举值/ActorDamageCause.md) |
| attackerPos | tuple(float,float,float) | 伤害来源坐标默认值为None该参数会影响击退效果的计算 |
| knocked | bool | 是否击退默认值为False如果设置为True需同时设置attackerPos |
| customTag | str | 标识自定义伤害来源只在cause为Custom生效可在ActorHurtServerEvent、ActuallyHurtServerEvent、DamageEvent、PlayerHurtEvent、PlayerDieEvent、MobDieEvent监听到标识 |
- 返回值
| <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- |
| dict | 成功返回使用过后的物品字典失败返回None |
- 备注
- 无攻击力的物品,将会没有伤害。
- 有耐久的物品在攻击后,将会扣除部分耐久。
- 可通过DamageEvent等事件修改伤害值。
- 如果itemDict写入了不可添加到该物品的附魔该附魔效果将不会生效返回的itemDict也不会带有该附魔信息。如果有需求可考虑将附魔信息写入userData。
- 示例
```python
import mod.server.extraServerApi as serverApi
levelId = serverApi.GetLevelId()
comp = serverApi.GetEngineCompFactory().CreateGame(levelId)
itemDict = {
"newItemName": "minecraft:iron_sword",
"newAuxValue": 0,
"count": 1,
"durability": 256,
"enchantData": [(9,1)]
}
print(comp.UseItemAttackEntity(itemDict, entityId))
```