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.

203 lines
4.4KB

  1. local S = mobs.intllib
  2. -- Bee by KrupnoPavel (.b3d model by sirrobzeroone)
  3. mobs:register_mob("mobs_animal:bee", {
  4. type = "animal",
  5. passive = true,
  6. hp_min = 1,
  7. hp_max = 2,
  8. armor = 200,
  9. collisionbox = {-0.2, -0.01, -0.2, 0.2, 0.5, 0.2},
  10. visual = "mesh",
  11. mesh = "mobs_bee.b3d",
  12. textures = {
  13. {"mobs_bee.png"},
  14. },
  15. blood_texture = "mobs_bee_inv.png",
  16. blood_amount = 1,
  17. makes_footstep_sound = false,
  18. sounds = {
  19. random = "mobs_bee",
  20. },
  21. walk_velocity = 1,
  22. jump = true,
  23. drops = {
  24. {name = "mobs:honey", chance = 2, min = 1, max = 2},
  25. },
  26. water_damage = 1,
  27. lava_damage = 2,
  28. light_damage = 0,
  29. fall_damage = 0,
  30. fall_speed = -3,
  31. animation = {
  32. speed_normal = 15,
  33. stand_start = 0,
  34. stand_end = 30,
  35. walk_start = 35,
  36. walk_end = 65,
  37. },
  38. on_rightclick = function(self, clicker)
  39. mobs:capture_mob(self, clicker, 50, 90, 0, true, "mobs_animal:bee")
  40. end,
  41. -- after_activate = function(self, staticdata, def, dtime)
  42. -- print ("------", self.name, dtime, self.health)
  43. -- end,
  44. })
  45. mobs:spawn({
  46. name = "mobs_animal:bee",
  47. nodes = {"group:flower"},
  48. min_light = 14,
  49. interval = 60,
  50. chance = 7000,
  51. min_height = 3,
  52. max_height = 200,
  53. day_toggle = true,
  54. })
  55. mobs:register_egg("mobs_animal:bee", S("Bee"), "mobs_bee_inv.png")
  56. -- compatibility
  57. mobs:alias_mob("mobs:bee", "mobs_animal:bee")
  58. -- honey
  59. minetest.register_craftitem(":mobs:honey", {
  60. description = S("Honey"),
  61. inventory_image = "mobs_honey_inv.png",
  62. on_use = minetest.item_eat(4),
  63. groups = {food_honey = 1, food_sugar = 1, flammable = 1},
  64. })
  65. -- beehive (when placed spawns bee)
  66. minetest.register_node(":mobs:beehive", {
  67. description = S("Beehive"),
  68. drawtype = "plantlike",
  69. tiles = {"mobs_beehive.png"},
  70. inventory_image = "mobs_beehive.png",
  71. paramtype = "light",
  72. sunlight_propagates = true,
  73. walkable = true,
  74. groups = {oddly_breakable_by_hand = 3, flammable = 1},
  75. sounds = default.node_sound_defaults(),
  76. on_construct = function(pos)
  77. local meta = minetest.get_meta(pos)
  78. meta:set_string("formspec", "size[8,6]"
  79. ..default.gui_bg..default.gui_bg_img..default.gui_slots
  80. .. "image[3,0.8;0.8,0.8;mobs_bee_inv.png]"
  81. .. "list[current_name;beehive;4,0.5;1,1;]"
  82. .. "list[current_player;main;0,2.35;8,4;]"
  83. .. "listring[]")
  84. meta:get_inventory():set_size("beehive", 1)
  85. end,
  86. after_place_node = function(pos, placer, itemstack)
  87. if placer and placer:is_player() then
  88. minetest.set_node(pos, {name = "mobs:beehive", param2 = 1})
  89. if math.random(1, 4) == 1 then
  90. minetest.add_entity(pos, "mobs_animal:bee")
  91. end
  92. end
  93. end,
  94. on_punch = function(pos, node, puncher)
  95. -- yep, bee's don't like having their home punched by players
  96. puncher:set_hp(puncher:get_hp() - 4)
  97. end,
  98. allow_metadata_inventory_put = function(pos, listname, index, stack, player)
  99. if listname == "beehive" then
  100. return 0
  101. end
  102. return stack:get_count()
  103. end,
  104. can_dig = function(pos,player)
  105. local meta = minetest.get_meta(pos)
  106. -- only dig beehive if no honey inside
  107. return meta:get_inventory():is_empty("beehive")
  108. end,
  109. })
  110. minetest.register_craft({
  111. output = "mobs:beehive",
  112. recipe = {
  113. {"mobs:bee","mobs:bee","mobs:bee"},
  114. }
  115. })
  116. -- honey block
  117. minetest.register_node(":mobs:honey_block", {
  118. description = S("Honey Block"),
  119. tiles = {"mobs_honey_block.png"},
  120. groups = {snappy = 3, flammable = 2},
  121. sounds = default.node_sound_dirt_defaults(),
  122. })
  123. minetest.register_craft({
  124. output = "mobs:honey_block",
  125. recipe = {
  126. {"mobs:honey", "mobs:honey", "mobs:honey"},
  127. {"mobs:honey", "mobs:honey", "mobs:honey"},
  128. {"mobs:honey", "mobs:honey", "mobs:honey"},
  129. }
  130. })
  131. minetest.register_craft({
  132. output = "mobs:honey 9",
  133. recipe = {
  134. {"mobs:honey_block"},
  135. }
  136. })
  137. -- beehive workings
  138. minetest.register_abm({
  139. nodenames = {"mobs:beehive"},
  140. interval = 12,
  141. chance = 6,
  142. catch_up = false,
  143. action = function(pos, node)
  144. -- bee's only make honey during the day
  145. local tod = (minetest.get_timeofday() or 0) * 24000
  146. if tod < 5500 or tod > 18500 then
  147. return
  148. end
  149. -- is hive full?
  150. local meta = minetest.get_meta(pos)
  151. if not meta then return end -- for older beehives
  152. local inv = meta:get_inventory()
  153. local honey = inv:get_stack("beehive", 1):get_count()
  154. -- is hive full?
  155. if honey > 11 then
  156. return
  157. end
  158. -- no flowers no honey, nuff said!
  159. if #minetest.find_nodes_in_area_under_air(
  160. {x = pos.x - 4, y = pos.y - 3, z = pos.z - 4},
  161. {x = pos.x + 4, y = pos.y + 3, z = pos.z + 4},
  162. "group:flower") > 3 then
  163. inv:add_item("beehive", "mobs:honey")
  164. end
  165. end
  166. })