2016-05-19 19:24:06 -04:00
|
|
|
--License for code WTFPL and otherwise stated in readmes
|
|
|
|
|
2017-06-16 04:58:35 +02:00
|
|
|
local cow_def = {
|
2016-05-19 19:24:06 -04:00
|
|
|
type = "animal",
|
2017-06-14 19:47:33 -04:00
|
|
|
hp_min = 10,
|
|
|
|
hp_max = 10,
|
2017-06-16 02:08:12 +02:00
|
|
|
collisionbox = {-0.45, -0.01, -0.45, 0.45, 1.39, 0.45},
|
|
|
|
rotate = -180,
|
2016-05-19 19:24:06 -04:00
|
|
|
visual = "mesh",
|
2017-06-16 02:15:12 +02:00
|
|
|
mesh = "mobs_mc_cow.b3d",
|
2016-05-19 19:24:06 -04:00
|
|
|
textures = {
|
2017-06-16 02:15:12 +02:00
|
|
|
{"mobs_mc_cow.png"},
|
2016-05-19 19:24:06 -04:00
|
|
|
},
|
2017-06-16 02:08:12 +02:00
|
|
|
visual_size = {x=2.8, y=2.8},
|
2016-05-19 19:24:06 -04:00
|
|
|
makes_footstep_sound = true,
|
|
|
|
walk_velocity = 1,
|
|
|
|
drops = {
|
2017-06-16 02:08:12 +02:00
|
|
|
{name = "mobs_mc:beef_raw",
|
2016-05-19 19:24:06 -04:00
|
|
|
chance = 1,
|
|
|
|
min = 1,
|
|
|
|
max = 3,},
|
|
|
|
{name = "mobs:leather",
|
|
|
|
chance = 1,
|
|
|
|
min = 0,
|
|
|
|
max = 2,},
|
|
|
|
},
|
|
|
|
drawtype = "front",
|
|
|
|
water_damage = 1,
|
|
|
|
lava_damage = 5,
|
|
|
|
light_damage = 0,
|
|
|
|
fear_height = 3,
|
2017-06-16 02:08:12 +02:00
|
|
|
runaway = true,
|
2016-05-19 19:24:06 -04:00
|
|
|
sounds = {
|
|
|
|
random = "Cow1",
|
|
|
|
death = "Cowhurt1",
|
|
|
|
damage = "Cowhurt1",
|
|
|
|
},
|
|
|
|
animation = {
|
2017-05-23 19:03:37 -04:00
|
|
|
speed_normal = 25, speed_run = 50,
|
|
|
|
stand_start = 0, stand_end = 0,
|
|
|
|
walk_start = 0, walk_end = 40,
|
|
|
|
run_start = 0, run_end = 40,
|
2016-05-19 19:24:06 -04:00
|
|
|
},
|
|
|
|
follow = "farming:wheat",
|
|
|
|
on_rightclick = function(self, clicker)
|
2017-06-16 04:58:35 +02:00
|
|
|
if self.child then
|
|
|
|
return
|
|
|
|
end
|
2016-05-19 19:24:06 -04:00
|
|
|
local item = clicker:get_wielded_item()
|
|
|
|
if item:get_name() == "bucket:bucket_empty" and clicker:get_inventory() then
|
|
|
|
local inv = clicker:get_inventory()
|
|
|
|
inv:remove_item("main", "bucket:bucket_empty")
|
|
|
|
-- if room add bucket of milk to inventory, otherwise drop as item
|
2017-06-16 02:08:12 +02:00
|
|
|
if inv:room_for_item("main", {name="mobs_mc:milk_bucket"}) then
|
|
|
|
clicker:get_inventory():add_item("main", "mobs_mc:milk_bucket")
|
2016-05-19 19:24:06 -04:00
|
|
|
else
|
|
|
|
local pos = self.object:getpos()
|
|
|
|
pos.y = pos.y + 0.5
|
2017-06-16 02:08:12 +02:00
|
|
|
minetest.add_item(pos, {name = "mobs_mc:milk_bucket"})
|
2016-05-19 19:24:06 -04:00
|
|
|
end
|
|
|
|
end
|
2017-06-16 02:08:12 +02:00
|
|
|
mobs:capture_mob(self, clicker, 0, 5, 60, false, nil)
|
2016-05-19 19:24:06 -04:00
|
|
|
end,
|
2016-05-26 21:29:06 -04:00
|
|
|
follow = "farming:wheat",
|
2017-06-16 02:08:12 +02:00
|
|
|
view_range = 10,
|
2016-05-26 21:29:06 -04:00
|
|
|
fear_height = 2,
|
2017-06-16 04:58:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
mobs:register_mob("mobs_mc:cow", cow_def)
|
|
|
|
|
|
|
|
-- Mooshroom
|
|
|
|
local mooshroom_def = table.copy(cow_def)
|
|
|
|
|
2017-06-16 05:00:54 +02:00
|
|
|
mooshroom_def.mesh = "mobs_mc_mooshroom.b3d"
|
2017-06-16 05:02:27 +02:00
|
|
|
mooshroom_def.textures = { {"mobs_mc_mooshroom.png"}, }
|
2017-06-16 04:58:35 +02:00
|
|
|
mooshroom_def.on_rightclick = function(self, clicker)
|
|
|
|
if self.child then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
local item = clicker:get_wielded_item()
|
|
|
|
-- Use shears to get mushrooms and turn mooshroom into cow
|
|
|
|
if item:get_name() == "mobs:shears" then
|
|
|
|
local pos = self.object:getpos()
|
|
|
|
minetest.sound_play("shears", {pos = pos})
|
|
|
|
minetest.add_item({x=pos.x, y=pos.y+1.4, z=pos.z}, "flowers:mushroom_red 5")
|
|
|
|
|
|
|
|
local oldyaw = self.object:getyaw()
|
|
|
|
self.object:remove()
|
|
|
|
local cow = minetest.add_entity(pos, "mobs_mc:cow")
|
|
|
|
cow:setyaw(oldyaw)
|
|
|
|
|
|
|
|
if not minetest.setting_getbool("creative_mode") then
|
|
|
|
item:add_wear(300)
|
|
|
|
clicker:get_inventory():set_stack("main", clicker:get_wield_index(), item)
|
|
|
|
end
|
|
|
|
-- Use bucket to milk
|
|
|
|
elseif item:get_name() == "bucket:bucket_empty" and clicker:get_inventory() then
|
|
|
|
local inv = clicker:get_inventory()
|
|
|
|
inv:remove_item("main", "bucket:bucket_empty")
|
|
|
|
-- If room, add milk to inventory, otherwise drop as item
|
|
|
|
if inv:room_for_item("main", {name="mobs_mc:milk_bucket"}) then
|
|
|
|
clicker:get_inventory():add_item("main", "mobs_mc:milk_bucket")
|
|
|
|
else
|
|
|
|
local pos = self.object:getpos()
|
|
|
|
pos.y = pos.y + 0.5
|
|
|
|
minetest.add_item(pos, {name = "mobs_mc:milk_bucket"})
|
|
|
|
end
|
2017-06-16 13:32:42 +02:00
|
|
|
-- Use bowl to get mushroom stew
|
|
|
|
elseif item:get_name() == "mobs_mc:bowl" and clicker:get_inventory() then
|
2017-06-16 04:58:35 +02:00
|
|
|
local inv = clicker:get_inventory()
|
2017-06-16 13:32:42 +02:00
|
|
|
inv:remove_item("main", "mobs_mc:bowl")
|
2017-06-16 04:58:35 +02:00
|
|
|
-- If room, add mushroom stew to inventory, otherwise drop as item
|
|
|
|
if inv:room_for_item("main", {name="mobs_mc:mushroom_stew"}) then
|
|
|
|
clicker:get_inventory():add_item("main", "mobs_mc:mushroom_stew")
|
|
|
|
else
|
|
|
|
local pos = self.object:getpos()
|
|
|
|
pos.y = pos.y + 0.5
|
|
|
|
minetest.add_item(pos, {name = "mobs_mc:mushroom_stew"})
|
|
|
|
end
|
|
|
|
end
|
|
|
|
mobs:capture_mob(self, clicker, 0, 5, 60, false, nil)
|
|
|
|
end
|
|
|
|
mobs:register_mob("mobs_mc:mooshroom", mooshroom_def)
|
|
|
|
|
2016-05-26 21:29:06 -04:00
|
|
|
|
2017-06-16 04:58:35 +02:00
|
|
|
-- Spawning
|
2017-05-28 23:16:44 -04:00
|
|
|
mobs:register_spawn("mobs_mc:cow", {"default:dirt_with_grass"}, 20, 8, 17000, 2, 31000)
|
2017-06-16 04:58:35 +02:00
|
|
|
mobs:register_spawn("mobs_mc:mooshroom", {"default:mycelium_snow", "default:mycelium"}, 20, 8, 7000, 1, 31000)
|
2016-05-19 19:24:06 -04:00
|
|
|
|
|
|
|
|
|
|
|
-- compatibility
|
2017-05-23 19:03:37 -04:00
|
|
|
mobs:alias_mob("mobs_animal:cow", "mobs_mc:cow")
|
2016-05-19 19:24:06 -04:00
|
|
|
|
2017-05-23 19:03:37 -04:00
|
|
|
-- spawn egg
|
2017-06-16 02:15:12 +02:00
|
|
|
mobs:register_egg("mobs_mc:cow", "Cow", "mobs_mc_spawn_icon_cow.png", 0)
|
2017-06-16 05:00:54 +02:00
|
|
|
mobs:register_egg("mobs_mc:mooshroom", "Mooshroom", "mobs_mc_spawn_icon_mooshroom.png", 0)
|
2016-05-19 19:24:06 -04:00
|
|
|
|
|
|
|
if minetest.setting_get("log_mods") then
|
|
|
|
minetest.log("action", "MC Cow loaded")
|
2017-06-14 19:47:33 -04:00
|
|
|
end
|