From 1b1f6818865703e71c3d65dedc49e9df473471fa Mon Sep 17 00:00:00 2001 From: tenplus1 Date: Sun, 10 Nov 2024 11:41:32 +0000 Subject: [PATCH] tidy spawning --- api.lua | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/api.lua b/api.lua index 307987a..3f8f8a1 100644 --- a/api.lua +++ b/api.lua @@ -18,7 +18,7 @@ end mobs = { mod = "redo", - version = "20241028", + version = "20241110", spawning_mobs = {}, translate = S, invis = minetest.global_exists("invisibility") and invisibility or {}, @@ -4213,6 +4213,10 @@ function mobs:register_egg(mob, desc, background, addegg, no_creative) return end + -- get mob collisionbox and determine y_offset when spawning + local _prop = is_mob and is_mob.initial_properties or {} + local _y = _prop and -_prop.collisionbox[2] or 1 + -- register new spawn egg containing mob information (cannot be stacked) -- these are only created for animals and npc's, not monsters if is_mob.type ~= "monster" then @@ -4250,12 +4254,7 @@ function mobs:register_egg(mob, desc, background, addegg, no_creative) return end - -- get mob collisionbox and determine how high up to spawn - local _mob = minetest.registered_entities[mob] - local _prop = _mob and _mob.initial_properties or {} - local _y = _prop and -_prop.collisionbox[2] or 1 - - pos.y = pos.y + _y--1 + pos.y = pos.y + _y local data = itemstack:get_metadata() local smob = minetest.add_entity(pos, mob, data) @@ -4311,12 +4310,7 @@ function mobs:register_egg(mob, desc, background, addegg, no_creative) return end - -- get mob collisionbox and determine how high up to spawn - local _mob = minetest.registered_entities[mob] - local _prop = _mob and _mob.initial_properties or {} - local _y = _prop and -_prop.collisionbox[2] or 1 - - pos.y = pos.y + _y--1 + pos.y = pos.y + _y local smob = minetest.add_entity(pos, mob) local ent = smob and smob:get_luaentity()