diff --git a/cow.lua b/cow.lua index 5f9348a..a2ea9d7 100644 --- a/cow.lua +++ b/cow.lua @@ -49,20 +49,29 @@ mobs:register_mob("mobs_animal:cow", { punch_start = 70, punch_end = 100, }, - follow = "farming:wheat", + follow = {"farming:wheat", "default:grass_1"}, view_range = 8, replace_rate = 10, --- replace_what = {"default:grass_3", "default:grass_4", "default:grass_5", "farming:wheat_8"}, replace_what = { {"group:grass", "air", 0}, {"default:dirt_with_grass", "default:dirt", -1} }, - replace_with = "air", fear_height = 2, on_rightclick = function(self, clicker) -- feed or tame - if mobs:feed_tame(self, clicker, 8, true, true) then return end + if mobs:feed_tame(self, clicker, 8, true, true) then + + -- if fed 7x wheat or grass then cow can be milked again + if self.food > 6 then + + self.food = 0 + self.gotten = false + end + + return + end + if mobs:protect(self, clicker) then return end if mobs:capture_mob(self, clicker, 0, 5, 60, false, nil) then return end @@ -101,6 +110,16 @@ mobs:register_mob("mobs_animal:cow", { return end end, + on_replace = function(self, pos, oldnode, newnode) + + self.food = (self.food or 0) + 1 + + -- if cow replaces 8x grass then it can be milked again + if self.food >= 8 then + self.food = 0 + self.gotten = false + end + end, }) diff --git a/sheep.lua b/sheep.lua index 8df5107..535a07d 100644 --- a/sheep.lua +++ b/sheep.lua @@ -65,25 +65,40 @@ stepheight = 0.6, walk_start = 81, walk_end = 100, }, - follow = {"farming:wheat", "default:grass_5"}, + follow = {"farming:wheat", "default:grass_1"}, view_range = 8, replace_rate = 10, - replace_what = {"default:grass_3", "default:grass_4", "default:grass_5", "farming:wheat_8"}, - replace_with = "air", - replace_offset = -1, + replace_what = { + {"group:grass", "air", -1}, + {"default:dirt_with_grass", "default:dirt", -2} + }, fear_height = 3, ---[[ on_replace = function(self, pos, oldnode, newnode) - print ("---- replaced") ; return false -- false to keep node, true to replace + + self.food = (self.food or 0) + 1 + + -- if sheep replaces 8x grass then it regrows wool + if self.food >= 8 then + + self.food = 0 + self.gotten = false + + self.object:set_properties({ + textures = {"mobs_sheep_base.png^(mobs_sheep_wool.png^[colorize:" .. col[3] .. ")"}, + mesh = "mobs_sheep.b3d", + }) + end end, -]] on_rightclick = function(self, clicker) --are we feeding? if mobs:feed_tame(self, clicker, 8, true, true) then - --if full grow fuzz - if self.gotten == false then + --if fed 7x grass or wheat then sheep regrows wool + if self.food > 6 then + + self.food = 0 + self.gotten = false self.object:set_properties({ textures = {"mobs_sheep_base.png^(mobs_sheep_wool.png^[colorize:" .. col[3] .. ")"},