Check if hitter has inventory when punching item

Fixes #3280
This commit is contained in:
BlockMen 2015-10-25 18:15:31 +01:00 committed by Nils Dagsson Moskopp
parent c0297ebcbe
commit 1f21ad4da2
Signed by: erle
GPG Key ID: A3BC671C35191080
1 changed files with 4 additions and 3 deletions

View File

@ -200,9 +200,10 @@ core.register_entity(":__builtin:item", {
end,
on_punch = function(self, hitter)
if self.itemstring ~= '' then
local left = hitter:get_inventory():add_item("main", self.itemstring)
if not left:is_empty() then
local inv = hitter:get_inventory()
if inv and self.itemstring ~= '' then
local left = inv:add_item("main", self.itemstring)
if left and not left:is_empty() then
self.itemstring = left:to_string()
return
end