coffee.lua 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. local S = farming.translate
  2. -- coffee
  3. minetest.register_craftitem("farming:coffee_beans", {
  4. description = S("Coffee Beans"),
  5. inventory_image = "farming_coffee_beans.png",
  6. groups = {compostability = 48, seed = 2, food_coffee = 1, flammable = 2},
  7. on_place = function(itemstack, placer, pointed_thing)
  8. return farming.place_seed(itemstack, placer, pointed_thing, "farming:coffee_1")
  9. end
  10. })
  11. -- cup of coffee
  12. minetest.register_node("farming:coffee_cup", {
  13. description = S("Cup of Coffee"),
  14. drawtype = "torchlike",
  15. tiles = {"farming_coffee_cup.png"},
  16. inventory_image = "farming_coffee_cup.png",
  17. wield_image = "farming_coffee_cup.png",
  18. paramtype = "light",
  19. walkable = false,
  20. selection_box = {
  21. type = "fixed",
  22. fixed = {-0.25, -0.5, -0.25, 0.25, 0.25, 0.25}
  23. },
  24. groups = {vessel = 1, dig_immediate = 3, attached_node = 1, drink = 1},
  25. on_use = minetest.item_eat(2, "vessels:drinking_glass"),
  26. sounds = farming.sounds.node_sound_glass_defaults()
  27. })
  28. minetest.register_alias("farming:coffee_cup_hot", "farming:coffee_cup")
  29. minetest.register_alias("farming:drinking_cup", "vessels:drinking_glass")
  30. local tmp = farming.use_utensils and "farming:saucepan" or ""
  31. minetest.register_craft( {
  32. output = "farming:coffee_cup",
  33. recipe = {
  34. {"group:food_coffee", "group:food_water_glass", tmp}
  35. },
  36. replacements = {
  37. {"group:food_saucepan", "farming:saucepan"}
  38. }
  39. })
  40. -- coffee definition
  41. local def = {
  42. drawtype = "plantlike",
  43. tiles = {"farming_coffee_1.png"},
  44. paramtype = "light",
  45. sunlight_propagates = true,
  46. walkable = false,
  47. buildable_to = true,
  48. drop = "",
  49. waving = 1,
  50. selection_box = farming.select,
  51. groups = {
  52. handy = 1, snappy = 3, flammable = 2, plant = 1, attached_node = 1,
  53. not_in_creative_inventory = 1, growing = 1
  54. },
  55. sounds = farming.sounds.node_sound_leaves_defaults()
  56. }
  57. -- stage 1
  58. minetest.register_node("farming:coffee_1", table.copy(def))
  59. -- stage 2
  60. def.tiles = {"farming_coffee_2.png"}
  61. minetest.register_node("farming:coffee_2", table.copy(def))
  62. -- stage 3
  63. def.tiles = {"farming_coffee_3.png"}
  64. minetest.register_node("farming:coffee_3", table.copy(def))
  65. -- stage 4
  66. def.tiles = {"farming_coffee_4.png"}
  67. minetest.register_node("farming:coffee_4", table.copy(def))
  68. -- stage 5 (final)
  69. def.tiles = {"farming_coffee_5.png"}
  70. def.groups.growing = nil
  71. def.selection_box = farming.select_final
  72. def.drop = {
  73. items = {
  74. {items = {"farming:coffee_beans 2"}, rarity = 1},
  75. {items = {"farming:coffee_beans 2"}, rarity = 2},
  76. {items = {"farming:coffee_beans 2"}, rarity = 3}
  77. }
  78. }
  79. minetest.register_node("farming:coffee_5", table.copy(def))
  80. -- add to registered_plants
  81. farming.registered_plants["farming:coffee"] = {
  82. crop = "farming:coffee",
  83. seed = "farming:coffee_beans",
  84. minlight = farming.min_light,
  85. maxlight = farming.max_light,
  86. steps = 5
  87. }
  88. -- mapgen
  89. local mg = farming.mapgen == "v6"
  90. def = {
  91. y_max = mg and 50 or 55,
  92. spawn_on = mg and {"default:dirt_with_grass"} or {"default:dirt_with_dry_grass",
  93. "default:dirt_with_rainforest_litter", "default:dry_dirt_with_dry_grass"}
  94. }
  95. minetest.register_decoration({
  96. deco_type = "simple",
  97. place_on = def.spawn_on,
  98. sidelen = 16,
  99. noise_params = {
  100. offset = 0,
  101. scale = farming.coffee,
  102. spread = {x = 100, y = 100, z = 100},
  103. seed = 12,
  104. octaves = 3,
  105. persist = 0.6
  106. },
  107. y_min = 20,
  108. y_max = def.y_max,
  109. decoration = "farming:coffee_5"
  110. })