Remove logging in tipped_arrows, prevent crash when spawning chicks, add extra safety check in vl_projectile.collides_with_solids

This commit is contained in:
teknomunk 2024-09-07 11:25:55 -05:00
parent 7bf6783f8e
commit 51c0750634
3 changed files with 5 additions and 7 deletions

View file

@ -54,8 +54,6 @@ function mcl_potions.register_arrow(name, desc, color, def)
local potency = self._potency or 0 local potency = self._potency or 0
local plus = self._plus or 0 local plus = self._plus or 0
minetest.log("tipped arrow collision")
if def._effect_list then if def._effect_list then
for name, details in pairs(def._effect_list) do for name, details in pairs(def._effect_list) do
local ef_level = details.level local ef_level = details.level
@ -75,7 +73,6 @@ function mcl_potions.register_arrow(name, desc, color, def)
if details.effect_stacks then if details.effect_stacks then
ef_level = ef_level + mcl_potions.get_effect_level(obj, name) ef_level = ef_level + mcl_potions.get_effect_level(obj, name)
end end
minetest.log("giving effect "..name)
mcl_potions.give_effect_by_level(name, obj, ef_level, dur) mcl_potions.give_effect_by_level(name, obj, ef_level, dur)
end end
end end

View file

@ -46,14 +46,14 @@ minetest.register_entity("mcl_throwing:egg_entity",{
-- FIXME: Chicks have a quite good chance to spawn in walls -- FIXME: Chicks have a quite good chance to spawn in walls
if math.random(1,8) ~= 1 then return end if math.random(1,8) ~= 1 then return end
mcl_mobs.spawn_child(self._lastpos, "mobs_mc:chicken") mcl_mobs.spawn_child(pos, "mobs_mc:chicken")
-- BONUS ROUND: 1/32 chance to spawn 3 additional chicks -- BONUS ROUND: 1/32 chance to spawn 3 additional chicks
if math.random(1,32) ~= 1 then return end if math.random(1,32) ~= 1 then return end
mcl_mobs.spawn_child(vector.offset(self._lastpos, 0.7, 0, 0), "mobs_mc:chicken") mcl_mobs.spawn_child(vector.offset(pos, 0.7, 0, 0 ), "mobs_mc:chicken")
mcl_mobs.spawn_child(vector.offset(self._lastpos, -0.7, 0, -0.7), "mobs_mc:chicken") mcl_mobs.spawn_child(vector.offset(pos, -0.7, 0, -0.7), "mobs_mc:chicken")
mcl_mobs.spawn_child(vector.offset(self._lastpos, -0.7, 0, 0.7), "mobs_mc:chicken") mcl_mobs.spawn_child(vector.offset(pos, -0.7, 0, 0.7), "mobs_mc:chicken")
end, end,
sounds = { sounds = {
on_collision = {"mcl_throwing_egg_impact", {max_hear_distance=10, gain=0.5}, true} on_collision = {"mcl_throwing_egg_impact", {max_hear_distance=10, gain=0.5}, true}

View file

@ -183,6 +183,7 @@ end
function mod.collides_with_solids(self, dtime, entity_def, projectile_def) function mod.collides_with_solids(self, dtime, entity_def, projectile_def)
local pos = self.object:get_pos() local pos = self.object:get_pos()
if not pos then return end
-- Don't try to do anything on first update -- Don't try to do anything on first update
if not self._last_pos then if not self._last_pos then