chicks from eggs cannot spawn inside node

This commit is contained in:
TenPlus1 2015-11-01 21:03:05 +00:00
parent e1b086e86a
commit db63c91fe3
2 changed files with 9 additions and 2 deletions

View File

@ -1,4 +1,4 @@
-- Mobs Api (30th October 2015)
-- Mobs Api (1st November 2015)
mobs = {}
mobs.mod = "redo"

View File

@ -93,9 +93,15 @@ mobs:register_arrow("mobs:egg_entity", {
hit_node = function(self, pos, node)
local num = math.random(1, 8)
local num = math.random(1, 10)
if num == 1 then
pos.y = pos.y + 1
local nod = minetest.get_node_or_nil(pos)
if not nod
or not minetest.registered_nodes[nod.name]
or minetest.registered_nodes[nod.name].walkable == true then
return
end
local mob = minetest.add_entity(pos, "mobs:chicken")
local ent2 = mob:get_luaentity()
mob:set_properties({
@ -150,6 +156,7 @@ local mobs_shoot_egg = function (item, player, pointed_thing)
y = -egg_GRAVITY,
z = dir.z * -3
})
-- pass player name to egg for chick ownership
local ent2 = obj:get_luaentity()
ent2.playername = player:get_player_name()
item:take_item()