+ if self.force_out then
+ -- This code runs after the entity got a push from the is_stuck code.
+ -- It makes sure the entity is entirely outside the solid node
+ local c = self.object:get_properties().collisionbox
+ local s = self.force_out_start
+ local f = self.force_out
+ local ok = (f.x > 0 and pos.x + c[1] > s.x + 0.5) or
+ (f.y > 0 and pos.y + c[2] > s.y + 0.5) or
+ (f.z > 0 and pos.z + c[3] > s.z + 0.5) or
+ (f.x < 0 and pos.x + c[4] < s.x - 0.5) or
+ (f.z < 0 and pos.z + c[6] < s.z - 0.5)
+ if ok then
+ -- Item was successfully forced out
+ self.force_out = nil
+ self:enable_physics()
+ return
+ end
+ end
+
+ if not self.physical_state then
+ return -- Don't do anything
+ end
+
+ assert(moveresult)
+ if not moveresult.collides then
+ -- future TODO: items should probably decelerate in air
+ return
+ end
+
+ -- Push item out when stuck inside solid node