forked from PilzAdam/farming_plus
-
Notifications
You must be signed in to change notification settings - Fork 1
/
cherries.lua
106 lines (95 loc) · 3.51 KB
/
cherries.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
-- 'farming_plus' farming mod for Minetest.
-- Copyright (C) 2017 PilzAdam, Wade Cline
--
-- This library is free software; you can redistribute it and/or
-- modify it under the terms of the GNU Lesser General Public
-- License as published by the Free Software Foundation; either
-- version 2.1 of the License, or (at your option) any later version.
--
-- This library is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-- Lesser General Public License for more details.
--
-- You should have received a copy of the GNU Lesser General Public
-- License along with this library; if not, write to the Free Software
-- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-- main `S` code in init.lua
local S
S = farming_plus.S
----
minetest.register_node("farming_plus:cherry_sapling", {
description = S("Cherry Tree Sapling"),
drawtype = "plantlike",
tiles = {"farming_plus_cherry_sapling.png"},
inventory_image = "farming_plus_cherry_sapling.png",
wield_image = "farming_plus_cherry_sapling.png",
paramtype = "light",
walkable = false,
selection_box = {
type = "fixed",
fixed = {-0.3, -0.5, -0.3, 0.3, 0.35, 0.3}
},
groups = {snappy = 2, dig_immediate=3, flammable=2, attached_node = 1,
sapling = 1},
sounds = default.node_sound_defaults(),
on_timer = function(pos, node)
farming_plus.generate_tree(pos, "farming_plus:cherry_tree", "farming_plus:cherry_leaves", {"default:dirt", "default:dirt_with_grass"}, "farming_plus:cherry", 5, false)
end,
on_construct = farming_plus.tree_on_construct
})
local cherry_tree = table.copy(minetest.registered_nodes["default:tree"])
cherry_tree.description = "Cherry Tree"
cherry_tree.drop = "default:tree"
minetest.register_node("farming_plus:cherry_tree", cherry_tree)
local cherry_leaves = table.copy(minetest.registered_nodes["default:leaves"])
cherry_leaves.description = "Cherry Leaves"
cherry_leaves.drop = {
max_items = 1,
items = {
{
items = {"farming_plus:cherry_sapling"},
rarity = 20,
},
{
items = {"default:leaves"},
}
}
}
minetest.register_node("farming_plus:cherry_leaves", cherry_leaves)
minetest.register_node("farming_plus:cherry", {
description = S("Cherry"),
tiles = {"farming_plus_cherry.png"},
inventory_image = "farming_plus_cherry.png",
wield_image = "farming_plus_cherry.png",
drawtype = "plantlike",
paramtype = "light",
sunlight_propagates = true,
walkable = false,
groups = {fleshy=3,dig_immediate=3,flammable=2,leafdecay=3,leafdecay_drop=1},
sounds = default.node_sound_defaults(),
on_use = minetest.item_eat(2),
})
default.register_leafdecay({
trunks = {"farming_plus:cherry_tree"},
leaves = {"farming_plus:cherry_leaves", "farming_plus:cherry", "default:leaves"},
radius = 2,
})
farming_plus.add_tree("cherry",
function(minp, maxp, blockseed)
local tmp = {x=(maxp.x-minp.x)/2+minp.x, y=(maxp.y-minp.y)/2+minp.y, z=(maxp.z-minp.z)/2+minp.z}
-- See corresponding function in 'bananas.lua'
local forest = minetest.find_node_near(tmp, maxp.x-minp.x, {"default:tree"})
if forest == nil then
return nil
end
local node = minetest.find_node_near(tmp, maxp.x-minp.x, {"default:dirt_with_grass"})
if node == nil then
return nil
end
local pos = {x=node.x, y=node.y+1, z=node.z}
farming_plus.generate_tree(pos, "farming_plus:cherry_tree", "farming_plus:cherry_leaves", {"default:dirt", "default:dirt_with_grass"}, "farming_plus:cherry", 10, true)
return pos
end,
3
)