Skip to content

Commit

Permalink
Check if hitter has inventory when punching item
Browse files Browse the repository at this point in the history
Fixes #3280
  • Loading branch information
BlockMen committed Oct 25, 2015
1 parent df2c474 commit eb92bfb
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions builtin/game/item_entity.lua
Expand Up @@ -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
Expand Down

0 comments on commit eb92bfb

Please sign in to comment.