allow player animations hit by mobs

This commit is contained in:
epCode 2022-10-16 17:23:28 -07:00
parent b7eda10054
commit c3425a69b1
1 changed files with 15 additions and 7 deletions

View File

@ -128,8 +128,7 @@ mcl_enchanting.enchantments.fire_aspect = {
} }
minetest.register_on_punchplayer(function(player, hitter, time_from_last_punch, tool_capabilities, dir, damage) minetest.register_on_punchplayer(function(player, hitter, time_from_last_punch, tool_capabilities, dir, damage)
if hitter and hitter:is_player() then if hitter then
local wielditem = hitter:get_wielded_item()
local p = player:get_pos() local p = player:get_pos()
if time_from_last_punch > 0.5 then if time_from_last_punch > 0.5 then
local yy=0 local yy=0
@ -141,13 +140,22 @@ minetest.register_on_punchplayer(function(player, hitter, time_from_last_punch,
player:get_meta():set_string("punched", "0") player:get_meta():set_string("punched", "0")
end) end)
local d = hitter:get_look_dir() local d = vector.new()
if hitter:is_player() then
d = hitter:get_look_dir()
elseif hitter:get_luaentity() then
d = minetest.yaw_to_dir(hitter:get_yaw())
end
player:add_velocity({x=d.x*4,y=yy,z=d.z*4}) player:add_velocity({x=d.x*4,y=yy,z=d.z*4})
end end
if wielditem then
local fire_aspect_level = mcl_enchanting.get_enchantment(wielditem, "fire_aspect") if hitter:is_player() then
if fire_aspect_level > 0 then local wielditem = hitter:get_wielded_item()
mcl_burning.set_on_fire(player, fire_aspect_level * 4) if wielditem then
local fire_aspect_level = mcl_enchanting.get_enchantment(wielditem, "fire_aspect")
if fire_aspect_level > 0 then
mcl_burning.set_on_fire(player, fire_aspect_level * 4)
end
end end
end end
end end