@@ -46,15 +46,17 @@ core.register_entity(":__builtin:falling_node", {
46
46
if not vector .equals (acceleration , {x = 0 , y = - 10 , z = 0 }) then
47
47
self .object :setacceleration ({x = 0 , y = - 10 , z = 0 })
48
48
end
49
- -- Turn to actual sand when collides to ground or just move
49
+ -- Turn to actual node when colliding with ground, or continue to move
50
50
local pos = self .object :getpos ()
51
- local bcp = {x = pos .x , y = pos .y - 0.7 , z = pos .z } -- Position of bottom center point
52
- local bcn = core .get_node (bcp )
53
- local bcd = core .registered_nodes [bcn .name ]
54
- -- Note: walkable is in the node definition, not in item groups
55
- if not bcd or bcd .walkable or
51
+ -- Position of bottom center point
52
+ local bcp = {x = pos .x , y = pos .y - 0.7 , z = pos .z }
53
+ -- Avoid bugs caused by an unloaded node below
54
+ local bcn = core .get_node_or_nil (bcp )
55
+ local bcd = bcn and core .registered_nodes [bcn .name ]
56
+ if bcn and
57
+ (not bcd or bcd .walkable or
56
58
(core .get_item_group (self .node .name , " float" ) ~= 0 and
57
- bcd .liquidtype ~= " none" ) then
59
+ bcd .liquidtype ~= " none" )) then
58
60
if bcd and bcd .leveled and
59
61
bcn .name == self .node .name then
60
62
local addlevel = self .node .level
@@ -154,16 +156,19 @@ function nodeupdate_single(p)
154
156
local n = core .get_node (p )
155
157
if core .get_item_group (n .name , " falling_node" ) ~= 0 then
156
158
local p_bottom = {x = p .x , y = p .y - 1 , z = p .z }
157
- local n_bottom = core . get_node ( p_bottom )
158
- local d_bottom = core .registered_nodes [ n_bottom . name ]
159
- -- Note: walkable is in the node definition, not in item groups
159
+ -- Only spawn falling node if node below is loaded
160
+ local n_bottom = core .get_node_or_nil ( p_bottom )
161
+ local d_bottom = n_bottom and core . registered_nodes [ n_bottom . name ]
160
162
if d_bottom and
163
+
161
164
(core .get_item_group (n .name , " float" ) == 0 or
162
- d_bottom .liquidtype == " none" ) and
165
+ d_bottom .liquidtype == " none" ) and
166
+
163
167
(n .name ~= n_bottom .name or (d_bottom .leveled and
164
- core .get_node_level (p_bottom ) < core .get_node_max_level (p_bottom ))) and
165
- (not d_bottom .walkable or
166
- d_bottom .buildable_to ) then
168
+ core .get_node_level (p_bottom ) <
169
+ core .get_node_max_level (p_bottom ))) and
170
+
171
+ (not d_bottom .walkable or d_bottom .buildable_to ) then
167
172
n .level = core .get_node_level (p )
168
173
core .remove_node (p )
169
174
spawn_falling_node (p , n )
0 commit comments