cow.lua 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. local S = mobs.intllib
  2. -- Cow by Krupnovpavel (additional texture by JurajVajda)
  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. damage_chance = 75,
  11. hp_min = 5,
  12. hp_max = 20,
  13. armor = 200,
  14. collisionbox = {-0.4, -0.01, -0.4, 0.4, 1.2, 0.4},
  15. visual = "mesh",
  16. mesh = "mobs_cow.x",
  17. textures = {
  18. {"mobs_cow.png"},
  19. {"mobs_cow2.png"},
  20. },
  21. makes_footstep_sound = true,
  22. sounds = {
  23. random = "mobs_cow",
  24. },
  25. walk_velocity = 1,
  26. run_velocity = 2,
  27. jump = true,
  28. jump_height = 6,
  29. pushable = true,
  30. drops = {
  31. {name = "mobs:meat_raw", chance = 1, min = 1, max = 3},
  32. {name = "mobs:leather", chance = 1, min = 1, max = 2},
  33. {name = 'bonemeal:bone', chance = 2, min = 1, max = 10},
  34. },
  35. water_damage = 1,
  36. lava_damage = 5,
  37. light_damage = 0,
  38. animation = {
  39. speed_normal = 15,
  40. speed_run = 15,
  41. stand_start = 0,
  42. stand_end = 30,
  43. walk_start = 35,
  44. walk_end = 65,
  45. run_start = 105,
  46. run_end = 135,
  47. punch_start = 70,
  48. punch_end = 100,
  49. },
  50. follow = "farming:wheat",
  51. view_range = 8,
  52. replace_rate = 10,
  53. replace_what = {"default:grass_3", "default:grass_4", "default:grass_5", "group:grain"},
  54. replace_with = "air",
  55. fear_height = 2,
  56. on_rightclick = function(self, clicker)
  57. if mobs:feed_tame(self, clicker, 9, true, true) then
  58. if self.food and self.food >= 8 then
  59. self.gotten = false
  60. end
  61. return
  62. end
  63. if mobs:protect(self, clicker) then return end
  64. if mobs:capture_mob(self, clicker, 0, 5, 60, false, nil) then return end
  65. local tool = clicker:get_wielded_item()
  66. local name = clicker:get_player_name()
  67. if tool:get_name() == "bucket:bucket_empty" then
  68. if self.child == true then
  69. return
  70. end
  71. if self.gotten == true then
  72. minetest.chat_send_player(name,
  73. S("Cow already milked!"))
  74. return
  75. end
  76. local inv = clicker:get_inventory()
  77. tool:take_item()
  78. clicker:set_wielded_item(tool)
  79. if inv:room_for_item("main", {name = "mobs:bucket_milk"}) then
  80. clicker:get_inventory():add_item("main", "mobs:bucket_milk")
  81. else
  82. local pos = self.object:get_pos()
  83. pos.y = pos.y + 0.5
  84. minetest.add_item(pos, {name = "mobs:bucket_milk"})
  85. end
  86. self.gotten = true -- milked
  87. return
  88. end
  89. end,
  90. on_replace = function(self, pos, oldnode, newnode)
  91. self.food = (self.food or 0) + 1
  92. if self.food >= 8 then
  93. self.food = 0
  94. self.gotten = false
  95. end
  96. end,
  97. })
  98. mobs:spawn({
  99. name = "mobs_animal:cow",
  100. nodes = {"default:dirt_with_grass", "ethereal:green_dirt"},
  101. neighbors = {"group:grass"},
  102. min_light = 14,
  103. interval = 60,
  104. chance = 8000, -- 15000
  105. min_height = 5,
  106. max_height = 200,
  107. day_toggle = true,
  108. })
  109. mobs:register_egg("mobs_animal:cow", S("Cow"), "default_grass.png", 1)
  110. mobs:alias_mob("mobs:cow", "mobs_animal:cow") -- compatibility
  111. -- bucket of milk
  112. minetest.register_craftitem(":mobs:bucket_milk", {
  113. description = S("Bucket of Milk"),
  114. inventory_image = "mobs_bucket_milk.png",
  115. stack_max = 1,
  116. on_use = minetest.item_eat(8, 'bucket:bucket_empty'),
  117. groups = {food_milk = 1, flammable = 3},
  118. })
  119. -- butter
  120. minetest.register_craftitem(":mobs:butter", {
  121. description = S("Butter"),
  122. inventory_image = "mobs_butter.png",
  123. on_use = minetest.item_eat(1),
  124. groups = {food_butter = 1, flammable = 2},
  125. })
  126. -- cheese wedge
  127. minetest.register_craftitem(":mobs:cheese", {
  128. description = S("Cheese"),
  129. inventory_image = "mobs_cheese.png",
  130. on_use = minetest.item_eat(4),
  131. groups = {food_cheese = 1, flammable = 2},
  132. })
  133. minetest.register_craft({
  134. type = "cooking",
  135. output = "mobs:cheese",
  136. recipe = "mobs:bucket_milk",
  137. cooktime = 5,
  138. replacements = {{ "mobs:bucket_milk", "bucket:bucket_empty"}}
  139. })
  140. -- cheese block
  141. minetest.register_node(":mobs:cheeseblock", {
  142. description = S("Cheese Block"),
  143. tiles = {"mobs_cheeseblock.png"},
  144. is_ground_content = false,
  145. groups = {crumbly = 3},
  146. sounds = default.node_sound_dirt_defaults()
  147. })
  148. minetest.register_craft({
  149. output = "mobs:cheeseblock",
  150. recipe = {
  151. {'mobs:cheese', 'mobs:cheese', 'mobs:cheese'},
  152. {'mobs:cheese', 'mobs:cheese', 'mobs:cheese'},
  153. {'mobs:cheese', 'mobs:cheese', 'mobs:cheese'},
  154. }
  155. })
  156. minetest.register_craft({
  157. output = "mobs:cheese 9",
  158. recipe = {
  159. {'mobs:cheeseblock'},
  160. }
  161. })