1 --License for code WTFPL and otherwise stated in readmes
4 local MP
= minetest
.get_modpath(minetest
.get_current_modname())
5 local S
, NS
= dofile(MP
.."/intllib.lua")
11 collisionbox
= {-0.45, -0.01, -0.45, 0.45, 1.39, 0.45},
13 mesh
= "mobs_mc_cow.b3d",
18 visual_size
= {x
=2.8, y
=2.8},
19 makes_footstep_sound
= true,
22 {name
= mobs_mc
.items
.beef_raw
,
26 {name
= mobs_mc
.items
.leather
,
36 random = "mobs_mc_cow",
37 damage
= "mobs_mc_cow_hurt",
38 death
= "mobs_mc_cow_hurt",
42 stand_speed
= 25, walk_speed
= 25, run_speed
= 50,
43 stand_start
= 0, stand_end
= 0,
44 walk_start
= 0, walk_end
= 40,
45 run_start
= 0, run_end
= 40,
47 follow
= mobs_mc
.follow
.cow
,
48 on_rightclick
= function(self
, clicker
)
49 if mobs
:feed_tame(self
, clicker
, 1, true, true) then return end
50 if mobs
:protect(self
, clicker
) then return end
56 local item
= clicker
:get_wielded_item()
57 if item
:get_name() == mobs_mc
.items
.bucket
and clicker
:get_inventory() then
58 local inv
= clicker
:get_inventory()
59 inv
:remove_item("main", mobs_mc
.items
.bucket
)
60 -- if room add bucket of milk to inventory, otherwise drop as item
61 if inv
:room_for_item("main", {name
=mobs_mc
.items
.milk
}) then
62 clicker
:get_inventory():add_item("main", mobs_mc
.items
.milk
)
64 local pos
= self
.object
:get_pos()
66 minetest
.add_item(pos
, {name
= mobs_mc
.items
.milk
})
70 mobs
:capture_mob(self
, clicker
, 0, 5, 60, false, nil)
72 follow
= mobs_mc
.items
.wheat
,
77 mobs
:register_mob("mobs_mc:cow", cow_def
)
80 local mooshroom_def
= table.copy(cow_def
)
82 mooshroom_def
.mesh
= "mobs_mc_cow.b3d"
83 mooshroom_def
.textures
= { {"mobs_mc_mooshroom.png", "mobs_mc_mushroom_red.png"}, }
84 mooshroom_def
.on_rightclick
= function(self
, clicker
)
85 if mobs
:feed_tame(self
, clicker
, 1, true, true) then return end
86 if mobs
:protect(self
, clicker
) then return end
91 local item
= clicker
:get_wielded_item()
92 -- Use shears to get mushrooms and turn mooshroom into cow
93 if item
:get_name() == mobs_mc
.items
.shears
then
94 local pos
= self
.object
:get_pos()
95 minetest
.sound_play("shears", {pos
= pos
})
96 minetest
.add_item({x
=pos
.x
, y
=pos
.y
+1.4, z
=pos
.z
}, mobs_mc
.items
.mushroom_red
.. " 5")
98 local oldyaw
= self
.object
:getyaw()
100 local cow
= minetest
.add_entity(pos
, "mobs_mc:cow")
103 if not minetest
.settings
:get_bool("creative_mode") then
104 item
:add_wear(mobs_mc
.misc
.shears_wear
)
105 clicker
:get_inventory():set_stack("main", clicker
:get_wield_index(), item
)
107 -- Use bucket to milk
108 elseif item
:get_name() == mobs_mc
.items
.bucket
and clicker
:get_inventory() then
109 local inv
= clicker
:get_inventory()
110 inv
:remove_item("main", mobs_mc
.items
.bucket
)
111 -- If room, add milk to inventory, otherwise drop as item
112 if inv
:room_for_item("main", {name
=mobs_mc
.items
.milk
}) then
113 clicker
:get_inventory():add_item("main", mobs_mc
.items
.milk
)
115 local pos
= self
.object
:get_pos()
117 minetest
.add_item(pos
, {name
= mobs_mc
.items
.milk
})
119 -- Use bowl to get mushroom stew
120 elseif item
:get_name() == mobs_mc
.items
.bowl
and clicker
:get_inventory() then
121 local inv
= clicker
:get_inventory()
122 inv
:remove_item("main", mobs_mc
.items
.bowl
)
123 -- If room, add mushroom stew to inventory, otherwise drop as item
124 if inv
:room_for_item("main", {name
=mobs_mc
.items
.mushroom_stew
}) then
125 clicker
:get_inventory():add_item("main", mobs_mc
.items
.mushroom_stew
)
127 local pos
= self
.object
:get_pos()
129 minetest
.add_item(pos
, {name
= mobs_mc
.items
.mushroom_stew
})
132 mobs
:capture_mob(self
, clicker
, 0, 5, 60, false, nil)
134 mobs
:register_mob("mobs_mc:mooshroom", mooshroom_def
)
138 mobs
:spawn_specific("mobs_mc:cow", mobs_mc
.spawn
.grassland
, {"air"}, 9, minetest
.LIGHT_MAX
+1, 30, 17000, 20, mobs_mc
.spawn_height
.overworld_min
, mobs_mc
.spawn_height
.overworld_max
)
139 mobs
:spawn_specific("mobs_mc:mooshroom", mobs_mc
.spawn
.mushroom_island
, {"air"}, 9, minetest
.LIGHT_MAX
+1, 30, 17000, 10, mobs_mc
.spawn_height
.overworld_min
, mobs_mc
.spawn_height
.overworld_max
)
142 mobs
:alias_mob("mobs_animal:cow", "mobs_mc:cow")
145 mobs
:register_egg("mobs_mc:cow", S("Cow"), "mobs_mc_spawn_icon_cow.png", 0)
146 mobs
:register_egg("mobs_mc:mooshroom", S("Mooshroom"), "mobs_mc_spawn_icon_mooshroom.png", 0)
148 if minetest
.settings
:get_bool("log_mods") then
149 minetest
.log("action", "MC Cow loaded")