Optimisation and cleanup

-optimised and cleaned up wither rose withering effect code
-removed unused code
This commit is contained in:
the-real-herowl 2023-09-23 20:33:34 +02:00 committed by the-real-herowl
parent e4102e6124
commit 966712f4ff
4 changed files with 7 additions and 14 deletions

@ -681,6 +681,9 @@ function mob_class:do_env_damage()
-- don't fall when on ignore, just stand still
if self.standing_in == "ignore" then
self.object:set_velocity({x = 0, y = 0, z = 0})
-- wither rose effect
elseif self.standing_in == "mcl_flowers:wither_rose" then
mcl_potions.withering_func(self.object, 1, 2)
end
local nodef = minetest.registered_nodes[self.standing_in]

@ -161,7 +161,6 @@ mcl_mobs.register_mob("mobs_mc:wither", {
if self._custom_timer > 1 then
self.health = math.min(self.health + 1, self.hp_max)
self._custom_timer = self._custom_timer - 1
self._xplded_lately = false
end
if anti_troll and self._spawner then

@ -734,10 +734,6 @@ function mcl_potions.healing_func(player, hp)
local obj = player:get_luaentity()
if player:get_hp() == 0 then
return
end
if obj and obj.harmed_by_heal then hp = -hp end
if hp > 0 then

@ -474,21 +474,16 @@ mcl_mobs.effect_functions["heal"] = mcl_potions.healing_func
mcl_mobs.effect_functions["bad_omen"] = mcl_potions.bad_omen_func
mcl_mobs.effect_functions["withering"] = mcl_potions.withering_func
-- give withering when standing in wither rose
-- give withering to players in a wither rose
local etime = 0
minetest.register_globalstep(function(dtime)
etime = dtime + etime
if etime < 0.5 then return end
etime = 0
for _,pl in pairs(minetest.get_connected_players()) do
local n = minetest.find_node_near(pl:get_pos(),0.4,"mcl_flowers:wither_rose",true)
if n then mcl_potions.withering_func(pl, 1, 2) end
end
for _,ent in pairs(minetest.luaentities) do
if ent.object:get_pos() and ent.is_mob then
local n = minetest.find_node_near(ent.object:get_pos(),0.4,"mcl_flowers:wither_rose",true)
if n then mcl_potions.withering_func(ent.object, 1, 2) end
end
local npos = vector.offset(pl:get_pos(), 0, 0.2, 0)
local n = minetest.get_node(npos)
if n.name == "mcl_flowers:wither_rose" then mcl_potions.withering_func(pl, 1, 2) end
end
end)