cow.lua 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. local S = mobs.intllib
  2. -- Cow by Krupnovpavel (texture by Tirifto)
  3. mobs:register_mob("mobs_animal:cow", {
  4. type = "animal",
  5. passive = false,
  6. attack_type = "dogfight",
  7. reach = 2,
  8. damage = 4,
  9. hp_min = 5,
  10. hp_max = 20,
  11. armor = 200,
  12. collisionbox = {-0.4, -0.01, -0.4, 0.4, 1, 0.4},
  13. visual = "mesh",
  14. mesh = "mobs_cow.x",
  15. textures = {
  16. {"mobs_cow_brown.png"},
  17. {"mobs_cow_straciatella.png"},
  18. {"mobs_cow_straciatella2.png"},
  19. {"mobs_cow_meat.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. drops = {
  29. {name = "mobs:meat_raw", chance = 1, min = 1, max = 3},
  30. {name = "mobs:leather", chance = 1, min = 1, max = 2},
  31. },
  32. water_damage = 1,
  33. lava_damage = 5,
  34. light_damage = 0,
  35. animation = {
  36. speed_normal = 15,
  37. speed_run = 15,
  38. stand_start = 0,
  39. stand_end = 30,
  40. walk_start = 35,
  41. walk_end = 65,
  42. run_start = 105,
  43. run_end = 135,
  44. punch_start = 70,
  45. punch_end = 100,
  46. },
  47. follow = "farming:wheat",
  48. view_range = 8,
  49. replace_rate = 10,
  50. -- replace_what = {"default:grass_3", "default:grass_4", "default:grass_5", "farming:wheat_8"},
  51. replace_what = {
  52. {"group:grass", "air", 0},
  53. {"default:dirt_with_grass", "default:dirt", -1}
  54. },
  55. replace_with = "air",
  56. fear_height = 2,
  57. on_rightclick = function(self, clicker)
  58. -- feed or tame
  59. if mobs:feed_tame(self, clicker, 8, true, true) then return end
  60. if mobs:protect(self, clicker) then return end
  61. if mobs:capture_mob(self, clicker, 0, 5, 60, false, nil) then return end
  62. local tool = clicker:get_wielded_item()
  63. local name = clicker:get_player_name()
  64. -- milk cow with empty bucket
  65. if tool:get_name() == "bucket:bucket_empty" then
  66. --if self.gotten == true
  67. if self.child == true then
  68. return
  69. end
  70. if self.gotten == true then
  71. minetest.chat_send_player(name,
  72. S("Cow already milked!"))
  73. return
  74. end
  75. local inv = clicker:get_inventory()
  76. inv:remove_item("main", "bucket:bucket_empty")
  77. if inv:room_for_item("main", {name = "mobs:bucket_milk"}) then
  78. clicker:get_inventory():add_item("main", "mobs:bucket_milk")
  79. else
  80. local pos = self.object:getpos()
  81. pos.y = pos.y + 0.5
  82. minetest.add_item(pos, {name = "mobs:bucket_milk"})
  83. end
  84. self.gotten = true -- milked
  85. return
  86. end
  87. end,
  88. })
  89. local spawn_on = "default:dirt_with_grass"
  90. if minetest.get_modpath("ethereal") then
  91. spawn_on = "ethereal:green_dirt"
  92. end
  93. mobs:spawn({
  94. name = "mobs_animal:cow",
  95. nodes = {spawn_on},
  96. min_light = 0,
  97. max_light = 10,
  98. chance = 15000,
  99. min_height = 0,
  100. max_height = 31000,
  101. day_toggle = true,
  102. })
  103. mobs:register_egg("mobs_animal:cow", S("Cow"), "default_grass.png", 1)
  104. mobs:alias_mob("mobs:cow", "mobs_animal:cow") -- compatibility
  105. -- bucket of milk
  106. minetest.register_craftitem(":mobs:bucket_milk", {
  107. description = S("Bucket of Milk"),
  108. inventory_image = "mobs_bucket_milk.png",
  109. stack_max = 1,
  110. on_use = minetest.item_eat(8, 'bucket:bucket_empty'),
  111. })
  112. -- cheese wedge
  113. minetest.register_craftitem(":mobs:cheese", {
  114. description = S("Cheese"),
  115. inventory_image = "mobs_cheese.png",
  116. on_use = minetest.item_eat(4),
  117. })
  118. minetest.register_craft({
  119. type = "cooking",
  120. output = "mobs:cheese",
  121. recipe = "mobs:bucket_milk",
  122. cooktime = 5,
  123. replacements = {{ "mobs:bucket_milk", "bucket:bucket_empty"}}
  124. })
  125. -- cheese block
  126. minetest.register_node(":mobs:cheeseblock", {
  127. description = S("Cheese Block"),
  128. tiles = {"mobs_cheeseblock.png"},
  129. is_ground_content = false,
  130. groups = {crumbly = 3},
  131. sounds = default.node_sound_dirt_defaults()
  132. })
  133. minetest.register_craft({
  134. output = "mobs:cheeseblock",
  135. recipe = {
  136. {'mobs:cheese', 'mobs:cheese', 'mobs:cheese'},
  137. {'mobs:cheese', 'mobs:cheese', 'mobs:cheese'},
  138. {'mobs:cheese', 'mobs:cheese', 'mobs:cheese'},
  139. }
  140. })
  141. minetest.register_craft({
  142. output = "mobs:cheese 9",
  143. recipe = {
  144. {'mobs:cheeseblock'},
  145. }
  146. })