Re-enable item falling after being in unloaded

This commit is contained in:
Wuzzy 2017-05-27 15:37:15 +02:00
parent 3cda40818c
commit 23c438f427
1 changed files with 7 additions and 1 deletions

View File

@ -375,13 +375,19 @@ core.register_entity(":__builtin:item", {
local p = self.object:getpos()
local node = core.get_node_or_nil(p)
local in_unloaded = (node == nil)
if in_unloaded then
if in_unloaded and self.physical_state == true then
-- Don't infinetly fall into unloaded map
self.object:setvelocity({x = 0, y = 0, z = 0})
self.object:setacceleration({x = 0, y = 0, z = 0})
self.physical_state = false
self.object:set_properties({physical = false})
return
elseif self.physical_state == false then
-- Start falling again if map has been loaded again
self.object:setacceleration({x = 0, y = -get_gravity(), z = 0})
self.physical_state = true
self.object:set_properties({physical = true})
return
end
-- Destroy item in lava or special nodes