sheep.lua 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. mobs.register_mob("sheep:sheep", {
  2. type = "animal",
  3. passive = true,
  4. hp_min = 8,
  5. hp_max = 10,
  6. armor = 200,
  7. collisionbox = {-0.45, -1, -0.45, 0.45, 0.3, 0.45},
  8. visual = "mesh",
  9. mesh = "sheep_sheep.b3d",
  10. textures = {
  11. {"sheep_sheep_base.png^(sheep_sheep_wool.png^[colorize:#abababc0)"},
  12. },
  13. gotten_texture = {"sheep_sheep_shaved.png"},
  14. gotten_mesh = "sheep_sheep_shaved.b3d",
  15. makes_footstep_sound = true,
  16. sounds = {
  17. random = "sheep_sheep",
  18. death = "sheep_sheep",
  19. },
  20. walk_velocity = 1,
  21. run_velocity = 2,
  22. runaway = true,
  23. jump = true,
  24. drops = {
  25. {name = "mobs:meat_raw_mutton", chance = 1, min = 1, max = 1}, -- Killing sheep doesn't yield much meat.
  26. },
  27. water_damage = 1,
  28. lava_damage = 100,
  29. light_damage = 0,
  30. animation = {
  31. speed_normal = 15,
  32. speed_run = 15,
  33. stand_start = 0,
  34. stand_end = 80,
  35. walk_start = 81,
  36. walk_end = 100,
  37. },
  38. follow = {"farming:wheat", "default:grass_dummy", "default:coarsegrass"},
  39. view_range = 8,
  40. replace_rate = 10,
  41. replace_what = {
  42. "default:grass_3",
  43. "default:grass_4",
  44. "default:grass_5",
  45. "farming:wheat_8",
  46. },
  47. replace_with = "air",
  48. replace_offset = -1,
  49. fear_height = 2,
  50. on_rightclick = function(self, clicker)
  51. -- Are we feeding?
  52. if mobs.feed_tame(self, clicker, 8, true, true) then
  53. --if full grow fuzz
  54. if self.gotten == false then
  55. self.object:set_properties({
  56. textures = {"sheep_sheep_base.png^(sheep_sheep_wool.png^[colorize:#abababc0)"},
  57. mesh = "sheep_sheep.b3d",
  58. })
  59. end
  60. return
  61. end
  62. local item = clicker:get_wielded_item()
  63. local itemname = item:get_name()
  64. -- Are we giving a haircut?.
  65. if itemname == "shears:shears" then
  66. if self.gotten ~= false or self.child ~= false or not minetest.get_modpath("wool") then
  67. return
  68. end
  69. self.gotten = true -- shaved
  70. local obj = minetest.add_item(
  71. self.object:getpos(),
  72. ItemStack( "wool:white " .. math.random(1, 3) )
  73. )
  74. if obj then
  75. obj:setvelocity({
  76. x = math.random(-1, 1),
  77. y = 5,
  78. z = math.random(-1, 1)
  79. })
  80. end
  81. item:add_wear(650) -- 100 uses
  82. clicker:set_wielded_item(item)
  83. self.object:set_properties({
  84. textures = {"sheep_sheep_shaved.png"},
  85. mesh = "sheep_sheep_shaved.b3d",
  86. })
  87. return
  88. end
  89. -- Are we capturing?
  90. mobs.capture_mob(self, clicker, 0, 80, 60, false, nil)
  91. end
  92. })
  93. -- Obtainable by players.
  94. mobs.register_egg("sheep:sheep", "Sheep", "wool_white.png", 1)
  95. -- Compatibility.
  96. mobs.alias_mob("mobs:sheep", "sheep:sheep")
  97. mobs.alias_mob("mobs_animal:sheep_white", "sheep:sheep")