item duplication bug

This commit is contained in:
FaceDeer 2017-04-21 16:58:03 -06:00
parent 09db79f362
commit dcdeb5d321

View File

@ -69,7 +69,7 @@ minetest.register_entity("anvil:item",{
})
local remove_item = function(pos, node)
local objs = minetest.env:get_objects_inside_radius({x = pos.x, y = pos.y + item_displacement, z = pos.z}, .5)
local objs = minetest.get_objects_inside_radius({x = pos.x, y = pos.y + item_displacement, z = pos.z}, .5)
if objs then
for _, obj in ipairs(objs) do
if obj and obj:get_luaentity() and obj:get_luaentity().name == "anvil:item" then
@ -80,13 +80,13 @@ local remove_item = function(pos, node)
end
local update_item = function(pos, node)
local meta = minetest.env:get_meta(pos)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
if not inv:is_empty("input") then
pos.y = pos.y + item_displacement
tmp.nodename = node.name
tmp.texture = inv:get_stack("input", 1):get_name()
local e = minetest.env:add_entity(pos,"anvil:item")
local e = minetest.add_entity(pos,"anvil:item")
local yaw = math.pi*2 - node.param2 * math.pi/2
e:setyaw(yaw)
end
@ -180,20 +180,20 @@ minetest.register_node("anvil:anvil", {
on_rightclick = function(pos, node, clicker, itemstack)
if itemstack:get_count() == 0 then
local meta = minetest.env:get_meta(pos)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
if not inv:is_empty("input") then
local return_stack = inv:get_stack("input", 1)
inv:set_stack("input", 1, nil)
clicker:get_inventory():add_item("main", return_stack)
remove_item(pos, node)
return return_stack
return itemstack
end
end
local this_def = minetest.registered_nodes[node.name]
if this_def.allow_metadata_inventory_put(pos, "input", 1, itemstack:peek_item(), clicker) > 0 then
local s = itemstack:take_item()
local meta = minetest.env:get_meta(pos)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
inv:add_item("input", s)
update_item(pos,node)