Skip to content

Commit

Permalink
use attackEntityFrom method
Browse files Browse the repository at this point in the history
  • Loading branch information
friendlyhj committed Jan 7, 2023
1 parent 6b84097 commit 53dcb80
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion advanced/event-overview/basic-framework.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import crafttweaker.event.PlayerCraftedEvent //导入玩家合成事件的类
//使用events全局关键词调用事件管理器,并使用一个ZenMethod指定使用的事件,在函数头将事件匹配至PlayerCraftedEvent
events.onPlayerCrafted(function(event as PlayerCraftedEvent){
event.player.xp += 1; //玩家 +1 经验
event.player.attackEntityFrom(<damageSource:MAGIC>, 1.0f); // 玩家受到 1 点魔法伤害
});
```

Expand Down
6 changes: 3 additions & 3 deletions advanced/recipe-function-and-action/recipe-action.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ description: 配方事件也是有三个参数的函数,用来指定合成完
recipes.addShapeless("recipe_action_test", <minecraft:sapling>,
[<minecraft:stick>,<minecraft:leaves>],
function (out,ins,info) {
//生命值只有大于5才能合成,防止掉5点血后直接死亡
//生命值只有大于 5 才能合成,防止掉 5 点血后直接死亡
return info.player.health > 5 ? out : null;
},
function (out,info,player) { // 声明配方事件
//合成后玩家掉5点血
player.health -= 5;
//合成后玩家受到 5 点魔法伤害
player.attackEntityFrom(<damageSource:MAGIC>, 5.0f);
});
```

Expand Down

0 comments on commit 53dcb80

Please sign in to comment.