Fix eaten item being replaced with copies of itself (#43)
This commit is contained in:
parent
78be994cab
commit
6e979b7cd8
24
init.lua
24
init.lua
@ -509,23 +509,19 @@ function minetest.do_item_eat(hp_change, replace_with_item, itemstack, player, p
|
|||||||
end
|
end
|
||||||
|
|
||||||
itemstack:take_item()
|
itemstack:take_item()
|
||||||
|
player:set_wielded_item(itemstack)
|
||||||
if replace_with_item then
|
replace_with_item = ItemStack(replace_with_item)
|
||||||
if itemstack:is_empty() then
|
if not replace_with_item:is_empty() then
|
||||||
itemstack:add_item(replace_with_item)
|
local inv = player:get_inventory()
|
||||||
else
|
replace_with_item = inv:add_item("main", replace_with_item)
|
||||||
local inv = player:get_inventory()
|
if not replace_with_item:is_empty() then
|
||||||
if inv:room_for_item("main", {name=replace_with_item}) then
|
local pos = player:get_pos()
|
||||||
inv:add_item("main", replace_with_item)
|
pos.y = math.floor(pos.y - 1.0)
|
||||||
else
|
minetest.add_item(pos, replace_with_item)
|
||||||
local pos = player:get_pos()
|
|
||||||
pos.y = math.floor(pos.y - 1.0)
|
|
||||||
minetest.add_item(pos, replace_with_item)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return itemstack
|
return nil -- don't overwrite wield item a second time
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_on_joinplayer(function(player)
|
minetest.register_on_joinplayer(function(player)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user