Skip to content

Commit dca7b79

Browse files
authored
Merge pull request #188 from Watilin/manual-crafter-aboose
Fix an exploit with manual crafter
2 parents 00451f8 + feee57d commit dca7b79

File tree

1 file changed

+24
-11
lines changed

1 file changed

+24
-11
lines changed

mods/sbz_power/manual_crafter.lua

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -154,13 +154,13 @@ core.register_node('sbz_power:manual_crafter', {
154154
meta:set_string(
155155
'formspec',
156156
[[
157-
formspec_version[8]
158-
size[10.25,9.6]
159-
list[context;configure_craft;0.25,0.25;3,3]
160-
list[context;configure_craft_output;5.25,1.525;1,1]
161-
list[current_player;main;0.25,4.6;8,4]
162-
button[8,0.25;2,1;configure;Configure]
163-
]]
157+
formspec_version[8]
158+
size[10.25,9.6]
159+
list[context;configure_craft;0.25,0.25;3,3]
160+
list[context;configure_craft_output;5.25,1.525;1,1]
161+
list[current_player;main;0.25,4.6;8,4]
162+
button[8,0.25;2,1;configure;Configure]
163+
]]
164164
)
165165
end,
166166
groups = { matter = 2 },
@@ -169,17 +169,24 @@ core.register_node('sbz_power:manual_crafter', {
169169
end,
170170

171171
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
172-
validate_craft(pos)
172+
if from_list ~= to_list then return 0 end
173173
return count
174174
end,
175175

176+
on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
177+
validate_craft(pos)
178+
end,
179+
176180
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
177181
if listname == 'configure_craft' or listname == 'configure_craft_output' then
178182
local from_inv = core.get_meta(pos):get_inventory()
179183
stack:set_count(1)
180184
from_inv:set_stack(listname, index, stack)
181-
if listname == 'configure_craft_output' then configure_from_craft_output(pos, player) end
182-
validate_craft(pos)
185+
if listname == 'configure_craft_output' then
186+
configure_from_craft_output(pos, player)
187+
else
188+
validate_craft(pos)
189+
end
183190
end
184191
return 0
185192
end,
@@ -188,7 +195,13 @@ core.register_node('sbz_power:manual_crafter', {
188195
if listname == 'configure_craft' or listname == 'configure_craft_output' then
189196
local from_inv = core.get_meta(pos):get_inventory()
190197
from_inv:set_stack(listname, index, '')
191-
validate_craft(pos)
198+
if listname == 'configure_craft_output' then
199+
from_inv:set_list('configure_craft', { '', '', '',
200+
'', '', '',
201+
'', '', '' })
202+
else
203+
validate_craft(pos)
204+
end
192205
end
193206
return 0
194207
end,

0 commit comments

Comments
 (0)