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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
|
-- Code of rubber tree by PilzAdam
minetest.register_node("technic:rubber_sapling", {
description = "Rubber Tree Sapling",
drawtype = "plantlike",
tiles = {"technic_rubber_sapling.png"},
inventory_image = "technic_rubber_sapling.png",
wield_image = "technic_rubber_sapling.png",
paramtype = "light",
walkable = false,
groups = {dig_immediate=3,flammable=2},
sounds = default.node_sound_defaults(),
})
minetest.register_node("technic:rubber_tree_full", {
description = "Rubber Tree",
tiles = {"default_tree_top.png", "default_tree_top.png", "technic_rubber_tree_full.png"},
groups = {tree=1,snappy=1,choppy=2,oddly_breakable_by_hand=1,flammable=2},
drop = "default:tree",
sounds = default.node_sound_wood_defaults(),
on_dig = function(pos, node, digger)
minetest.node_dig(pos, node, digger)
minetest.env:remove_node(pos)
end,
after_destruct = function(pos, oldnode)
oldnode.name = "technic:rubber_tree_empty"
minetest.env:set_node(pos, oldnode)
end
})
minetest.register_node("technic:rubber_tree_empty", {
tiles = {"default_tree_top.png", "default_tree_top.png", "technic_rubber_tree_empty.png"},
groups = {tree=1,snappy=1,choppy=2,oddly_breakable_by_hand=1,flammable=2, not_in_creative_inventory=1},
drop = "default:tree",
sounds = default.node_sound_wood_defaults(),
})
minetest.register_abm({
nodenames = {"technic:rubber_tree_empty"},
interval = 60,
chance = 15,
action = function(pos, node)
node.name = "technic:rubber_tree_full"
minetest.env:set_node(pos, node)
end
})
minetest.register_node("technic:rubber_leaves", {
drawtype = "allfaces_optional",
visual_scale = 1.3,
tiles = {"default_leaves.png"},
paramtype = "light",
groups = {snappy=3, leafdecay=3, flammable=2, not_in_creative_inventory=1},
drop = {
max_items = 1,
items = {
{
items = {'technic:rubber_sapling'},
rarity = 20,
},
}
},
sounds = default.node_sound_leaves_defaults(),
})
minetest.register_abm({
nodenames = {"technic:rubber_sapling"},
interval = 60,
chance = 20,
action = function(pos, node)
generate_tree(pos, "technic:rubber_tree_full", "technic:rubber_leaves", {"default:dirt", "default:dirt_with_grass"})
end
})
minetest.register_on_generated(function(minp, maxp, blockseed)
if math.random(1, 100) > 5 then
return
end
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}
local pos = minetest.env:find_node_near(tmp, maxp.x-minp.x, {"default:dirt_with_grass"})
if pos ~= nil then
generate_tree({x=pos.x, y=pos.y+1, z=pos.z}, "technic:rubber_tree_full", "technic:rubber_leaves", {"default:dirt", "default:dirt_with_grass"})
end
end)
-- ========= FUEL =========
minetest.register_craft({
type = "fuel",
recipe = "technic:rubber_sapling",
burntime = 10
})
function generate_tree(pos, trunk, leaves, underground, replacements)
pos.y = pos.y-1
local nodename = minetest.env:get_node(pos).name
local ret = true
for _,name in ipairs(underground) do
if nodename == name then
ret = false
break
end
end
pos.y = pos.y+1
if ret or minetest.env:get_node_light(pos) < 8 then
return
end
node = {name = ""}
for dy=1,4 do
pos.y = pos.y+dy
if minetest.env:get_node(pos).name ~= "air" then
return
end
pos.y = pos.y-dy
end
node.name = trunk
for dy=0,4 do
pos.y = pos.y+dy
minetest.env:set_node(pos, node)
pos.y = pos.y-dy
end
if not replacements then
replacements = {}
end
node.name = leaves
pos.y = pos.y+3
for dx=-2,2 do
for dz=-2,2 do
for dy=0,3 do
pos.x = pos.x+dx
pos.y = pos.y+dy
pos.z = pos.z+dz
if dx == 0 and dz == 0 and dy==3 then
if minetest.env:get_node(pos).name == "air" and math.random(1, 5) <= 4 then
minetest.env:set_node(pos, node)
for name,rarity in pairs(replacements) do
if math.random(1, rarity) == 1 then
minetest.env:set_node(pos, {name=name})
end
end
end
elseif dx == 0 and dz == 0 and dy==4 then
if minetest.env:get_node(pos).name == "air" and math.random(1, 5) <= 4 then
minetest.env:set_node(pos, node)
for name,rarity in pairs(replacements) do
if math.random(1, rarity) == 1 then
minetest.env:set_node(pos, {name=name})
end
end
end
elseif math.abs(dx) ~= 2 and math.abs(dz) ~= 2 then
if minetest.env:get_node(pos).name == "air" then
minetest.env:set_node(pos, node)
for name,rarity in pairs(replacements) do
if math.random(1, rarity) == 1 then
minetest.env:set_node(pos, {name=name})
end
end
end
else
if math.abs(dx) ~= 2 or math.abs(dz) ~= 2 then
if minetest.env:get_node(pos).name == "air" and math.random(1, 5) <= 4 then
minetest.env:set_node(pos, node)
for name,rarity in pairs(replacements) do
if math.random(1, rarity) == 1 then
minetest.env:set_node(pos, {name=name})
end
end
end
end
end
pos.x = pos.x-dx
pos.y = pos.y-dy
pos.z = pos.z-dz
end
end
end
end
|