-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcraftitems.lua
More file actions
316 lines (277 loc) · 9.22 KB
/
craftitems.lua
File metadata and controls
316 lines (277 loc) · 9.22 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
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
--[[
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
--]]
--
-- Craft items
--
local S = core.get_translator(core.get_current_modname())
-- Flour
core.register_craftitem('x_farming:flour', {
description = S('Barley Flour'),
inventory_image = 'x_farming_flour.png',
groups = { food_flour = 1, flammable = 1 },
})
-- Bread
local bread_def = {
description = S('Barley Bread') .. '\n' .. S('Compost chance') .. ': 85%\n'
.. core.colorize(x_farming.colors.brown, S('Hunger') .. ': 5'),
inventory_image = 'x_farming_bread.png',
groups = {
-- MTG
food_bread = 1,
flammable = 2,
-- MCL
food = 2,
eatable = 5,
compostability = 85
},
_mcl_saturation = 6.0,
}
if core.get_modpath('farming') then
bread_def.on_use = core.item_eat(5)
end
if core.get_modpath('mcl_farming') then
bread_def.on_place = core.item_eat(5)
bread_def.on_secondary_use = core.item_eat(5)
end
core.register_craftitem('x_farming:bread', bread_def)
-- String
core.register_craftitem('x_farming:string', {
description = S('Cotton String'),
inventory_image = 'x_farming_string.png',
groups = { flammable = 2, string = 1 },
})
-- Soup Bowl
core.register_craftitem('x_farming:bowl', {
description = S('Empty Soup Bowl'),
inventory_image = 'x_farming_bowl.png',
})
-- Bottle Water
core.register_craftitem('x_farming:bottle_water', {
description = S('Water Bottle'),
tiles = { 'x_farming_bottle_water.png' },
inventory_image = 'x_farming_bottle_water.png',
wield_image = 'x_farming_bottle_water.png',
groups = { vessel = 1, food_water = 1 },
})
-- Bottle Honey
local bottle_honey_def = {
description = S('Honey Bottle') .. '\n' ..
core.colorize(x_farming.colors.brown, S('Hunger') .. ': 6'),
tiles = { 'x_farming_bottle_honey.png' },
inventory_image = 'x_farming_bottle_honey.png',
wield_image = 'x_farming_bottle_honey.png',
groups = {
hunger_amount = 6,
-- MCL
craftitem = 1,
food = 3,
eatable = 6,
can_eat_when_full = 1
},
_mcl_saturation = 1.2,
}
if core.get_modpath('farming') then
if x_farming.vessels then
bottle_honey_def.on_use = core.item_eat(6, 'vessels:glass_bottle')
else
bottle_honey_def.on_use = core.item_eat(6, 'x_farming:glass_bottle')
end
end
if core.get_modpath('mcl_farming') then
if x_farming.vessels then
bottle_honey_def.on_place = core.item_eat(6, 'x_farming:glass_bottle')
bottle_honey_def.on_secondary_use = core.item_eat(6, 'vessels:glass_bottle')
else
bottle_honey_def.on_place = core.item_eat(6, 'x_farming:glass_bottle')
bottle_honey_def.on_secondary_use = core.item_eat(6, 'x_farming:glass_bottle')
end
end
core.register_craftitem('x_farming:bottle_honey', bottle_honey_def)
-- Honeycomb
core.register_craftitem('x_farming:honeycomb', {
description = S('Honeycomb'),
inventory_image = 'x_farming_honeycomb.png',
})
-- Honey Sticks
local sticks_honey_def = {
description = S('Honey Sticks') .. '\n' ..
core.colorize(x_farming.colors.brown, S('Hunger') .. ': 2'),
tiles = { 'x_farming_honey_sticks.png' },
inventory_image = 'x_farming_honey_sticks.png',
wield_image = 'x_farming_honey_sticks.png',
wield_scale = 0.4,
groups = {
hunger_amount = 2,
-- MCL
craftitem = 1,
food = 3,
eatable = 6,
can_eat_when_full = 1
},
_mcl_saturation = 1.0,
on_use = core.item_eat(2, 'default:paper'),
}
core.register_craftitem('x_farming:honey_sticks', sticks_honey_def)
-- Jar empty
core.register_craftitem('x_farming:jar_empty', {
description = S('Empty Jar - Right-click to catch Bee with it'),
inventory_image = 'x_farming_jar_empty.png',
groups = { vessel = 1 }
})
-- Jar with bee
core.register_craftitem('x_farming:jar_with_bee', {
description = S('Jar with Bee - Right-click to add bee to a Hive'),
inventory_image = 'x_farming_jar_with_bee.png',
groups = { bee = 1, not_in_creative_inventory = 1 }
})
-- Jars
core.register_craftitem('x_farming:jar_with_honey', {
description = S('Jar of Honey Preserves') .. '\n'
.. core.colorize(x_farming.colors.brown, S('Hunger') .. ': 14'),
inventory_image = 'x_farming_jar_honey.png',
groups = {
vessel = 1,
hunger_amount = 14,
-- MCL
craftitem = 1,
food = 3,
eatable = 12,
can_eat_when_full = 1
},
_mcl_saturation = 1.0,
on_use = core.item_eat(14, 'x_farming:jar_empty'),
})
core.register_craftitem('x_farming:jar_with_bluerries', {
description = S('Jar of Blueberry Preserves') .. '\n'
.. core.colorize(x_farming.colors.brown, S('Hunger') .. ': 7'),
inventory_image = 'x_farming_jar_blueberry.png',
groups = {
vessel = 1,
hunger_amount = 7,
-- MCL
craftitem = 1,
food = 3,
eatable = 6,
can_eat_when_full = 1
},
_mcl_saturation = 1.0,
on_use = core.item_eat(7, 'x_farming:jar_empty'),
})
core.register_craftitem('x_farming:jar_with_strawberries', {
description = S('Jar of Strawberry Preserves') .. '\n'
.. core.colorize(x_farming.colors.brown, S('Hunger') .. ': 7'),
inventory_image = 'x_farming_jar_strawberry.png',
groups = {
vessel = 1,
hunger_amount = 7,
-- MCL
craftitem = 1,
food = 3,
eatable = 6,
can_eat_when_full = 1
},
_mcl_saturation = 1.0,
on_use = core.item_eat(7, 'x_farming:jar_empty'),
})
if core.get_modpath("ctg_world") then
core.register_craftitem('x_farming:jar_with_glowberries', {
description = S('Jar of Glowberry Preserves') .. '\n'
.. core.colorize(x_farming.colors.brown, S('Hunger') .. ': 7'),
inventory_image = 'x_farming_jar_glowberry.png',
light_source = 10,
groups = {
vessel = 1,
hunger_amount = 7,
-- MCL
craftitem = 1,
food = 3,
eatable = 6,
can_eat_when_full = 1
},
_mcl_saturation = 1.0,
on_use = core.item_eat(7, 'x_farming:jar_empty'),
})
end
-- Rice
core.register_craftitem('x_farming:rice_grains', {
description = S('Rice Grains'),
inventory_image = 'x_farming_rice_grains.png',
})
-- Sushi
local sushi_maki_def = {
description = S('Sushi Maki') .. '\n' .. S('Compost chance') .. ': 85%\n'
.. core.colorize(x_farming.colors.brown, S('Hunger') .. ': 5'),
inventory_image = 'x_farming_sushi_maki.png',
groups = {
hunger_amount = 5,
-- MTG
flammable = 2,
-- MCL
food = 2,
eatable = 5,
compostability = 85
},
_mcl_saturation = 6.0,
}
if core.get_modpath('farming') then
sushi_maki_def.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
--sushi_maki_def.on_use = core.item_eat(5)
end
if core.get_modpath('mcl_farming') then
sushi_maki_def.on_place = core.item_eat(5)
sushi_maki_def.on_secondary_use = core.item_eat(5)
end
core.register_craftitem('x_farming:sushi_maki', sushi_maki_def)
local sushi_nigiri_def = {
description = S('Sushi Nigiri') .. '\n' .. S('Compost chance') .. ': 85%\n'
.. core.colorize(x_farming.colors.brown, S('Hunger') .. ': 3'),
inventory_image = 'x_farming_sushi_nigiri.png',
groups = {
hunger_amount = 3,
-- MTG
flammable = 2,
-- MCL
food = 2,
eatable = 3,
compostability = 85
},
_mcl_saturation = 4.0,
}
if core.get_modpath('farming') then
sushi_maki_def.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
--sushi_nigiri_def.on_use = core.item_eat(3)
end
if core.get_modpath('mcl_farming') then
sushi_nigiri_def.on_place = core.item_eat(3)
sushi_nigiri_def.on_secondary_use = core.item_eat(3)
end
core.register_craftitem('x_farming:sushi_nigiri', sushi_nigiri_def)
-- Brick
core.register_craftitem('x_farming:silt_loam_brick', {
description = S('Silt Loam Brick'),
inventory_image = 'x_farming_silt_loam_brick.png',
})