VoxeLibre/mods/ENTITIES/mobs_mc/cow.lua

105 lines
2.1 KiB
Lua
Raw Normal View History

--MCmobs v0.2
--maikerumine
--made for MC like Survival game
--License for code WTFPL and otherwise stated in readmes
mobs:register_mob("mobs_mc:cow", {
type = "animal",
2017-01-20 21:24:56 +01:00
hp_min = 10,
2017-01-16 20:52:09 +01:00
hp_max = 10,
2017-02-23 17:19:06 +01:00
collisionbox = {-0.8, -0.01, -0.8, 0.8, 1.8, 0.8},
visual = "mesh",
mesh = "mobs_mc_cow.x",
textures = {
{"mobs_mc_cow.png"}
},
makes_footstep_sound = true,
walk_velocity = 1,
2017-01-16 20:52:09 +01:00
armor = 100,
drops = {
{name = "mcl_mobitems:beef",
chance = 1,
min = 1,
max = 3,},
2017-01-16 18:20:06 +01:00
{name = "mcl_mobitems:leather",
chance = 1,
min = 0,
max = 2,},
},
drawtype = "front",
water_damage = 1,
lava_damage = 5,
light_damage = 0,
fear_height = 3,
sounds = {
2017-02-23 17:04:43 +01:00
random = "mobs_mc_cow",
death = "Cowhurt1",
damage = "Cowhurt1",
},
animation = {
speed_normal = 24,
stand_start = 0,
stand_end = 23,
walk_start = 24,
walk_end = 49,
hurt_start = 118,
hurt_end = 154,
death_start = 154,
death_end = 179,
eat_start = 49,
eat_end = 78,
look_start = 78,
look_end = 108,
},
--from mobs_animals
follow = "mcl_farming:wheat_item",
view_range = 10,
fear_height = 2,
on_rightclick = function(self, clicker)
-- feed or tame
if mobs:feed_tame(self, clicker, 8, true, true) then
return
end
local tool = clicker:get_wielded_item()
-- milk cow with empty bucket
if tool:get_name() == "bucket:bucket_empty" then
if self.child == true then
return
end
local inv = clicker:get_inventory()
inv:remove_item("main", "bucket:bucket_empty")
2017-01-17 01:09:11 +01:00
if inv:room_for_item("main", {name = "mcl_mobitems:milk_bucket"}) then
clicker:get_inventory():add_item("main", "mcl_mobitems:milk_bucket")
else
local pos = self.object:getpos()
pos.y = pos.y + 0.5
2017-01-17 01:09:11 +01:00
minetest.add_item(pos, {name = "mcl_mobitems:milk_bucket"})
end
return
end
end,
})
2017-02-20 03:00:03 +01:00
mobs:register_spawn("mobs_mc:cow", {"group:solid"}, 20, 9, 7000, 1, 31000)
-- compatibility
mobs:alias_mob("mobs:cow", "mobs_mc:cow")
-- spawn egg
mobs:register_egg("mobs_mc:cow", "Spawn Cow", "spawn_egg_cow.png")
if minetest.setting_get("log_mods") then
minetest.log("action", "MC Cow loaded")
end