carrot.lua 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. --[[
  2. Original textures from PixelBox texture pack
  3. https://forum.minetest.net/viewtopic.php?id=4990
  4. ]]
  5. local S = farming.translate
  6. -- carrot
  7. minetest.register_craftitem("farming:carrot", {
  8. description = S("Carrot"),
  9. inventory_image = "farming_carrot.png",
  10. groups = {compostability = 48, seed = 2, food_carrot = 1, flammable = 2},
  11. on_place = function(itemstack, placer, pointed_thing)
  12. return farming.place_seed(itemstack, placer, pointed_thing, "farming:carrot_1")
  13. end,
  14. on_use = minetest.item_eat(4)
  15. })
  16. -- carrot juice
  17. minetest.register_craftitem("farming:carrot_juice", {
  18. description = S("Carrot Juice"),
  19. inventory_image = "farming_carrot_juice.png",
  20. on_use = minetest.item_eat(4, "vessels:drinking_glass"),
  21. groups = {vessel = 1, drink = 1}
  22. })
  23. local tmp = farming.use_utensils and "farming:juicer" or ""
  24. minetest.register_craft({
  25. output = "farming:carrot_juice",
  26. recipe = {
  27. {tmp},
  28. {"group:food_carrot"},
  29. {"vessels:drinking_glass"}
  30. },
  31. replacements = {
  32. {"group:food_juicer", "farming:juicer"}
  33. }
  34. })
  35. -- golden carrot
  36. minetest.register_craftitem("farming:carrot_gold", {
  37. description = S("Golden Carrot"),
  38. inventory_image = "farming_carrot_gold.png",
  39. on_use = minetest.item_eat(10)
  40. })
  41. minetest.register_craft({
  42. output = "farming:carrot_gold",
  43. recipe = {{"group:food_carrot", "default:gold_lump"}}
  44. })
  45. -- carrot definition
  46. local def = {
  47. drawtype = "plantlike",
  48. tiles = {"farming_carrot_1.png"},
  49. paramtype = "light",
  50. sunlight_propagates = true,
  51. walkable = false,
  52. buildable_to = true,
  53. drop = "",
  54. waving = 1,
  55. selection_box = farming.select,
  56. groups = {
  57. handy = 1, snappy = 3, flammable = 2, plant = 1, attached_node = 1,
  58. not_in_creative_inventory = 1, growing = 1
  59. },
  60. sounds = farming.sounds.node_sound_leaves_defaults()
  61. }
  62. -- stage 1
  63. minetest.register_node("farming:carrot_1", table.copy(def))
  64. -- stage 2
  65. def.tiles = {"farming_carrot_2.png"}
  66. minetest.register_node("farming:carrot_2", table.copy(def))
  67. -- stage 3
  68. def.tiles = {"farming_carrot_3.png"}
  69. minetest.register_node("farming:carrot_3", table.copy(def))
  70. -- stage 4
  71. def.tiles = {"farming_carrot_4.png"}
  72. minetest.register_node("farming:carrot_4", table.copy(def))
  73. -- stage 5
  74. def.tiles = {"farming_carrot_5.png"}
  75. minetest.register_node("farming:carrot_5", table.copy(def))
  76. -- stage 6
  77. def.tiles = {"farming_carrot_6.png"}
  78. minetest.register_node("farming:carrot_6", table.copy(def))
  79. -- stage 7
  80. def.tiles = {"farming_carrot_7.png"}
  81. def.drop = {
  82. items = {
  83. {items = {"farming:carrot"}, rarity = 1},
  84. {items = {"farming:carrot 2"}, rarity = 3}
  85. }
  86. }
  87. minetest.register_node("farming:carrot_7", table.copy(def))
  88. -- stage 8 (final)
  89. def.tiles = {"farming_carrot_8.png"}
  90. def.groups.growing = nil
  91. def.selection_box = farming.select_final
  92. def.drop = {
  93. items = {
  94. {items = {"farming:carrot 2"}, rarity = 1},
  95. {items = {"farming:carrot 3"}, rarity = 2}
  96. }
  97. }
  98. minetest.register_node("farming:carrot_8", table.copy(def))
  99. -- add to registered_plants
  100. farming.registered_plants["farming:carrot"] = {
  101. crop = "farming:carrot",
  102. seed = "farming:carrot",
  103. minlight = farming.min_light,
  104. maxlight = farming.max_light,
  105. steps = 8
  106. }
  107. -- mapgen
  108. local mg = farming.mapgen == "v6"
  109. def = {
  110. y_max = mg and 30 or 20,
  111. near = mg and "group:water" or nil,
  112. num = mg and 1 or -1,
  113. }
  114. minetest.register_decoration({
  115. deco_type = "simple",
  116. place_on = {"mcl_core:dirt_with_grass, default:dirt_with_grass"},
  117. sidelen = 16,
  118. noise_params = {
  119. offset = 0,
  120. scale = farming.carrot,
  121. spread = {x = 100, y = 100, z = 100},
  122. seed = 890,
  123. octaves = 3,
  124. persist = 0.6
  125. },
  126. y_min = 1,
  127. y_max = def.y_max,
  128. decoration = "farming:carrot_8",
  129. spawn_by = def.near,
  130. num_spawn_by = def.num
  131. })