Camas/mods/mobs/mob_sheep.lua

153 lines
3.9 KiB
Lua
Raw Normal View History

-- Sheep by PilzAdam; tweaked for Pixture by KaadmY
2015-09-01 17:15:24 +02:00
2019-08-28 17:31:41 +02:00
local S = minetest.get_translator("mobs")
2015-09-01 17:15:24 +02:00
mobs:register_mob(
"mobs:sheep",
{
type = "animal",
passive = true,
2015-10-23 19:34:09 +02:00
hp_min = 10,
2015-09-01 17:15:24 +02:00
hp_max = 14,
breath_max = 5,
2015-09-01 17:15:24 +02:00
armor = 200,
collisionbox = {-0.5, -1, -0.5, 0.5, 0.1, 0.5},
2015-09-01 17:15:24 +02:00
visual = "mesh",
mesh = "mobs_sheep.x",
visual_size = {x = 1, y = 1},
textures = {
{"mobs_sheep.png"},
},
gotten_texture = {"mobs_sheep_shaved.png"},
-- gotten_mesh = "mobs_sheep.x",
2015-09-01 17:15:24 +02:00
makes_footstep_sound = true,
sounds = {
random = "mobs_sheep",
2019-09-03 20:01:56 +02:00
death = "mobs_sheep",
2019-09-22 13:39:16 +02:00
damage = "mobs_sheep",
distance = 16,
2015-09-01 17:15:24 +02:00
},
walk_velocity = 1,
walk_chance = 150,
jump = false,
2015-09-01 17:15:24 +02:00
jump_height = 5,
drops = {
{name = "mobs:meat_raw",
chance = 1, min = 2, max = 4},
{name = "mobs:wool",
chance = 1, min = 1, max = 2},
},
water_damage = 0,
2015-09-01 17:15:24 +02:00
lava_damage = 5,
light_damage = 0,
animation = {
speed_normal = 15,
speed_run = 25,
stand_start = 0,
stand_end = 60,
walk_start = 61,
walk_end = 80,
},
follow = "farming:wheat",
view_range = 5,
replace_rate = 50,
replace_what = {
"default:grass",
"default:tall_grass",
"farming:wheat_3",
"farming:wheat_4"
},
2015-09-01 17:15:24 +02:00
replace_with = "air",
replace_offset = -1,
2015-09-01 17:15:24 +02:00
on_replace = function(self, pos)
minetest.set_node(pos, {name = self.replace_with})
if mobs:feed_tame(self, self.follow, 8, true) then
if self.gotten == false then
self.object:set_properties(
{
textures = {"mobs_sheep.png"},
mesh = "mobs_sheep.x",
})
end
end
end,
2015-09-01 17:15:24 +02:00
on_rightclick = function(self, clicker)
-- Are we feeding?
if mobs:feed_tame(self, clicker, 8, true) then
-- If full grow, add fuzz
if self.gotten == false then
self.object:set_properties(
{
textures = {"mobs_sheep.png"},
mesh = "mobs_sheep.x",
})
end
return
end
local item = clicker:get_wielded_item()
local itemname = item:get_name()
-- Are we giving a haircut?
2019-09-24 03:05:06 +02:00
if minetest.get_item_group(itemname, "shears") > 0 then
if self.gotten == false and self.child == false then
self.gotten = true -- shaved
local pos = self.object:get_pos()
pos.y = pos.y + 0.5
local obj = minetest.add_item(pos, ItemStack("mobs:wool"))
if obj then
obj:set_velocity(
{
x = math.random(-1,1),
y = 5,
z = math.random(-1,1)
})
end
if not minetest.settings:get_bool("creative_mode") then
local def = item:get_definition()
local cuts = minetest.get_item_group(itemname, "sheep_cuts")
if cuts > 0 then
item:add_wear(math.floor(65535 / cuts))
else
item:add_wear(math.floor(65535 / def.tool_capabilities.snappy.uses))
end
end
clicker:set_wielded_item(item)
self.object:set_properties(
{
textures = {"mobs_sheep_shaved.png"},
mesh = "mobs_sheep.x",
})
end
return
end
-- Are we capturing?
mobs:capture_mob(self, clicker, 0, 5, 60, false, nil)
end,
})
mobs:register_spawn(
"mobs:sheep",
{
"default:dirt_with_grass"
},
20,
10,
15000,
1,
31000
)
2015-09-01 17:15:24 +02:00
2019-08-28 17:31:41 +02:00
mobs:register_egg("mobs:sheep", S("Sheep"), "mobs_sheep_inventory.png")