From e246b5d0bba3489051351c692aee2b575a7d0311 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Thu, 31 May 2018 04:38:37 +0200 Subject: [PATCH] Fix breeding giving weird childs --- mods/ENTITIES/mobs/api.lua | 12 +++++++++--- mods/ENTITIES/mobs_mc/horse.lua | 11 ++++++++++- mods/ENTITIES/mobs_mc/sheep.lua | 16 ++++++++++++++++ 3 files changed, 35 insertions(+), 4 deletions(-) diff --git a/mods/ENTITIES/mobs/api.lua b/mods/ENTITIES/mobs/api.lua index 9cbfad4b8..95ef5d471 100644 --- a/mods/ENTITIES/mobs/api.lua +++ b/mods/ENTITIES/mobs/api.lua @@ -988,10 +988,16 @@ local breed = function(self) local ent_c = child:get_luaentity() - -- Use parent's texture - local textures = self.base_texture + + -- Use texture of one of the parents + local p = math.random(1, 2) + if p == 1 then + ent_c.base_texture = self.base_texture + else + ent_c.base_texture = ent.base_texture + end child:set_properties({ - textures = textures, + textures = ent_c.base_texture }) -- tamed and owned by parents' owner diff --git a/mods/ENTITIES/mobs_mc/horse.lua b/mods/ENTITIES/mobs_mc/horse.lua index 9aa5a1612..32f010c95 100644 --- a/mods/ENTITIES/mobs_mc/horse.lua +++ b/mods/ENTITIES/mobs_mc/horse.lua @@ -261,7 +261,16 @@ local horse = { on_breed = function(parent1, parent2) local pos = parent1.object:get_pos() - if mobs:spawn_child(pos, parent1.name) then + local child = mobs:spawn_child(pos, parent1.name) + if child then + local ent_c = child:get_luaentity() + local p = math.random(1, 2) + if p == 1 then + ent_c.base_texture = parent1.base_texture + else + ent_c.base_texture = parent2.base_texture + end + child:set_properties({textures = ent_c.base_texture}) return false end end, diff --git a/mods/ENTITIES/mobs_mc/sheep.lua b/mods/ENTITIES/mobs_mc/sheep.lua index 96734fd52..fa4197370 100644 --- a/mods/ENTITIES/mobs_mc/sheep.lua +++ b/mods/ENTITIES/mobs_mc/sheep.lua @@ -206,6 +206,22 @@ mobs:register_mob("mobs_mc:sheep", { end if mobs:capture_mob(self, clicker, 0, 5, 70, false, nil) then return end end, + on_breed = function(parent1, parent2) + local pos = parent1.object:get_pos() + local child = mobs:spawn_child(pos, parent1.name) + if child then + local ent_c = child:get_luaentity() + local p = math.random(1, 2) + if p == 1 then + ent_c.base_texture = sheep_texture(parent1.color) + else + ent_c.base_texture = sheep_texture(parent2.color) + end + child:set_properties({textures = ent_c.base_texture}) + ent_c.initial_color_set = true + return false + end + end, }) mobs:spawn_specific("mobs_mc:sheep", mobs_mc.spawn.grassland, {"air"}, 0, minetest.LIGHT_MAX+1, 30, 15000, 3, mobs_mc.spawn_height.overworld_min, mobs_mc.spawn_height.overworld_max)