Skip to content

Commit 44d4810

Browse files
SmallJokerCalinou
authored andcommitted
Cirular Saw: avoid errors caused by stack swapping
Calling to 'circular_saw:reset(pos)' clears the 'output' inventory, thus subsequent 'circular_saw:get_cost' calls would return 'nil'. This commit fixes that by relying on (semi-)recent engine bug fixes.
1 parent 533045d commit 44d4810

File tree

1 file changed

+6
-20
lines changed

1 file changed

+6
-20
lines changed

circular_saw.lua

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ circular_saw.known_stairs = setmetatable({}, {
1717
end,
1818
})
1919

20+
if not core.features.physics_overrides_v2 then
21+
-- Notable engine PR: #13919
22+
core.log("warning", "[moreblocks] Detected Luanti/Minetest < 5.8.0. Inventory handling issues may occur.")
23+
end
24+
25+
2026
-- This is populated by stairsplus:register_all:
2127
circular_saw.known_nodes = {}
2228

@@ -349,26 +355,6 @@ end
349355

350356
function circular_saw.on_metadata_inventory_take(
351357
pos, listname, index, stack, player)
352-
353-
-- Prevent (inbuilt) swapping between inventories with different blocks
354-
-- corrupting player inventory or Saw with 'unknown' items.
355-
local meta = minetest.get_meta(pos)
356-
local inv = meta:get_inventory()
357-
local input_stack = inv:get_stack(listname, index)
358-
if not input_stack:is_empty() and input_stack:get_name()~=stack:get_name() then
359-
local player_inv = player:get_inventory()
360-
361-
-- Prevent arbitrary item duplication.
362-
inv:remove_item(listname, input_stack)
363-
364-
if player_inv:room_for_item("main", input_stack) then
365-
player_inv:add_item("main", input_stack)
366-
end
367-
368-
circular_saw:reset(pos)
369-
return
370-
end
371-
372358
-- If it is one of the offered stairs: find out how many
373359
-- microblocks have to be subtracted:
374360
if listname == "output" then

0 commit comments

Comments
 (0)