Skip to content

Commit be18bd6

Browse files
tenplus1est31
authored andcommittedMay 14, 2015
Don't crash if an item gets dropped into unloaded space
Items dropped into unloaded map space will crash game so here's a fix...
1 parent 178f536 commit be18bd6

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed
 

Diff for: ‎builtin/game/item_entity.lua

+11-1
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,17 @@ core.register_entity(":__builtin:item", {
155155
end
156156
local p = self.object:getpos()
157157
p.y = p.y - 0.5
158-
local nn = core.get_node(p).name
158+
local node = core.get_node_or_nil(p)
159+
local in_unloaded = (node == nil)
160+
if in_unloaded then
161+
-- Don't infinetly fall into unloaded map
162+
self.object:setvelocity({x = 0, y = 0, z = 0})
163+
self.object:setacceleration({x = 0, y = 0, z = 0})
164+
self.physical_state = false
165+
self.object:set_properties({physical = false})
166+
return
167+
end
168+
local nn = node.name
159169
-- If node is not registered or node is walkably solid and resting on nodebox
160170
local v = self.object:getvelocity()
161171
if not core.registered_nodes[nn] or core.registered_nodes[nn].walkable and v.y == 0 then

0 commit comments

Comments
 (0)
Please sign in to comment.