From 5df8579e88fd4fa9b731cb5e044f021b893c3862 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Wed, 15 Feb 2017 00:31:00 +0100 Subject: [PATCH] Dispensers now support spawn eggs --- mods/mobs/api.lua | 8 +++++--- mods/redstone/mcl_dispensers/init.lua | 11 +++++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/mods/mobs/api.lua b/mods/mobs/api.lua index 67f60bc4..f7d3e478 100644 --- a/mods/mobs/api.lua +++ b/mods/mobs/api.lua @@ -2826,7 +2826,7 @@ function mobs:register_egg(mob, desc, background, addegg, no_creative) if pos and within_limits(pos, 0) - and not minetest.is_protected(pos, placer:get_player_name()) then + and (not placer or not minetest.is_protected(pos, placer:get_player_name())) then pos.y = pos.y + 1 @@ -2840,8 +2840,10 @@ function mobs:register_egg(mob, desc, background, addegg, no_creative) if ent.type ~= "monster" then -- set owner and tame if not monster - ent.owner = placer:get_player_name() - ent.tamed = true + if placer then + ent.owner = placer:get_player_name() + ent.tamed = true + end end -- if not in creative then take item diff --git a/mods/redstone/mcl_dispensers/init.lua b/mods/redstone/mcl_dispensers/init.lua index 90c99ea2..8d76e5f3 100644 --- a/mods/redstone/mcl_dispensers/init.lua +++ b/mods/redstone/mcl_dispensers/init.lua @@ -298,6 +298,17 @@ local dispenserdef = { end end + elseif igroups.spawn_egg then + -- Place spawn egg + if not dropnodedef.walkable then + pointed_thing = { above = droppos, under = { x=droppos.x, y=droppos.y-1, z=droppos.z } } + + minetest.registered_items[iname].on_place(ItemStack(iname), nil, pointed_thing) + + stack:take_item() + inv:set_stack("main", stack_id, stack) + end + -- TODO: Many other dispenser actions else -- Drop item