mirror of
https://codeberg.org/tenplus1/mobs_animal.git
synced 2025-07-26 20:10:21 +02:00
add on_replace functions to cow and sheep to replace milk and wool when eating
This commit is contained in:
27
cow.lua
27
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,
|
||||
})
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user