@@ -41,7 +41,7 @@ core.register_entity(":__builtin:falling_node", {
41
41
end ,
42
42
43
43
on_step = function (self , dtime )
44
- -- Set gravity
44
+ -- Set gravity
45
45
local acceleration = self .object :getacceleration ()
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 })
@@ -52,10 +52,9 @@ core.register_entity(":__builtin:falling_node", {
52
52
local bcn = core .get_node (bcp )
53
53
local bcd = core .registered_nodes [bcn .name ]
54
54
-- Note: walkable is in the node definition, not in item groups
55
- if not bcd or
56
- (bcd .walkable or
55
+ if not bcd or bcd .walkable or
57
56
(core .get_item_group (self .node .name , " float" ) ~= 0 and
58
- bcd .liquidtype ~= " none" )) then
57
+ bcd .liquidtype ~= " none" ) then
59
58
if bcd and bcd .leveled and
60
59
bcn .name == self .node .name then
61
60
local addlevel = self .node .level
@@ -75,20 +74,20 @@ core.register_entity(":__builtin:falling_node", {
75
74
local np = {x = bcp .x , y = bcp .y + 1 , z = bcp .z }
76
75
-- Check what's here
77
76
local n2 = core .get_node (np )
77
+ local nd = core .registered_nodes [n2 .name ]
78
78
-- If it's not air or liquid, remove node and replace it with
79
79
-- it's drops
80
- if n2 .name ~= " air" and (not core .registered_nodes [n2 .name ] or
81
- core .registered_nodes [n2 .name ].liquidtype == " none" ) then
80
+ if n2 .name ~= " air" and (not nd or nd .liquidtype == " none" ) then
82
81
core .remove_node (np )
83
- if core . registered_nodes [ n2 . name ] .buildable_to == false then
82
+ if nd .buildable_to == false then
84
83
-- Add dropped items
85
84
local drops = core .get_node_drops (n2 .name , " " )
86
- for _ , dropped_item in ipairs (drops ) do
85
+ for _ , dropped_item in pairs (drops ) do
87
86
core .add_item (np , dropped_item )
88
87
end
89
88
end
90
89
-- Run script hook
91
- for _ , callback in ipairs (core .registered_on_dignodes ) do
90
+ for _ , callback in pairs (core .registered_on_dignodes ) do
92
91
callback (np , n2 )
93
92
end
94
93
end
116
115
function drop_attached_node (p )
117
116
local nn = core .get_node (p ).name
118
117
core .remove_node (p )
119
- for _ , item in ipairs (core .get_node_drops (nn , " " )) do
118
+ for _ , item in pairs (core .get_node_drops (nn , " " )) do
120
119
local pos = {
121
120
x = p .x + math.random ()/ 2 - 0.25 ,
122
121
y = p .y + math.random ()/ 2 - 0.25 ,
@@ -156,14 +155,15 @@ function nodeupdate_single(p)
156
155
if core .get_item_group (n .name , " falling_node" ) ~= 0 then
157
156
local p_bottom = {x = p .x , y = p .y - 1 , z = p .z }
158
157
local n_bottom = core .get_node (p_bottom )
158
+ local d_bottom = core .registered_nodes [n_bottom .name ]
159
159
-- Note: walkable is in the node definition, not in item groups
160
- if core . registered_nodes [ n_bottom . name ] and
160
+ if d_bottom and
161
161
(core .get_item_group (n .name , " float" ) == 0 or
162
- core . registered_nodes [ n_bottom . name ] .liquidtype == " none" ) and
163
- (n .name ~= n_bottom .name or (core . registered_nodes [ n_bottom . name ] .leveled and
162
+ d_bottom .liquidtype == " none" ) and
163
+ (n .name ~= n_bottom .name or (d_bottom .leveled and
164
164
core .get_node_level (p_bottom ) < core .get_node_max_level (p_bottom ))) and
165
- (not core . registered_nodes [ n_bottom . name ] .walkable or
166
- core . registered_nodes [ n_bottom . name ] .buildable_to ) then
165
+ (not d_bottom .walkable or
166
+ d_bottom .buildable_to ) then
167
167
n .level = core .get_node_level (p )
168
168
core .remove_node (p )
169
169
spawn_falling_node (p , n )
0 commit comments