mirror of
https://github.com/HybridDog/builtin_item.git
synced 2025-11-21 01:25:23 +01:00
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.
This commit is contained in:
4
init.lua
4
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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user