Skip to content
Snippets Groups Projects
Commit eb92bfb0 authored by BlockMen's avatar BlockMen
Browse files

Check if hitter has inventory when punching item

Fixes #3280
parent df2c474d
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment