hemp.lua 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. local S = farming.translate
  2. -- hemp seeds
  3. minetest.register_node("farming:seed_hemp", {
  4. description = S("Hemp Seed"),
  5. tiles = {"farming_hemp_seed.png"},
  6. inventory_image = "farming_hemp_seed.png",
  7. wield_image = "farming_hemp_seed.png",
  8. drawtype = "signlike",
  9. groups = {compostability = 38, seed = 1, snappy = 3, attached_node = 1, growing = 1},
  10. paramtype = "light",
  11. paramtype2 = "wallmounted",
  12. walkable = false,
  13. sunlight_propagates = true,
  14. selection_box = farming.select,
  15. next_plant = "farming:hemp_1",
  16. on_place = function(itemstack, placer, pointed_thing)
  17. return farming.place_seed(itemstack, placer, pointed_thing, "farming:seed_hemp")
  18. end
  19. })
  20. -- harvested hemp
  21. minetest.register_craftitem("farming:hemp_leaf", {
  22. description = S("Hemp Leaf"),
  23. inventory_image = "farming_hemp_leaf.png",
  24. groups = {compostability = 35}
  25. })
  26. -- hemp oil
  27. minetest.register_node("farming:hemp_oil", {
  28. description = S("Bottle of Hemp Oil"),
  29. drawtype = "plantlike",
  30. tiles = {"farming_hemp_oil.png"},
  31. inventory_image = "farming_hemp_oil.png",
  32. wield_image = "farming_hemp_oil.png",
  33. paramtype = "light",
  34. is_ground_content = false,
  35. walkable = false,
  36. selection_box = {
  37. type = "fixed",
  38. fixed = {-0.25, -0.5, -0.25, 0.25, 0.3, 0.25}
  39. },
  40. groups = {compostability = 45, food_oil = 1, vessel = 1, dig_immediate = 3, attached_node = 1},
  41. sounds = farming.sounds.node_sound_glass_defaults()
  42. })
  43. minetest.register_craft( {
  44. output = "farming:hemp_oil",
  45. recipe = {
  46. {"farming:hemp_leaf", "farming:hemp_leaf", "farming:hemp_leaf"},
  47. {"farming:hemp_leaf", "farming:hemp_leaf", "farming:hemp_leaf"},
  48. {"", "vessels:glass_bottle", ""}
  49. }
  50. })
  51. minetest.register_craft( {
  52. output = "farming:hemp_oil",
  53. recipe = {
  54. {"farming:seed_hemp", "farming:seed_hemp", "farming:seed_hemp"},
  55. {"farming:seed_hemp", "farming:seed_hemp", "farming:seed_hemp"},
  56. {"farming:seed_hemp", "vessels:glass_bottle", "farming:seed_hemp"}
  57. }
  58. })
  59. minetest.register_craft({
  60. type = "fuel",
  61. recipe = "farming:hemp_oil",
  62. burntime = 20,
  63. replacements = {{"farming:hemp_oil", "vessels:glass_bottle"}}
  64. })
  65. -- hemp fibre
  66. minetest.register_craftitem("farming:hemp_fibre", {
  67. description = S("Hemp Fibre"),
  68. inventory_image = "farming_hemp_fibre.png",
  69. groups = {compostability = 55}
  70. })
  71. minetest.register_craft( {
  72. output = "farming:hemp_fibre 8",
  73. recipe = {
  74. {"farming:hemp_leaf", "farming:hemp_leaf", "farming:hemp_leaf"},
  75. {"farming:hemp_leaf", "group:water_bucket", "farming:hemp_leaf"},
  76. {"farming:hemp_leaf", "farming:hemp_leaf", "farming:hemp_leaf"}
  77. },
  78. replacements = {{"group:water_bucket", "bucket:bucket_empty"}}
  79. })
  80. if minetest.get_modpath("bucket_wooden") then
  81. minetest.register_craft( {
  82. output = "farming:hemp_fibre 8",
  83. recipe = {
  84. {"farming:hemp_leaf", "farming:hemp_leaf", "farming:hemp_leaf"},
  85. {"farming:hemp_leaf", "group:water_bucket_wooden", "farming:hemp_leaf"},
  86. {"farming:hemp_leaf", "farming:hemp_leaf", "farming:hemp_leaf"}
  87. },
  88. replacements = {{"group:water_bucket_wooden", "bucket_wooden:bucket_empty"}}
  89. })
  90. end
  91. -- hemp block
  92. minetest.register_node("farming:hemp_block", {
  93. description = S("Hemp Block"),
  94. tiles = {"farming_hemp_block.png"},
  95. paramtype = "light",
  96. groups = {handy = 1, snappy = 2, oddly_breakable_by_hand = 1, flammable = 2, compostability = 85},
  97. sounds = farming.sounds.node_sound_leaves_defaults()
  98. })
  99. minetest.register_craft( {
  100. output = "farming:hemp_block",
  101. recipe = {
  102. {"farming:hemp_fibre", "farming:hemp_fibre", "farming:hemp_fibre"},
  103. {"farming:hemp_fibre", "farming:hemp_fibre", "farming:hemp_fibre"},
  104. {"farming:hemp_fibre", "farming:hemp_fibre", "farming:hemp_fibre"}
  105. }
  106. })
  107. -- check and register stairs
  108. if minetest.global_exists("stairs") then
  109. if stairs.mod and stairs.mod == "redo" then
  110. stairs.register_all("hemp_block", "farming:hemp_block",
  111. {snappy = 2, oddly_breakable_by_hand = 1, flammable = 2},
  112. {"farming_hemp_block.png"},
  113. "Hemp Block",
  114. farming.sounds.node_sound_leaves_defaults())
  115. else
  116. stairs.register_stair_and_slab("hemp_block", "farming:hemp_block",
  117. {snappy = 2, oddly_breakable_by_hand = 1, flammable = 2},
  118. {"farming_hemp_block.png"},
  119. "Hemp Block Stair",
  120. "Hemp Block Slab",
  121. farming.sounds.node_sound_leaves_defaults())
  122. end
  123. end
  124. -- paper
  125. minetest.register_craft( {
  126. output = "default:paper 3",
  127. recipe = {
  128. {"farming:hemp_fibre", "farming:hemp_fibre", "farming:hemp_fibre"}
  129. }
  130. })
  131. -- string
  132. minetest.register_craft( {
  133. output = "farming:cotton 3",
  134. recipe = {
  135. {"farming:hemp_fibre"},
  136. {"farming:hemp_fibre"},
  137. {"farming:hemp_fibre"}
  138. }
  139. })
  140. -- hemp rope
  141. minetest.register_node("farming:hemp_rope", {
  142. description = S("Hemp Rope"),
  143. walkable = false,
  144. climbable = true,
  145. sunlight_propagates = true,
  146. paramtype = "light",
  147. tiles = {"farming_hemp_rope.png"},
  148. wield_image = "farming_hemp_rope.png",
  149. inventory_image = "farming_hemp_rope.png",
  150. drawtype = "plantlike",
  151. groups = {flammable = 2, choppy = 3, oddly_breakable_by_hand = 3, compostability = 55},
  152. sounds = farming.sounds.node_sound_leaves_defaults(),
  153. selection_box = {
  154. type = "fixed",
  155. fixed = {-1/7, -1/2, -1/7, 1/7, 1/2, 1/7}
  156. }
  157. })
  158. -- string
  159. minetest.register_craft( {
  160. output = "farming:hemp_rope 6",
  161. recipe = {
  162. {"farming:hemp_fibre", "farming:hemp_fibre", "farming:hemp_fibre"},
  163. {"farming:cotton", "farming:cotton", "farming:cotton"},
  164. {"farming:hemp_fibre", "farming:hemp_fibre", "farming:hemp_fibre"}
  165. }
  166. })
  167. -- hemp definition
  168. local def = {
  169. drawtype = "plantlike",
  170. tiles = {"farming_hemp_1.png"},
  171. paramtype = "light",
  172. sunlight_propagates = true,
  173. walkable = false,
  174. buildable_to = true,
  175. drop = "",
  176. waving = 1,
  177. selection_box = farming.select,
  178. groups = {
  179. handy = 1, snappy = 3, flammable = 2, plant = 1, attached_node = 1,
  180. not_in_creative_inventory = 1, growing = 1
  181. },
  182. sounds = farming.sounds.node_sound_leaves_defaults()
  183. }
  184. -- stage 1
  185. minetest.register_node("farming:hemp_1", table.copy(def))
  186. -- stage 2
  187. def.tiles = {"farming_hemp_2.png"}
  188. minetest.register_node("farming:hemp_2", table.copy(def))
  189. -- stage 3
  190. def.tiles = {"farming_hemp_3.png"}
  191. minetest.register_node("farming:hemp_3", table.copy(def))
  192. -- stage 4
  193. def.tiles = {"farming_hemp_4.png"}
  194. minetest.register_node("farming:hemp_4", table.copy(def))
  195. -- stage 5
  196. def.tiles = {"farming_hemp_5.png"}
  197. minetest.register_node("farming:hemp_5", table.copy(def))
  198. -- stage 6
  199. def.tiles = {"farming_hemp_6.png"}
  200. def.drop = {
  201. items = {
  202. {items = {"farming:hemp_leaf"}, rarity = 2},
  203. {items = {"farming:seed_hemp"}, rarity = 1}
  204. }
  205. }
  206. minetest.register_node("farming:hemp_6", table.copy(def))
  207. -- stage 7
  208. def.tiles = {"farming_hemp_7.png"}
  209. def.drop = {
  210. items = {
  211. {items = {"farming:hemp_leaf"}, rarity = 1},
  212. {items = {"farming:hemp_leaf"}, rarity = 3},
  213. {items = {"farming:seed_hemp"}, rarity = 1},
  214. {items = {"farming:seed_hemp"}, rarity = 3}
  215. }
  216. }
  217. minetest.register_node("farming:hemp_7", table.copy(def))
  218. -- stage 8 (final)
  219. def.tiles = {"farming_hemp_8.png"}
  220. def.groups.growing = nil
  221. def.selection_box = farming.select_final
  222. def.drop = {
  223. items = {
  224. {items = {"farming:hemp_leaf 2"}, rarity = 1},
  225. {items = {"farming:hemp_leaf"}, rarity = 2},
  226. {items = {"farming:seed_hemp"}, rarity = 1},
  227. {items = {"farming:seed_hemp"}, rarity = 2}
  228. }
  229. }
  230. minetest.register_node("farming:hemp_8", table.copy(def))
  231. -- add to registered_plants
  232. farming.registered_plants["farming:hemp"] = {
  233. crop = "farming:hemp",
  234. seed = "farming:seed_hemp",
  235. minlight = farming.min_light,
  236. maxlight = farming.max_light,
  237. steps = 8
  238. }
  239. -- mapgen
  240. minetest.register_decoration({
  241. deco_type = "simple",
  242. place_on = {"mcl_core:dirt_with_grass, default:dirt_with_grass", "default:dirt_with_rainforest_litter"},
  243. sidelen = 16,
  244. noise_params = {
  245. offset = 0,
  246. scale = farming.hemp,
  247. spread = {x = 100, y = 100, z = 100},
  248. seed = 420,
  249. octaves = 3,
  250. persist = 0.6
  251. },
  252. y_min = 3,
  253. y_max = 45,
  254. decoration = "farming:hemp_7",
  255. spawn_by = "group:tree",
  256. num_spawn_by = 1
  257. })