2017-07-05 03:15:46 +02:00
|
|
|
--License for code WTFPL and otherwise stated in readmes
|
|
|
|
|
2022-02-13 21:40:12 +01:00
|
|
|
local S = minetest.get_translator("mobs_mc")
|
2017-07-05 03:15:46 +02:00
|
|
|
|
|
|
|
local cow_def = {
|
2021-04-25 17:30:15 +02:00
|
|
|
description = S("Cow"),
|
2017-07-05 03:15:46 +02:00
|
|
|
type = "animal",
|
2020-04-11 02:46:03 +02:00
|
|
|
spawn_class = "passive",
|
2017-07-05 03:15:46 +02:00
|
|
|
hp_min = 10,
|
|
|
|
hp_max = 10,
|
2020-12-06 15:46:42 +01:00
|
|
|
xp_min = 1,
|
|
|
|
xp_max = 3,
|
2017-07-05 03:15:46 +02:00
|
|
|
collisionbox = {-0.45, -0.01, -0.45, 0.45, 1.39, 0.45},
|
|
|
|
visual = "mesh",
|
|
|
|
mesh = "mobs_mc_cow.b3d",
|
2017-09-13 23:13:47 +02:00
|
|
|
textures = { {
|
|
|
|
"mobs_mc_cow.png",
|
|
|
|
"blank.png",
|
|
|
|
}, },
|
2017-07-05 03:15:46 +02:00
|
|
|
visual_size = {x=2.8, y=2.8},
|
|
|
|
makes_footstep_sound = true,
|
|
|
|
walk_velocity = 1,
|
|
|
|
drops = {
|
2022-05-25 23:25:15 +02:00
|
|
|
{name = "mcl_mobitems:beef",
|
2017-07-05 03:15:46 +02:00
|
|
|
chance = 1,
|
|
|
|
min = 1,
|
2020-12-23 17:41:42 +01:00
|
|
|
max = 3,
|
|
|
|
looting = "common",},
|
2022-05-25 23:25:15 +02:00
|
|
|
{name = "mcl_mobitems:leather",
|
2017-07-05 03:15:46 +02:00
|
|
|
chance = 1,
|
|
|
|
min = 0,
|
2020-12-23 17:41:42 +01:00
|
|
|
max = 2,
|
|
|
|
looting = "common",},
|
2017-07-05 03:15:46 +02:00
|
|
|
},
|
2022-02-13 21:40:12 +01:00
|
|
|
runaway = true,
|
2017-07-05 03:15:46 +02:00
|
|
|
sounds = {
|
|
|
|
random = "mobs_mc_cow",
|
2018-09-14 17:37:24 +02:00
|
|
|
damage = "mobs_mc_cow_hurt",
|
|
|
|
death = "mobs_mc_cow_hurt",
|
2020-12-05 23:37:12 +01:00
|
|
|
eat = "mobs_mc_animal_eat_generic",
|
2017-07-05 03:15:46 +02:00
|
|
|
distance = 16,
|
|
|
|
},
|
|
|
|
animation = {
|
2020-08-03 15:37:58 +02:00
|
|
|
stand_speed = 25, walk_speed = 40,
|
|
|
|
run_speed = 60, stand_start = 0,
|
|
|
|
stand_end = 0, walk_start = 0,
|
2021-04-25 17:30:15 +02:00
|
|
|
walk_end = 40, run_start = 0,
|
2020-08-03 15:37:58 +02:00
|
|
|
run_end = 40,
|
2017-07-05 03:15:46 +02:00
|
|
|
},
|
|
|
|
on_rightclick = function(self, clicker)
|
2022-05-25 14:44:49 +02:00
|
|
|
if mcl_mobs:feed_tame(self, clicker, 1, true, true) then return end
|
|
|
|
if mcl_mobs:protect(self, clicker) then return end
|
2017-07-05 03:15:46 +02:00
|
|
|
|
2022-02-13 21:40:12 +01:00
|
|
|
if self.child then
|
2017-07-05 03:15:46 +02:00
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
local item = clicker:get_wielded_item()
|
2022-05-25 23:25:15 +02:00
|
|
|
if item:get_name() == "mcl_buckets:bucket_empty" and clicker:get_inventory() then
|
2017-07-05 03:15:46 +02:00
|
|
|
local inv = clicker:get_inventory()
|
2022-05-25 23:25:15 +02:00
|
|
|
inv:remove_item("main", "mcl_buckets:bucket_empty")
|
2020-12-05 19:17:15 +01:00
|
|
|
minetest.sound_play("mobs_mc_cow_milk", {pos=self.object:get_pos(), gain=0.6})
|
2017-07-05 03:15:46 +02:00
|
|
|
-- if room add bucket of milk to inventory, otherwise drop as item
|
2022-05-25 23:25:15 +02:00
|
|
|
if inv:room_for_item("main", {name = "mcl_mobitems:milk_bucket"}) then
|
|
|
|
clicker:get_inventory():add_item("main", "mcl_mobitems:milk_bucket")
|
2017-07-05 03:15:46 +02:00
|
|
|
else
|
2019-02-01 06:33:07 +01:00
|
|
|
local pos = self.object:get_pos()
|
2017-07-05 03:15:46 +02:00
|
|
|
pos.y = pos.y + 0.5
|
2022-05-25 23:25:15 +02:00
|
|
|
minetest.add_item(pos, {name = "mcl_mobitems:milk_bucket"})
|
2017-07-05 03:15:46 +02:00
|
|
|
end
|
|
|
|
return
|
|
|
|
end
|
2022-05-25 14:44:49 +02:00
|
|
|
mcl_mobs:capture_mob(self, clicker, 0, 5, 60, false, nil)
|
2017-07-05 03:15:46 +02:00
|
|
|
end,
|
2022-05-25 23:25:15 +02:00
|
|
|
follow = "mcl_farming:wheat_item",
|
2017-07-05 03:15:46 +02:00
|
|
|
view_range = 10,
|
|
|
|
fear_height = 4,
|
|
|
|
}
|
|
|
|
|
2022-05-25 14:44:49 +02:00
|
|
|
mcl_mobs:register_mob("mobs_mc:cow", cow_def)
|
2017-07-05 03:15:46 +02:00
|
|
|
|
|
|
|
-- Mooshroom
|
|
|
|
local mooshroom_def = table.copy(cow_def)
|
2021-04-25 17:30:15 +02:00
|
|
|
mooshroom_def.description = S("Mooshroom")
|
2017-07-05 03:15:46 +02:00
|
|
|
mooshroom_def.mesh = "mobs_mc_cow.b3d"
|
2022-07-17 02:20:51 +02:00
|
|
|
mooshroom_def.spawn_in_group_min = 4
|
|
|
|
mooshroom_def.spawn_in_group = 8
|
2019-02-21 02:37:13 +01:00
|
|
|
mooshroom_def.textures = { {"mobs_mc_mooshroom.png", "mobs_mc_mushroom_red.png"}, {"mobs_mc_mooshroom_brown.png", "mobs_mc_mushroom_brown.png" } }
|
2017-07-05 03:15:46 +02:00
|
|
|
mooshroom_def.on_rightclick = function(self, clicker)
|
2022-05-25 14:44:49 +02:00
|
|
|
if mcl_mobs:feed_tame(self, clicker, 1, true, true) then return end
|
|
|
|
if mcl_mobs:protect(self, clicker) then return end
|
2017-07-05 03:15:46 +02:00
|
|
|
|
2022-02-13 21:40:12 +01:00
|
|
|
if self.child then
|
2017-07-05 03:15:46 +02:00
|
|
|
return
|
|
|
|
end
|
|
|
|
local item = clicker:get_wielded_item()
|
|
|
|
-- Use shears to get mushrooms and turn mooshroom into cow
|
2022-05-25 23:25:15 +02:00
|
|
|
if item:get_name() == "mcl_tools:shears" then
|
2019-02-01 06:33:07 +01:00
|
|
|
local pos = self.object:get_pos()
|
2020-12-06 01:21:02 +01:00
|
|
|
minetest.sound_play("mcl_tools_shears_cut", {pos = pos}, true)
|
2019-02-21 02:37:13 +01:00
|
|
|
|
|
|
|
if self.base_texture[1] == "mobs_mc_mooshroom_brown.png" then
|
2022-05-25 23:25:15 +02:00
|
|
|
minetest.add_item({x=pos.x, y=pos.y+1.4, z=pos.z}, "mcl_mushrooms:mushroom_brown 5")
|
2019-02-21 02:37:13 +01:00
|
|
|
else
|
2022-05-25 23:25:15 +02:00
|
|
|
minetest.add_item({x=pos.x, y=pos.y+1.4, z=pos.z}, "mcl_mushrooms:mushroom_red 5")
|
2019-02-21 02:37:13 +01:00
|
|
|
end
|
2017-07-05 03:15:46 +02:00
|
|
|
|
2019-03-06 04:38:57 +01:00
|
|
|
local oldyaw = self.object:get_yaw()
|
2017-07-05 03:15:46 +02:00
|
|
|
self.object:remove()
|
|
|
|
local cow = minetest.add_entity(pos, "mobs_mc:cow")
|
2019-03-06 04:38:57 +01:00
|
|
|
cow:set_yaw(oldyaw)
|
2017-07-05 03:15:46 +02:00
|
|
|
|
2020-07-10 16:08:40 +02:00
|
|
|
if not minetest.is_creative_enabled(clicker:get_player_name()) then
|
2022-05-25 23:25:15 +02:00
|
|
|
item:add_wear(mobs_mc.shears_wear)
|
2017-07-05 03:15:46 +02:00
|
|
|
clicker:get_inventory():set_stack("main", clicker:get_wield_index(), item)
|
|
|
|
end
|
|
|
|
-- Use bucket to milk
|
2022-05-25 23:25:15 +02:00
|
|
|
elseif item:get_name() == "mcl_buckets:bucket_empty" and clicker:get_inventory() then
|
2017-07-05 03:15:46 +02:00
|
|
|
local inv = clicker:get_inventory()
|
2022-05-25 23:25:15 +02:00
|
|
|
inv:remove_item("main", "mcl_buckets:bucket_empty")
|
2020-12-05 19:17:15 +01:00
|
|
|
minetest.sound_play("mobs_mc_cow_milk", {pos=self.object:get_pos(), gain=0.6})
|
2017-07-05 03:15:46 +02:00
|
|
|
-- If room, add milk to inventory, otherwise drop as item
|
2022-05-25 23:25:15 +02:00
|
|
|
if inv:room_for_item("main", {name="mcl_mobitems:milk_bucket"}) then
|
|
|
|
clicker:get_inventory():add_item("main", "mcl_mobitems:milk_bucket")
|
2017-07-05 03:15:46 +02:00
|
|
|
else
|
2019-02-01 06:33:07 +01:00
|
|
|
local pos = self.object:get_pos()
|
2017-07-05 03:15:46 +02:00
|
|
|
pos.y = pos.y + 0.5
|
2022-05-25 23:25:15 +02:00
|
|
|
minetest.add_item(pos, {name = "mcl_mobitems:milk_bucket"})
|
2017-07-05 03:15:46 +02:00
|
|
|
end
|
|
|
|
-- Use bowl to get mushroom stew
|
2022-05-25 23:25:15 +02:00
|
|
|
elseif item:get_name() == "mcl_core:bowl" and clicker:get_inventory() then
|
2017-07-05 03:15:46 +02:00
|
|
|
local inv = clicker:get_inventory()
|
2022-05-25 23:25:15 +02:00
|
|
|
inv:remove_item("main", "mcl_core:bowl")
|
2020-12-05 19:17:15 +01:00
|
|
|
minetest.sound_play("mobs_mc_cow_mushroom_stew", {pos=self.object:get_pos(), gain=0.6})
|
2017-07-05 03:15:46 +02:00
|
|
|
-- If room, add mushroom stew to inventory, otherwise drop as item
|
2022-05-25 23:25:15 +02:00
|
|
|
if inv:room_for_item("main", {name="mcl_mushrooms:mushroom_stew"}) then
|
|
|
|
clicker:get_inventory():add_item("main", "mcl_mushrooms:mushroom_stew")
|
2017-07-05 03:15:46 +02:00
|
|
|
else
|
2019-02-01 06:33:07 +01:00
|
|
|
local pos = self.object:get_pos()
|
2017-07-05 03:15:46 +02:00
|
|
|
pos.y = pos.y + 0.5
|
2022-05-25 23:25:15 +02:00
|
|
|
minetest.add_item(pos, {name = "mcl_mushrooms:mushroom_stew"})
|
2017-07-05 03:15:46 +02:00
|
|
|
end
|
2021-05-23 15:10:20 +02:00
|
|
|
end
|
2022-05-25 14:44:49 +02:00
|
|
|
mcl_mobs:capture_mob(self, clicker, 0, 5, 60, false, nil)
|
2017-07-05 03:15:46 +02:00
|
|
|
end
|
2022-05-25 14:44:49 +02:00
|
|
|
mcl_mobs:register_mob("mobs_mc:mooshroom", mooshroom_def)
|
2017-07-05 03:15:46 +02:00
|
|
|
|
|
|
|
|
|
|
|
-- Spawning
|
2022-05-25 14:44:49 +02:00
|
|
|
mcl_mobs:spawn_specific(
|
2021-04-08 13:39:18 +02:00
|
|
|
"mobs_mc:cow",
|
2021-04-25 17:30:15 +02:00
|
|
|
"overworld",
|
2021-04-08 13:39:18 +02:00
|
|
|
"ground",
|
|
|
|
{
|
2022-03-22 15:16:48 +01:00
|
|
|
"flat",
|
|
|
|
"IcePlainsSpikes",
|
|
|
|
"ColdTaiga",
|
|
|
|
"ColdTaiga_beach",
|
|
|
|
"ColdTaiga_beach_water",
|
|
|
|
"MegaTaiga",
|
|
|
|
"MegaSpruceTaiga",
|
|
|
|
"ExtremeHills",
|
|
|
|
"ExtremeHills_beach",
|
|
|
|
"ExtremeHillsM",
|
|
|
|
"ExtremeHills+",
|
|
|
|
"ExtremeHills+_snowtop",
|
|
|
|
"StoneBeach",
|
|
|
|
"Plains",
|
|
|
|
"Plains_beach",
|
|
|
|
"SunflowerPlains",
|
|
|
|
"Taiga",
|
|
|
|
"Taiga_beach",
|
|
|
|
"Forest",
|
|
|
|
"Forest_beach",
|
|
|
|
"FlowerForest",
|
|
|
|
"FlowerForest_beach",
|
|
|
|
"BirchForest",
|
|
|
|
"BirchForestM",
|
|
|
|
"RoofedForest",
|
|
|
|
"Savanna",
|
|
|
|
"Savanna_beach",
|
|
|
|
"SavannaM",
|
|
|
|
"Jungle",
|
|
|
|
"Jungle_shore",
|
|
|
|
"JungleM",
|
|
|
|
"JungleM_shore",
|
|
|
|
"JungleEdge",
|
|
|
|
"JungleEdgeM",
|
|
|
|
"Swampland",
|
|
|
|
"Swampland_shore"
|
2021-04-08 13:39:18 +02:00
|
|
|
},
|
2021-04-25 17:30:15 +02:00
|
|
|
9,
|
|
|
|
minetest.LIGHT_MAX+1,
|
|
|
|
30,
|
|
|
|
17000,
|
|
|
|
10,
|
2022-05-25 23:25:15 +02:00
|
|
|
mobs_mc.water_level,
|
|
|
|
mcl_vars.mg_overworld_max)
|
2021-04-08 13:39:18 +02:00
|
|
|
|
|
|
|
|
2021-04-08 16:00:04 +02:00
|
|
|
|
2022-05-25 14:44:49 +02:00
|
|
|
mcl_mobs:spawn_specific(
|
2021-04-25 17:30:15 +02:00
|
|
|
"mobs_mc:mooshroom",
|
|
|
|
"overworld",
|
2021-04-08 13:39:18 +02:00
|
|
|
"ground",
|
|
|
|
{
|
|
|
|
"MushroomIslandShore",
|
|
|
|
"MushroomIsland"
|
|
|
|
},
|
2021-04-25 17:30:15 +02:00
|
|
|
9,
|
|
|
|
minetest.LIGHT_MAX+1,
|
|
|
|
30,
|
|
|
|
17000,
|
|
|
|
5,
|
2022-05-25 23:25:15 +02:00
|
|
|
mcl_vars.mg_overworld_min,
|
|
|
|
mcl_vars.mg_overworld_max)
|
2017-07-05 03:15:46 +02:00
|
|
|
|
|
|
|
-- spawn egg
|
2022-05-25 14:44:49 +02:00
|
|
|
mcl_mobs:register_egg("mobs_mc:cow", S("Cow"), "mobs_mc_spawn_icon_cow.png", 0)
|
|
|
|
mcl_mobs:register_egg("mobs_mc:mooshroom", S("Mooshroom"), "mobs_mc_spawn_icon_mooshroom.png", 0)
|