@@ -163,9 +163,8 @@ local function entity_physics(pos, radius, drops)
163
163
164
164
local damage = (4 / dist ) * radius
165
165
if obj :is_player () then
166
- -- currently the engine has no method to set
167
- -- player velocity. See #2960
168
- -- instead, we knock the player back 1.0 node, and slightly upwards
166
+ -- we knock the player back 1.0 node, and slightly upwards
167
+ -- TODO: switch to add_player_velocity() introduced in 5.1
169
168
local dir = vector .normalize (vector .subtract (obj_pos , pos ))
170
169
local moveoff = vector .multiply (dir , dist + 1.0 )
171
170
local newpos = vector .add (pos , moveoff )
@@ -174,31 +173,35 @@ local function entity_physics(pos, radius, drops)
174
173
175
174
obj :set_hp (obj :get_hp () - damage )
176
175
else
177
- local do_damage = true
178
- local do_knockback = true
179
- local entity_drops = {}
180
176
local luaobj = obj :get_luaentity ()
181
- local objdef = minetest .registered_entities [luaobj .name ]
182
177
183
- if objdef and objdef .on_blast then
184
- do_damage , do_knockback , entity_drops = objdef .on_blast (luaobj , damage )
185
- end
178
+ -- object might have disappeared somehow
179
+ if luaobj then
180
+ local do_damage = true
181
+ local do_knockback = true
182
+ local entity_drops = {}
183
+ local objdef = minetest .registered_entities [luaobj .name ]
186
184
187
- if do_knockback then
188
- local obj_vel = obj :get_velocity ()
189
- obj :set_velocity (calc_velocity (pos , obj_pos ,
190
- obj_vel , radius * 10 ))
191
- end
192
- if do_damage then
193
- if not obj :get_armor_groups ().immortal then
194
- obj :punch (obj , 1.0 , {
195
- full_punch_interval = 1.0 ,
196
- damage_groups = {fleshy = damage },
197
- }, nil )
185
+ if objdef and objdef .on_blast then
186
+ do_damage , do_knockback , entity_drops = objdef .on_blast (luaobj , damage )
187
+ end
188
+
189
+ if do_knockback then
190
+ local obj_vel = obj :get_velocity ()
191
+ obj :set_velocity (calc_velocity (pos , obj_pos ,
192
+ obj_vel , radius * 10 ))
193
+ end
194
+ if do_damage then
195
+ if not obj :get_armor_groups ().immortal then
196
+ obj :punch (obj , 1.0 , {
197
+ full_punch_interval = 1.0 ,
198
+ damage_groups = {fleshy = damage },
199
+ }, nil )
200
+ end
201
+ end
202
+ for _ , item in pairs (entity_drops ) do
203
+ add_drop (drops , item )
198
204
end
199
- end
200
- for _ , item in pairs (entity_drops ) do
201
- add_drop (drops , item )
202
205
end
203
206
end
204
207
end
0 commit comments