mirror of
https://github.com/minetest-mods/technic.git
synced 2024-12-25 10:20:37 +01:00
Drop upgrade items in the after_dig_node handler instead of can_dig
This fixes an item duplication bug triggered by using a screwdriver on an upgraded machine
This commit is contained in:
parent
c6464d3ebe
commit
c8cbd261ee
@ -102,7 +102,7 @@ minetest.register_node("technic:tool_workshop", {
|
|||||||
},
|
},
|
||||||
technic_run = run,
|
technic_run = run,
|
||||||
after_place_node = pipeworks.after_place,
|
after_place_node = pipeworks.after_place,
|
||||||
after_dig_node = pipeworks.after_dig
|
after_dig_node = technic.machine_after_dig_node
|
||||||
})
|
})
|
||||||
|
|
||||||
technic.register_machine("MV", "technic:tool_workshop", technic.receiver)
|
technic.register_machine("MV", "technic:tool_workshop", technic.receiver)
|
||||||
|
@ -196,7 +196,7 @@ function technic.register_battery_box(data)
|
|||||||
allow_metadata_inventory_move = technic.machine_inventory_move,
|
allow_metadata_inventory_move = technic.machine_inventory_move,
|
||||||
technic_run = run,
|
technic_run = run,
|
||||||
after_place_node = tube and pipeworks.after_place,
|
after_place_node = tube and pipeworks.after_place,
|
||||||
after_dig_node = tube and pipeworks.after_dig
|
after_dig_node = technic.machine_after_dig_node
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -147,15 +147,30 @@ function technic.machine_can_dig(pos, player)
|
|||||||
S("Machine cannot be removed because it is not empty"))
|
S("Machine cannot be removed because it is not empty"))
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
else
|
|
||||||
if not inv:is_empty("upgrade1") then
|
|
||||||
minetest.item_drop(inv:get_stack("upgrade1", 1), "", pos)
|
|
||||||
end
|
|
||||||
if not inv:is_empty("upgrade2") then
|
|
||||||
minetest.item_drop(inv:get_stack("upgrade2", 1), "", pos)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function technic.machine_after_dig_node(pos, oldnode, oldmetadata, player)
|
||||||
|
if oldmetadata.inventory then
|
||||||
|
if oldmetadata.inventory.upgrade1 and oldmetadata.inventory.upgrade1[1] then
|
||||||
|
local stack = ItemStack(oldmetadata.inventory.upgrade1[1])
|
||||||
|
if not stack:is_empty() then
|
||||||
|
minetest.item_drop(stack, "", pos)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if oldmetadata.inventory.upgrade2 and oldmetadata.inventory.upgrade2[1] then
|
||||||
|
local stack = ItemStack(oldmetadata.inventory.upgrade2[1])
|
||||||
|
if not stack:is_empty() then
|
||||||
|
minetest.item_drop(stack, "", pos)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if minetest.registered_nodes[oldnode.name].tube then
|
||||||
|
pipeworks.after_dig(pos, oldnode, oldmetadata, player)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function inv_change(pos, player, count, from_list, to_list, stack)
|
local function inv_change(pos, player, count, from_list, to_list, stack)
|
||||||
|
@ -110,7 +110,7 @@ function technic.register_generator(data)
|
|||||||
allow_metadata_inventory_move = technic.machine_inventory_move,
|
allow_metadata_inventory_move = technic.machine_inventory_move,
|
||||||
technic_run = run,
|
technic_run = run,
|
||||||
after_place_node = tube and pipeworks.after_place,
|
after_place_node = tube and pipeworks.after_place,
|
||||||
after_dig_node = tube and pipeworks.after_dig
|
after_dig_node = technic.machine_after_dig_node
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_node("technic:"..ltier.."_generator_active", {
|
minetest.register_node("technic:"..ltier.."_generator_active", {
|
||||||
|
@ -154,7 +154,7 @@ function technic.register_base_machine(data)
|
|||||||
allow_metadata_inventory_move = technic.machine_inventory_move,
|
allow_metadata_inventory_move = technic.machine_inventory_move,
|
||||||
technic_run = run,
|
technic_run = run,
|
||||||
after_place_node = tube and pipeworks.after_place,
|
after_place_node = tube and pipeworks.after_place,
|
||||||
after_dig_node = tube and pipeworks.after_dig
|
after_dig_node = technic.machine_after_dig_node
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_node("technic:"..ltier.."_"..machine_name.."_active",{
|
minetest.register_node("technic:"..ltier.."_"..machine_name.."_active",{
|
||||||
|
Loading…
Reference in New Issue
Block a user