-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcowberries.lua
145 lines (124 loc) · 4.4 KB
/
cowberries.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
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
local S = minetest.get_translator("ebiomes")
--from runs cooltrees
local modname = "ebiomes"
local modpath = minetest.get_modpath(modname)
local mg_name = minetest.get_mapgen_setting("mg_name")
-- Aliases
minetest.register_alias("cowberry_bush_leaves", "ebiomes:cowberry_bush_leaves")
minetest.register_alias("cowberry_bush_leaves", "ebiomes:cowberry_bush_leaves_with_berries")
minetest.register_alias("cowberry_bush_sapling", "ebiomes:cowberry_bush_sapling")
minetest.register_alias("cowberries", "ebiomes:cowberries")
-- Cowberry
local function grow_new_cowberry(pos)
if not default.can_grow(pos) then
-- try a bit later again
minetest.get_node_timer(pos):start(math.random(150, 300))
return
end
minetest.remove_node(pos)
minetest.place_schematic({x = pos.x, y = pos.y, z = pos.z}, modpath.."/schematics/ebiomes_cowberry_bush.mts", "0", nil, false)
end
minetest.register_craftitem("ebiomes:cowberries", {
description = S("Cowberries"),
inventory_image = "ebiomes_cowberries.png",
groups = {food_cowberries = 1, food_berry = 1, eatable = 2},
on_use = minetest.item_eat(2),
})
minetest.register_node("ebiomes:cowberry_bush_leaves_with_berries", {
description = S("Cowberry Bush Leaves with Berries"),
drawtype = "allfaces_optional",
tiles = {"ebiomes_cowberry_bush_leaves.png^ebiomes_cowberry_overlay.png"},
paramtype = "light",
groups = {snappy = 3, flammable = 2, leaves = 1, dig_immediate = 3},
walkable = false,
drop = "ebiomes:cowberries",
sounds = default.node_sound_leaves_defaults(),
node_dig_prediction = "ebiomes:cowberry_bush_leaves",
after_dig_node = function(pos, oldnode, oldmetadata, digger)
minetest.set_node(pos, {name = "ebiomes:cowberry_bush_leaves"})
minetest.get_node_timer(pos):start(math.random(300, 1500))
end,
})
minetest.register_node("ebiomes:cowberry_bush_leaves", {
description = S("Cowberry Bush Leaves"),
drawtype = "allfaces_optional",
tiles = {"ebiomes_cowberry_bush_leaves.png"},
paramtype = "light",
groups = {snappy = 3, flammable = 2, leaves = 1},
walkable = false,
drop = {
max_items = 1,
items = {
{items = {"ebiomes:cowberry_bush_sapling"}, rarity = 5},
{items = {"ebiomes:cowberry_bush_leaves"}}
}
},
sounds = default.node_sound_leaves_defaults(),
on_timer = function(pos, elapsed)
if minetest.get_node_light(pos) < 11 then
minetest.get_node_timer(pos):start(200)
else
minetest.set_node(pos, {name = "ebiomes:cowberry_bush_leaves_with_berries"})
end
end,
after_place_node = default.after_place_leaves,
})
minetest.register_node("ebiomes:cowberry_bush_sapling", {
description = S("Cowberry Bush Sapling"),
drawtype = "plantlike",
tiles = {"ebiomes_cowberry_bush_sapling.png"},
inventory_image = "ebiomes_cowberry_bush_sapling.png",
wield_image = "ebiomes_cowberry_bush_sapling.png",
paramtype = "light",
sunlight_propagates = true,
walkable = false,
on_timer = grow_new_cowberry,
selection_box = {
type = "fixed",
fixed = {-2 / 16, -0.5, -2 / 16, 2 / 16, -1 / 16, 2 / 16}
},
groups = {snappy = 2, dig_immediate = 3, flammable = 2,
attached_node = 1, sapling = 1},
sounds = default.node_sound_leaves_defaults(),
on_construct = function(pos)
minetest.get_node_timer(pos):start(math.random(300, 1500))
end,
on_place = function(itemstack, placer, pointed_thing)
itemstack = default.sapling_on_place(itemstack, placer, pointed_thing,
"ebiomes:cowberry_bush_sapling",
-- minp, maxp to be checked, relative to sapling pos
{x = -1, y = 0, z = -1},
{x = 1, y = 1, z = 1},
-- maximum interval of interior volume check
2)
return itemstack
end,
})
minetest.register_decoration({
name = "ebiomes:cowberry_bush",
deco_type = "schematic",
place_on = {"default:dirt_with_snow", "default:permafrost_with_moss"},
sidelen = 16,
noise_params = {
offset = -0.004,
scale = 0.01,
spread = {x = 100, y = 100, z = 100},
seed = 697,
octaves = 3,
persist = 0.7,
},
biomes = {"taiga", "snowy_grassland", "tundra"},
y_max = 31000,
y_min = 1,
place_offset_y = 1,
schematic = minetest.get_modpath("ebiomes") .. "/schematics/ebiomes_cowberry_bush.mts",
flags = "place_center_x, place_center_z",
})
if minetest.get_modpath("bonemeal") ~= nil then
bonemeal:add_sapling({
{"ebiomes:cowberry_bush_sapling", grow_new_cowberry, "soil"},
})
end
if minetest.global_exists("flowerpot") then
flowerpot.register_node("ebiomes:cowberry_bush_sapling")
end