From 3c45e98ff29c32bf7dd8b136b8e2472c9b49cdb5 Mon Sep 17 00:00:00 2001 From: HybridDog Date: Fri, 14 Nov 2025 16:18:43 +0100 Subject: [PATCH] Fix crashes with objects in invalid state If __builtin:item's on_step() makes the dropped item invalid, e.g. by removing it, a later get_velocity() returns nil, which leads to a crash. After this change, the overridden on_step() aborts early if the object became invalid. --- init.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/init.lua b/init.lua index bda4da1..2f4bdb6 100644 --- a/init.lua +++ b/init.lua @@ -76,8 +76,8 @@ item_entity.on_step = function(self, dtime, ...) old_on_step(self, dtime, ...) - -- Ignore the item if it should not interact with physics - if not self.physical_state then + -- Ignore the item if it should not interact with physics or was removed + if not self.physical_state or not self.object:is_valid() then return end