From 1f21ad4da234b9a5af658692c4e39c903eaa7070 Mon Sep 17 00:00:00 2001 From: BlockMen Date: Sun, 25 Oct 2015 18:15:31 +0100 Subject: [PATCH] Check if hitter has inventory when punching item Fixes #3280 --- builtin/game/item_entity.lua | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/builtin/game/item_entity.lua b/builtin/game/item_entity.lua index 190473c..a8d7a18 100644 --- a/builtin/game/item_entity.lua +++ b/builtin/game/item_entity.lua @@ -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