simplify baby chicken from egg (thanks MoNTE48)

This commit is contained in:
tenplus1 2021-10-27 13:43:16 +01:00
parent c2fa3e300c
commit 99ca850018
2 changed files with 7 additions and 24 deletions

View File

@ -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()

Binary file not shown.

After

Width:  |  Height:  |  Size: 103 B