forked from mtcontrib/mobs_animal
simplify baby chicken from egg (thanks MoNTE48)
This commit is contained in:
parent
c2fa3e300c
commit
99ca850018
31
chicken.lua
31
chicken.lua
@ -146,7 +146,7 @@ mobs:register_arrow("mobs_animal:egg_entity", {
|
|||||||
|
|
||||||
hit_node = function(self, pos, node)
|
hit_node = function(self, pos, node)
|
||||||
|
|
||||||
if math.random(1, 10) > 1 then
|
if math.random(10) > 1 then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -160,28 +160,10 @@ mobs:register_arrow("mobs_animal:egg_entity", {
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local mob = minetest.add_entity(pos, "mobs_animal:chicken")
|
local staticdata = minetest.serialize(
|
||||||
local ent2 = mob:get_luaentity()
|
{child = true, tamed = true, owner = self.playername})
|
||||||
|
|
||||||
mob:set_properties({
|
minetest.add_entity(pos, "mobs_animal:chicken", staticdata)
|
||||||
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
|
|
||||||
end
|
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.switch = 1 -- needed so that egg doesn't despawn straight away
|
||||||
ent._is_arrow = true -- tell advanced mob protection this is an arrow
|
ent._is_arrow = true -- tell advanced mob protection this is an arrow
|
||||||
|
|
||||||
obj:setvelocity({
|
obj:set_velocity({
|
||||||
x = dir.x * egg_VELOCITY,
|
x = dir.x * egg_VELOCITY,
|
||||||
y = dir.y * egg_VELOCITY,
|
y = dir.y * egg_VELOCITY,
|
||||||
z = dir.z * egg_VELOCITY
|
z = dir.z * egg_VELOCITY
|
||||||
})
|
})
|
||||||
|
|
||||||
obj:setacceleration({
|
obj:set_acceleration({
|
||||||
x = dir.x * -3,
|
x = dir.x * -3,
|
||||||
y = -egg_GRAVITY,
|
y = -egg_GRAVITY,
|
||||||
z = dir.z * -3
|
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
|
-- pass player name to egg for chick ownership
|
||||||
local ent2 = obj:get_luaentity()
|
local ent2 = obj:get_luaentity()
|
||||||
|
|
||||||
ent2.playername = player:get_player_name()
|
ent2.playername = player:get_player_name()
|
||||||
|
|
||||||
item:take_item()
|
item:take_item()
|
||||||
|
BIN
textures/mobs_chicken_white.png
Normal file
BIN
textures/mobs_chicken_white.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 103 B |
Loading…
Reference in New Issue
Block a user