bunny.lua 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. local S = mobs.intllib_animal
  2. -- Bunny by ExeterDad
  3. mobs:register_mob("mobs_animal:bunny", {
  4. stepheight = 0.6,
  5. type = "animal",
  6. passive = true,
  7. reach = 1,
  8. hp_min = 1,
  9. hp_max = 4,
  10. armor = 200,
  11. collisionbox = {-0.268, -0.5, -0.268, 0.268, 0.167, 0.268},
  12. visual = "mesh",
  13. mesh = "mobs_bunny.b3d",
  14. drawtype = "front",
  15. textures = {
  16. {"mobs_bunny_grey.png"},
  17. {"mobs_bunny_brown.png"},
  18. {"mobs_bunny_white.png"}
  19. },
  20. sounds = {},
  21. makes_footstep_sound = false,
  22. walk_velocity = 1,
  23. run_velocity = 2,
  24. runaway = true,
  25. runaway_from = {"mobs_animal:pumba", "player"},
  26. jump = true,
  27. jump_height = 6,
  28. drops = {
  29. {name = "mobs:rabbit_raw", chance = 1, min = 1, max = 1},
  30. {name = "mobs:rabbit_hide", chance = 1, min = 0, max = 1}
  31. },
  32. water_damage = 0,
  33. lava_damage = 4,
  34. light_damage = 0,
  35. fear_height = 2,
  36. animation = {
  37. speed_normal = 15,
  38. stand_start = 1,
  39. stand_end = 15,
  40. walk_start = 16,
  41. walk_end = 24,
  42. punch_start = 16,
  43. punch_end = 24
  44. },
  45. follow = {"farming:carrot", "farming_plus:carrot_item", "default:grass_1"},
  46. view_range = 8,
  47. replace_rate = 10,
  48. replace_what = {"farming:carrot_7", "farming:carrot_8", "farming_plus:carrot"},
  49. replace_with = "air",
  50. on_rightclick = function(self, clicker)
  51. -- feed or tame
  52. if mobs:feed_tame(self, clicker, 4, true, true) then return end
  53. if mobs:protect(self, clicker) then return end
  54. if mobs:capture_mob(self, clicker, 30, 50, 80, false, nil) then return end
  55. -- Monty Python tribute
  56. local item = clicker:get_wielded_item()
  57. if item:get_name() == "mobs:lava_orb" then
  58. if not mobs.is_creative(clicker:get_player_name()) then
  59. item:take_item()
  60. clicker:set_wielded_item(item)
  61. end
  62. self.base_texture = {"mobs_bunny_evil.png"}
  63. self.object:set_properties({
  64. textures = {"mobs_bunny_evil.png"}
  65. })
  66. self.type = "monster"
  67. self.health = 20
  68. self.passive = false
  69. self.runaway = false
  70. return
  71. end
  72. end,
  73. on_spawn = function(self)
  74. local pos = self.object:get_pos() ; pos.y = pos.y - 1
  75. -- white snowy bunny
  76. if minetest.find_node_near(pos, 1,
  77. {"default:snow", "default:snowblock", "default:dirt_with_snow"}) then
  78. self.base_texture = {"mobs_bunny_white.png"}
  79. self.object:set_properties({textures = self.base_texture})
  80. -- brown desert bunny
  81. elseif minetest.find_node_near(pos, 1,
  82. {"default:desert_sand", "default:desert_stone"}) then
  83. self.base_texture = {"mobs_bunny_brown.png"}
  84. self.object:set_properties({textures = self.base_texture})
  85. -- grey stone bunny
  86. elseif minetest.find_node_near(pos, 1,
  87. {"default:stone", "default:gravel"}) then
  88. self.base_texture = {"mobs_bunny_grey.png"}
  89. self.object:set_properties({textures = self.base_texture})
  90. end
  91. return true -- run only once, false/nil runs every activation
  92. end,
  93. attack_type = "dogfight",
  94. damage = 5
  95. })
  96. local spawn_on = "default:dirt_with_grass"
  97. if minetest.get_modpath("ethereal") then
  98. spawn_on = "ethereal:prairie_dirt"
  99. end
  100. if not mobs.custom_spawn_animal then
  101. mobs:spawn({
  102. name = "mobs_animal:bunny",
  103. nodes = {spawn_on},
  104. neighbors = {"group:grass"},
  105. min_light = 14,
  106. interval = 60,
  107. chance = 8000,
  108. min_height = 5,
  109. max_height = 200,
  110. day_toggle = true
  111. })
  112. end
  113. mobs:register_egg("mobs_animal:bunny", S("Bunny"), "mobs_bunny_inv.png", 0)
  114. mobs:alias_mob("mobs:bunny", "mobs_animal:bunny") -- compatibility
  115. -- raw rabbit
  116. minetest.register_craftitem(":mobs:rabbit_raw", {
  117. description = S("Raw Rabbit"),
  118. inventory_image = "mobs_rabbit_raw.png",
  119. on_use = minetest.item_eat(3),
  120. groups = {food_meat_raw = 1, food_rabbit_raw = 1, flammable = 2}
  121. })
  122. -- cooked rabbit
  123. minetest.register_craftitem(":mobs:rabbit_cooked", {
  124. description = S("Cooked Rabbit"),
  125. inventory_image = "mobs_rabbit_cooked.png",
  126. on_use = minetest.item_eat(5),
  127. groups = {food_meat = 1, food_rabbit = 1, flammable = 2}
  128. })
  129. minetest.register_craft({
  130. type = "cooking",
  131. output = "mobs:rabbit_cooked",
  132. recipe = "mobs:rabbit_raw",
  133. cooktime = 5
  134. })
  135. -- rabbit hide
  136. minetest.register_craftitem(":mobs:rabbit_hide", {
  137. description = S("Rabbit Hide"),
  138. inventory_image = "mobs_rabbit_hide.png",
  139. groups = {flammable = 2, pelt = 1}
  140. })
  141. minetest.register_craft({
  142. type = "fuel",
  143. recipe = "mobs:rabbit_hide",
  144. burntime = 2
  145. })
  146. minetest.register_craft({
  147. output = "mobs:leather",
  148. recipe = {
  149. {"mobs:rabbit_hide", "mobs:rabbit_hide"},
  150. {"mobs:rabbit_hide", "mobs:rabbit_hide"}
  151. }
  152. })