sheep.lua 3.2 KB

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