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.

244 lines
5.7KB

  1. local S = mobs.intllib
  2. local all_colours = {
  3. {"black", S("Black"), "#000000b0"},
  4. {"blue", S("Blue"), "#015dbb70"},
  5. {"brown", S("Brown"), "#663300a0"},
  6. {"cyan", S("Cyan"), "#01ffd870"},
  7. {"dark_green", S("Dark Green"), "#005b0770"},
  8. {"dark_grey", S("Dark Grey"), "#303030b0"},
  9. {"green", S("Green"), "#61ff0170"},
  10. {"grey", S("Grey"), "#5b5b5bb0"},
  11. {"magenta", S("Magenta"), "#ff05bb70"},
  12. {"orange", S("Orange"), "#ff840170"},
  13. {"pink", S("Pink"), "#ff65b570"},
  14. {"red", S("Red"), "#ff0000a0"},
  15. {"violet", S("Violet"), "#2000c970"},
  16. {"white", S("White"), "#abababc0"},
  17. {"yellow", S("Yellow"), "#e3ff0070"},
  18. }
  19. -- Sheep by PilzAdam, texture converted to minetest by AMMOnym from Summerfield pack
  20. for _, col in ipairs(all_colours) do
  21. mobs:register_mob("mobs_animal:sheep_"..col[1], {
  22. stay_near = {"farming:straw", 10},
  23. stepheight = 0.6,
  24. type = "animal",
  25. passive = true,
  26. hp_min = 8,
  27. hp_max = 10,
  28. armor = 200,
  29. collisionbox = {-0.5, -1, -0.5, 0.5, 0.3, 0.5},
  30. visual = "mesh",
  31. mesh = "mobs_sheep.b3d",
  32. textures = {
  33. {"mobs_sheep_base.png^(mobs_sheep_wool.png^[colorize:" .. col[3] .. ")"},
  34. },
  35. gotten_texture = {"mobs_sheep_shaved.png"},
  36. gotten_mesh = "mobs_sheep_shaved.b3d",
  37. makes_footstep_sound = true,
  38. sounds = {
  39. random = "mobs_sheep",
  40. },
  41. walk_velocity = 1,
  42. run_velocity = 2,
  43. runaway = true,
  44. jump = true,
  45. jump_height = 6,
  46. pushable = true,
  47. drops = {
  48. {name = "mobs:mutton_raw", chance = 1, min = 1, max = 2},
  49. {name = "wool:"..col[1], chance = 1, min = 1, max = 1},
  50. },
  51. water_damage = 0,
  52. lava_damage = 5,
  53. light_damage = 0,
  54. animation = {
  55. speed_normal = 15,
  56. speed_run = 15,
  57. stand_start = 0,
  58. stand_end = 80,
  59. walk_start = 81,
  60. walk_end = 100,
  61. },
  62. follow = {"farming:wheat", "default:grass_1"},
  63. view_range = 8,
  64. replace_rate = 10,
  65. replace_what = {
  66. {"group:grass", "air", -1},
  67. {"default:dirt_with_grass", "default:dirt", -2}
  68. },
  69. fear_height = 3,
  70. on_replace = function(self, pos, oldnode, newnode)
  71. self.food = (self.food or 0) + 1
  72. -- if sheep replaces 8x grass then it regrows wool
  73. if self.food >= 8 then
  74. self.food = 0
  75. self.gotten = false
  76. self.object:set_properties({
  77. textures = {"mobs_sheep_base.png^(mobs_sheep_wool.png^[colorize:" .. col[3] .. ")"},
  78. mesh = "mobs_sheep.b3d",
  79. })
  80. end
  81. end,
  82. on_rightclick = function(self, clicker)
  83. --are we feeding?
  84. if mobs:feed_tame(self, clicker, 8, true, true) then
  85. --if fed 7x grass or wheat then sheep regrows wool
  86. if self.food and self.food > 6 then
  87. self.gotten = false
  88. self.object:set_properties({
  89. textures = {"mobs_sheep_base.png^(mobs_sheep_wool.png^[colorize:" .. col[3] .. ")"},
  90. mesh = "mobs_sheep.b3d",
  91. })
  92. end
  93. return
  94. end
  95. local item = clicker:get_wielded_item()
  96. local itemname = item:get_name()
  97. local name = clicker:get_player_name()
  98. --are we giving a haircut>
  99. if itemname == "mobs:shears" then
  100. if self.gotten ~= false
  101. or self.child ~= false
  102. or name ~= self.owner
  103. or not minetest.get_modpath("wool") then
  104. return
  105. end
  106. self.gotten = true -- shaved
  107. local obj = minetest.add_item(
  108. self.object:get_pos(),
  109. ItemStack( "wool:" .. col[1] .. " " .. math.random(1, 3) )
  110. )
  111. if obj then
  112. obj:setvelocity({
  113. x = math.random(-1, 1),
  114. y = 5,
  115. z = math.random(-1, 1)
  116. })
  117. end
  118. item:add_wear(650) -- 100 uses
  119. clicker:set_wielded_item(item)
  120. self.object:set_properties({
  121. textures = {"mobs_sheep_shaved.png"},
  122. mesh = "mobs_sheep_shaved.b3d",
  123. })
  124. return
  125. end
  126. --are we coloring?
  127. if itemname:find("dye:") then
  128. if self.gotten == false
  129. and self.child == false
  130. and self.tamed == true
  131. and name == self.owner then
  132. local colr = string.split(itemname, ":")[2]
  133. for _,c in pairs(all_colours) do
  134. if c[1] == colr then
  135. local pos = self.object:get_pos()
  136. self.object:remove()
  137. local mob = minetest.add_entity(pos, "mobs_animal:sheep_" .. colr)
  138. local ent = mob:get_luaentity()
  139. ent.owner = name
  140. ent.tamed = true
  141. -- take item
  142. if not mobs.is_creative(clicker:get_player_name()) then
  143. item:take_item()
  144. clicker:set_wielded_item(item)
  145. end
  146. break
  147. end
  148. end
  149. end
  150. return
  151. end
  152. -- protect mod with mobs:protector item
  153. if mobs:protect(self, clicker) then return end
  154. --are we capturing?
  155. if mobs:capture_mob(self, clicker, 0, 5, 60, false, nil) then return end
  156. end
  157. })
  158. mobs:register_egg("mobs_animal:sheep_"..col[1], S("@1 Sheep", col[2]), "wool_"..col[1]..".png^mobs_sheep_inv.png")
  159. -- compatibility
  160. mobs:alias_mob("mobs:sheep_" .. col[1], "mobs_animal:sheep_" .. col[1])
  161. end
  162. mobs:spawn({
  163. name = "mobs_animal:sheep_white",
  164. nodes = {"default:dirt_with_grass", "ethereal:green_dirt"},
  165. neighbors = {"group:grass"},
  166. min_light = 14,
  167. interval = 60,
  168. chance = 8000, -- 15000
  169. min_height = 0,
  170. max_height = 200,
  171. day_toggle = true,
  172. })
  173. mobs:alias_mob("mobs:sheep", "mobs_animal:sheep_white") -- compatibility
  174. -- raw mutton
  175. minetest.register_craftitem(":mobs:mutton_raw", {
  176. description = S("Raw Mutton"),
  177. inventory_image = "mobs_mutton_raw.png",
  178. on_use = minetest.item_eat(2),
  179. groups = {food_meat_raw = 1, food_mutton_raw = 1, flammable = 2},
  180. })
  181. -- cooked mutton
  182. minetest.register_craftitem(":mobs:mutton_cooked", {
  183. description = S("Cooked Mutton"),
  184. inventory_image = "mobs_mutton_cooked.png",
  185. on_use = minetest.item_eat(6),
  186. groups = {food_meat = 1, food_mutton = 1, flammable = 2},
  187. })
  188. minetest.register_craft({
  189. type = "cooking",
  190. output = "mobs:mutton_cooked",
  191. recipe = "mobs:mutton_raw",
  192. cooktime = 5,
  193. })