diff --git a/chicken.lua b/chicken.lua index e5d82c4..061f3ba 100644 --- a/chicken.lua +++ b/chicken.lua @@ -146,7 +146,7 @@ mobs:register_arrow("mobs_animal:egg_entity", { hit_node = function(self, pos, node) - if math.random(1, 10) > 1 then + if math.random(10) > 1 then return end @@ -160,28 +160,10 @@ mobs:register_arrow("mobs_animal:egg_entity", { return end - local mob = minetest.add_entity(pos, "mobs_animal:chicken") - local ent2 = mob:get_luaentity() + local staticdata = minetest.serialize( + {child = true, tamed = true, owner = self.playername}) - mob:set_properties({ - textures = ent2.child_texture[1], - visual_size = { - x = ent2.base_size.x / 2, - y = ent2.base_size.y / 2 - }, - collisionbox = { - ent2.base_colbox[1] / 2, - ent2.base_colbox[2] / 2, - ent2.base_colbox[3] / 2, - ent2.base_colbox[4] / 2, - ent2.base_colbox[5] / 2, - ent2.base_colbox[6] / 2 - }, - }) - - ent2.child = true - ent2.tamed = true - ent2.owner = self.playername + minetest.add_entity(pos, "mobs_animal:chicken", staticdata) end }) @@ -215,13 +197,13 @@ local mobs_shoot_egg = function (item, player, pointed_thing) ent.switch = 1 -- needed so that egg doesn't despawn straight away ent._is_arrow = true -- tell advanced mob protection this is an arrow - obj:setvelocity({ + obj:set_velocity({ x = dir.x * egg_VELOCITY, y = dir.y * egg_VELOCITY, z = dir.z * egg_VELOCITY }) - obj:setacceleration({ + obj:set_acceleration({ x = dir.x * -3, y = -egg_GRAVITY, z = dir.z * -3 @@ -229,6 +211,7 @@ local mobs_shoot_egg = function (item, player, pointed_thing) -- pass player name to egg for chick ownership local ent2 = obj:get_luaentity() + ent2.playername = player:get_player_name() item:take_item() diff --git a/textures/mobs_chicken_white.png b/textures/mobs_chicken_white.png new file mode 100644 index 0000000..87ab690 Binary files /dev/null and b/textures/mobs_chicken_white.png differ