-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmelon.lua
More file actions
291 lines (264 loc) · 9.13 KB
/
melon.lua
File metadata and controls
291 lines (264 loc) · 9.13 KB
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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
--[[
X Farming. Extends Luanti farming mod with new plants, crops and ice fishing.
Copyright (C) 2025 SaKeL
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 juraj.vajda@gmail.com
--]]
local S = core.get_translator(core.get_current_modname())
-- MELON
x_farming.register_plant('x_farming:melon', {
description = S('Melon Seed') .. '\n' .. S('Compost chance') .. ': 30%',
short_description = S('Melon Seed'),
inventory_image = 'x_farming_melon_seed.png',
steps = 8,
minlight = 13,
maxlight = 14,
fertility = { 'grassland' },
groups = { flammable = 4 },
place_param2 = 3,
})
-- needed
local melon_def = {
description = S('Melon') .. '\n' .. S('Compost chance') .. ': 50%\n'
.. core.colorize(x_farming.colors.brown, S('Hunger') .. ': 2'),
groups = {
hunger_amount = 2,
-- X Farming
compost = 50,
-- MCL
food = 2,
eatable = 2,
compostability = 50,
},
on_use = function(itemstack, user, pointed_thing)
local hunger_amount = core.get_item_group(itemstack:get_name(), "hunger_amount") or 0
if hunger_amount == 0 then
return itemstack
end
return core.item_eat(hunger_amount)(itemstack, user, pointed_thing)
end,
_mcl_saturation = 1.2,
wield_image = 'x_farming_melon.png',
}
if core.get_modpath('farming') then
melon_def.on_use = core.item_eat(2)
end
if core.get_modpath('mcl_farming') then
melon_def.on_place = core.item_eat(2)
melon_def.on_secondary_use = core.item_eat(2)
end
core.override_item('x_farming:melon', melon_def)
-- MELON FRUIT - HARVEST
core.register_node('x_farming:melon_fruit', {
description = S('Melon Fruit'),
tiles = {
'x_farming_melon_fruit_top.png',
'x_farming_melon_fruit_bottom.png',
'x_farming_melon_fruit_side.png',
'x_farming_melon_fruit_side.png',
'x_farming_melon_fruit_side.png',
'x_farming_melon_fruit_side.png'
},
sounds = x_farming.node_sound_wood_defaults(),
is_ground_content = false,
groups = {
-- MTG
snappy = 3,
flammable = 4,
fall_damage_add_percent = -30,
-- MCL
handy = 1,
axey = 1,
plant = 1,
dig_by_piston = 1,
},
_mcl_blast_resistance = 1,
_mcl_hardness = 1,
drop = {
max_items = 7, -- Maximum number of items to drop.
items = { -- Choose max_items randomly from this list.
{
items = { 'x_farming:melon' }, -- Items to drop.
rarity = 1, -- Probability of dropping is 1 / rarity.
},
{
items = { 'x_farming:melon' }, -- Items to drop.
rarity = 2, -- Probability of dropping is 1 / rarity.
},
{
items = { 'x_farming:melon' }, -- Items to drop.
rarity = 2, -- Probability of dropping is 1 / rarity.
},
{
items = { 'x_farming:melon' }, -- Items to drop.
rarity = 2, -- Probability of dropping is 1 / rarity.
},
{
items = { 'x_farming:melon' }, -- Items to drop.
rarity = 3, -- Probability of dropping is 1 / rarity.
},
{
items = { 'x_farming:melon' }, -- Items to drop.
rarity = 3, -- Probability of dropping is 1 / rarity.
},
{
items = { 'x_farming:melon' }, -- Items to drop.
rarity = 3, -- Probability of dropping is 1 / rarity.
},
},
},
after_dig_node = function(pos, oldnode, oldmetadata, digger)
local parent = oldmetadata.fields.parent
local parent_pos_from_child = core.string_to_pos(parent)
local parent_node = nil
-- make sure we have position
if parent_pos_from_child
and parent_pos_from_child ~= nil then
parent_node = core.get_node(parent_pos_from_child)
end
-- tick parent if parent stem still exists
if parent_node
and parent_node ~= nil
and parent_node.name == 'x_farming:melon_8' then
x_farming.tick_block(parent_pos_from_child)
end
end
})
-- MELON BLOCK - HARVEST from crops
core.register_node('x_farming:melon_block', {
description = S('Melon Block') .. '\n' .. S('Compost chance') .. ': 65%',
short_description = S('Melon Block'),
tiles = {
'x_farming_melon_fruit_top.png',
'x_farming_melon_fruit_bottom.png',
'x_farming_melon_fruit_side.png',
'x_farming_melon_fruit_side.png',
'x_farming_melon_fruit_side.png',
'x_farming_melon_fruit_side.png'
},
sounds = x_farming.node_sound_wood_defaults(),
is_ground_content = false,
groups = {
-- MTG
snappy = 3,
flammable = 4,
fall_damage_add_percent = -30,
not_in_creative_inventory = 1,
compost = 65,
-- MCL
handy = 1,
axey = 1,
plant = 1,
dig_by_piston = 1,
building_block = 1,
enderman_takable = 1,
compostability = 65
},
_mcl_blast_resistance = 1,
_mcl_hardness = 1,
})
-- take over the growth from minetest_game farming from here
core.override_item('x_farming:melon_8', {
next_plant = 'x_farming:melon_fruit',
on_timer = x_farming.grow_block
})
-- Golden Melon
local golden_melon_def = {
description = S('Golden Melon') .. '\n' .. core.colorize(x_farming.colors.brown, S('Hunger') .. ': 10'),
inventory_image = 'x_farming_golden_melon.png',
wield_image = 'x_farming_golden_melon.png',
groups = {
hunger_amount = 10,
-- MCL
food = 2,
eatable = 1,
},
_mcl_saturation = 14.4,
on_use = function(itemstack, user, pointed_thing)
local hunger_amount = core.get_item_group(itemstack:get_name(), "hunger_amount") or 0
if hunger_amount == 0 then
return itemstack
end
return core.item_eat(hunger_amount)(itemstack, user, pointed_thing)
end,
}
if x_farming.hbhunger ~= nil or x_farming.hunger_ng ~= nil then
golden_melon_def.description = golden_melon_def.description .. '\n' .. core.colorize(x_farming.colors.red, S('Heal') .. ': 10')
end
if core.get_modpath('farming') then
golden_melon_def.on_use = core.item_eat(10)
end
if core.get_modpath('mcl_farming') then
golden_melon_def.on_place = core.item_eat(10)
golden_melon_def.on_secondary_use = core.item_eat(10)
end
core.register_craftitem('x_farming:golden_melon', golden_melon_def)
-- replacement LBM for pre-nodetimer plants
core.register_lbm({
name = 'x_farming:start_nodetimer_melon',
nodenames = { 'x_farming:melon_8' },
action = function(pos, node)
x_farming.tick_block_short(pos)
end,
})
---crate
x_farming.register_crate('crate_melon_3', {
description = S('Melon Crate'),
short_description = S('Melon Crate'),
tiles = { 'x_farming_crate_melon_3.png' },
_custom = {
crate_item = 'x_farming:melon'
}
})
core.register_on_mods_loaded(function()
local deco_place_on = {}
local deco_biomes = {}
-- MTG
if core.get_modpath('default') then
table.insert(deco_place_on, 'default:dirt_with_grass')
table.insert(deco_biomes, 'grassland')
end
-- Everness
if core.get_modpath('everness') then
table.insert(deco_place_on, 'everness:dirt_with_coral_grass')
table.insert(deco_biomes, 'everness:coral_forest')
end
-- MCL
if core.get_modpath('mcl_core') then
table.insert(deco_place_on, 'mcl_core:dirt_with_grass')
table.insert(deco_biomes, 'Plains')
end
if next(deco_place_on) and next(deco_biomes) then
core.register_decoration({
name = 'x_farming:melon',
deco_type = 'simple',
place_on = deco_place_on,
sidelen = 16,
noise_params = {
offset = -0.1,
scale = 0.1,
spread = { x = 50, y = 50, z = 50 },
seed = 4242,
octaves = 3,
persist = 0.7
},
biomes = deco_biomes,
y_max = 31000,
y_min = 1,
decoration = {
'x_farming:melon_5',
'x_farming:melon_6',
'x_farming:melon_7',
'x_farming:melon_8',
},
})
end
end)