Animal mobs for Mobs Redo on Minetest https://content.minetest.net/packages/TenPlus1/mobs_animal/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

258 lines
5.8KB

  1. local S = mobs.intllib
  2. -- Cow by sirrobzeroone
  3. mobs:register_mob("mobs_animal:cow", {
  4. type = "animal",
  5. passive = false,
  6. attack_type = "dogfight",
  7. attack_npcs = false,
  8. reach = 2,
  9. damage = 4,
  10. hp_min = 5,
  11. hp_max = 20,
  12. armor = 200,
  13. collisionbox = {-0.4, -0.01, -0.4, 0.4, 1.2, 0.4},
  14. visual = "mesh",
  15. mesh = "mobs_cow.b3d",
  16. textures = {
  17. {"mobs_cow.png"},
  18. {"mobs_cow2.png"},
  19. },
  20. makes_footstep_sound = true,
  21. sounds = {
  22. random = "mobs_cow",
  23. },
  24. walk_velocity = 1,
  25. run_velocity = 2,
  26. jump = true,
  27. jump_height = 6,
  28. pushable = true,
  29. drops = {
  30. {name = "mobs:meat_raw", chance = 1, min = 1, max = 3},
  31. {name = "mobs:leather", chance = 1, min = 0, max = 2},
  32. },
  33. water_damage = 0,
  34. lava_damage = 5,
  35. light_damage = 0,
  36. animation = {
  37. stand_start = 0,
  38. stand_end = 30,
  39. stand_speed = 20,
  40. stand1_start = 35,
  41. stand1_end = 75,
  42. stand1_speed = 20,
  43. walk_start = 85,
  44. walk_end = 114,
  45. walk_speed = 20,
  46. run_start = 120,
  47. run_end = 140,
  48. run_speed = 30,
  49. punch_start = 145,
  50. punch_end = 160,
  51. punch_speed = 20,
  52. die_start = 165,
  53. die_end = 185,
  54. die_speed = 10,
  55. die_loop = false,
  56. },
  57. follow = {"farming:wheat", "default:grass_1"},
  58. view_range = 8,
  59. replace_rate = 10,
  60. replace_what = {
  61. {"group:grass", "air", 0},
  62. {"default:dirt_with_grass", "default:dirt", -1}
  63. },
  64. -- stay_near = {{"farming:straw", "group:grass"}, 10},
  65. fear_height = 2,
  66. on_rightclick = function(self, clicker)
  67. -- feed or tame
  68. if mobs:feed_tame(self, clicker, 8, true, true) then
  69. -- if fed 7x wheat or grass then cow can be milked again
  70. if self.food and self.food > 6 then
  71. self.gotten = false
  72. end
  73. return
  74. end
  75. if mobs:protect(self, clicker) then return end
  76. if mobs:capture_mob(self, clicker, 0, 5, 60, false, nil) then return end
  77. local tool = clicker:get_wielded_item()
  78. local name = clicker:get_player_name()
  79. -- milk cow with empty bucket
  80. if tool:get_name() == "bucket:bucket_empty" then
  81. --if self.gotten == true
  82. if self.child == true then
  83. return
  84. end
  85. if self.gotten == true then
  86. minetest.chat_send_player(name,
  87. S("Cow already milked!"))
  88. return
  89. end
  90. local inv = clicker:get_inventory()
  91. tool:take_item()
  92. clicker:set_wielded_item(tool)
  93. if inv:room_for_item("main", {name = "mobs:bucket_milk"}) then
  94. clicker:get_inventory():add_item("main", "mobs:bucket_milk")
  95. else
  96. local pos = self.object:get_pos()
  97. pos.y = pos.y + 0.5
  98. minetest.add_item(pos, {name = "mobs:bucket_milk"})
  99. end
  100. self.gotten = true -- milked
  101. return
  102. end
  103. end,
  104. on_replace = function(self, pos, oldnode, newnode)
  105. self.food = (self.food or 0) + 1
  106. -- if cow replaces 8x grass then it can be milked again
  107. if self.food >= 8 then
  108. self.food = 0
  109. self.gotten = false
  110. end
  111. end,
  112. })
  113. mobs:spawn({
  114. name = "mobs_animal:cow",
  115. nodes = {"default:dirt_with_grass", "ethereal:green_dirt"},
  116. neighbors = {"group:grass"},
  117. min_light = 14,
  118. interval = 60,
  119. chance = 8000, -- 15000
  120. min_height = 5,
  121. max_height = 200,
  122. day_toggle = true,
  123. })
  124. mobs:register_egg("mobs_animal:cow", S("Cow"), "mobs_cow_inv.png")
  125. mobs:alias_mob("mobs:cow", "mobs_animal:cow") -- compatibility
  126. -- bucket of milk
  127. minetest.register_craftitem(":mobs:bucket_milk", {
  128. description = S("Bucket of Milk"),
  129. inventory_image = "mobs_bucket_milk.png",
  130. stack_max = 1,
  131. on_use = minetest.item_eat(8, "bucket:bucket_empty"),
  132. groups = {food_milk = 1, flammable = 3, drink = 1},
  133. })
  134. -- glass of milk
  135. minetest.register_craftitem(":mobs:glass_milk", {
  136. description = S("Glass of Milk"),
  137. inventory_image = "mobs_glass_milk.png",
  138. on_use = minetest.item_eat(2, "vessels:drinking_glass"),
  139. groups = {food_milk_glass = 1, flammable = 3, vessel = 1, drink = 1},
  140. })
  141. minetest.register_craft({
  142. type = "shapeless",
  143. output = "mobs:glass_milk 4",
  144. recipe = {
  145. "vessels:drinking_glass", "vessels:drinking_glass",
  146. "vessels:drinking_glass", "vessels:drinking_glass",
  147. "mobs:bucket_milk"
  148. },
  149. replacements = { {"mobs:bucket_milk", "bucket:bucket_empty"} }
  150. })
  151. minetest.register_craft({
  152. type = "shapeless",
  153. output = "mobs:bucket_milk",
  154. recipe = {
  155. "mobs:glass_milk", "mobs:glass_milk",
  156. "mobs:glass_milk", "mobs:glass_milk",
  157. "bucket:bucket_empty"
  158. },
  159. replacements = { {"mobs:glass_milk", "vessels:drinking_glass 4"} }
  160. })
  161. -- butter
  162. minetest.register_craftitem(":mobs:butter", {
  163. description = S("Butter"),
  164. inventory_image = "mobs_butter.png",
  165. on_use = minetest.item_eat(1),
  166. groups = {food_butter = 1, flammable = 2},
  167. })
  168. if minetest.get_modpath("farming") and farming and farming.mod then
  169. minetest.register_craft({
  170. type = "shapeless",
  171. output = "mobs:butter",
  172. recipe = {"mobs:bucket_milk", "farming:salt"},
  173. replacements = {{ "mobs:bucket_milk", "bucket:bucket_empty"}}
  174. })
  175. else -- some saplings are high in sodium so makes a good replacement item
  176. minetest.register_craft({
  177. type = "shapeless",
  178. output = "mobs:butter",
  179. recipe = {"mobs:bucket_milk", "default:sapling"},
  180. replacements = {{ "mobs:bucket_milk", "bucket:bucket_empty"}}
  181. })
  182. end
  183. -- cheese wedge
  184. minetest.register_craftitem(":mobs:cheese", {
  185. description = S("Cheese"),
  186. inventory_image = "mobs_cheese.png",
  187. on_use = minetest.item_eat(4),
  188. groups = {food_cheese = 1, flammable = 2},
  189. })
  190. minetest.register_craft({
  191. type = "cooking",
  192. output = "mobs:cheese",
  193. recipe = "mobs:bucket_milk",
  194. cooktime = 5,
  195. replacements = {{ "mobs:bucket_milk", "bucket:bucket_empty"}}
  196. })
  197. -- cheese block
  198. minetest.register_node(":mobs:cheeseblock", {
  199. description = S("Cheese Block"),
  200. tiles = {"mobs_cheeseblock.png"},
  201. is_ground_content = false,
  202. groups = {crumbly = 3},
  203. sounds = default.node_sound_dirt_defaults()
  204. })
  205. minetest.register_craft({
  206. output = "mobs:cheeseblock",
  207. recipe = {
  208. {"mobs:cheese", "mobs:cheese", "mobs:cheese"},
  209. {"mobs:cheese", "mobs:cheese", "mobs:cheese"},
  210. {"mobs:cheese", "mobs:cheese", "mobs:cheese"},
  211. }
  212. })
  213. minetest.register_craft({
  214. output = "mobs:cheese 9",
  215. recipe = {
  216. {"mobs:cheeseblock"},
  217. }
  218. })