Fix mob egg double-spawns (#4657)

If you spawn a mob clicking on a wall, two mobs will be spawned.

To reproduce: face a stack of stones, with a spawn egg click on the side of a stone. It does not happen when you click the top of a node, because spawning below fails and only the second one succeeds.

Reviewed-on: VoxeLibre/VoxeLibre#4657
Reviewed-by: the-real-herowl <the-real-herowl@noreply.git.minetest.land>
Co-authored-by: kno10 <kno10@noreply.git.minetest.land>
Co-committed-by: kno10 <kno10@noreply.git.minetest.land>
This commit is contained in:
kno10 2024-09-30 19:21:40 +02:00 committed by the-real-herowl
parent dcfd31d17a
commit 253a06fa08
1 changed files with 1 additions and 1 deletions

View File

@ -615,7 +615,7 @@ function mcl_mobs.register_egg(mob_id, desc, background_color, overlay_color, ad
pos.y = pos.y - 1
local mob = mcl_mobs.spawn(pos, mob_name)
if not object then
if not mob then
pos.y = pos.y + 1
mob = mcl_mobs.spawn(pos, mob_name)
if not mob then return end