From 02679a02dfd279aee3919c307b0e827dd5e1da65 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Wed, 6 Sep 2017 21:42:37 +0200 Subject: [PATCH] Fix cactus not hurting player if above --- mods/PLAYER/mcl_playerplus/init.lua | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/mods/PLAYER/mcl_playerplus/init.lua b/mods/PLAYER/mcl_playerplus/init.lua index 1d4debbf5..f7db4faf4 100644 --- a/mods/PLAYER/mcl_playerplus/init.lua +++ b/mods/PLAYER/mcl_playerplus/init.lua @@ -134,21 +134,22 @@ minetest.register_globalstep(function(dtime) end end - -- am I near a cactus? + -- Am I near a cactus? local near = minetest.find_node_near(pos, 1, "mcl_core:cactus") - + if not near then + near = minetest.find_node_near({x=pos.x, y=pos.y-1, z=pos.z}, 1, "mcl_core:cactus") + end if near then - -- am I touching the cactus? if so it hurts - for _,object in pairs(minetest.get_objects_inside_radius(near, 1.1)) do - if object:get_hp() > 0 then - if object:is_player() then - mcl_death_messages.player_damage(object, string.format("%s was prickled by a cactus.", object:get_player_name())) - mcl_hunger.exhaust(object:get_player_name(), mcl_hunger.EXHAUST_DAMAGE) - end - object:set_hp(object:get_hp() - 1) + -- Am I touching the cactus? If so, it hurts + local dist = vector.distance(pos, near) + local dist_feet = vector.distance({x=pos.x, y=pos.y-1, z=pos.z}, near) + if dist < 1.1 or dist_feet < 1.1 then + if player:get_hp() > 0 then + mcl_death_messages.player_damage(player, string.format("%s was prickled by a cactus.", player:get_player_name())) + mcl_hunger.exhaust(player:get_player_name(), mcl_hunger.EXHAUST_DAMAGE) + player:set_hp(player:get_hp() - 1) end end - end -- Apply black sky in the Void and deal Void damage