From 53dcb80f272e7f18b1f71e3a6707465f59d1ae90 Mon Sep 17 00:00:00 2001 From: youyihj Date: Sat, 7 Jan 2023 22:06:34 +0800 Subject: [PATCH] use attackEntityFrom method --- advanced/event-overview/basic-framework.md | 2 +- advanced/recipe-function-and-action/recipe-action.md | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/advanced/event-overview/basic-framework.md b/advanced/event-overview/basic-framework.md index a50c8de..b91c270 100644 --- a/advanced/event-overview/basic-framework.md +++ b/advanced/event-overview/basic-framework.md @@ -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(, 1.0f); // 玩家受到 1 点魔法伤害 }); ``` diff --git a/advanced/recipe-function-and-action/recipe-action.md b/advanced/recipe-function-and-action/recipe-action.md index 7870cb6..139249a 100644 --- a/advanced/recipe-function-and-action/recipe-action.md +++ b/advanced/recipe-function-and-action/recipe-action.md @@ -18,12 +18,12 @@ description: 配方事件也是有三个参数的函数,用来指定合成完 recipes.addShapeless("recipe_action_test", , [,], 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(, 5.0f); }); ```