mirror of
https://git.minetest.land/MineClone2/MineClone2.git
synced 2024-12-12 12:43:15 +01:00
Rearrange conditions to minimize executed code
This commit is contained in:
parent
505c5109ee
commit
7f4f751938
@ -450,18 +450,18 @@ function mod.collides_with_solids(self, dtime, entity_def, projectile_def)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function handle_entity_collision(self, entity_def, projectile_def, object)
|
local function handle_entity_collision(self, entity_def, projectile_def, object)
|
||||||
local pos = self.object:get_pos()
|
-- Arrows stuck in players can't collide with entities
|
||||||
local dir = vector.normalize(self.object:get_velocity())
|
if self._in_player then return end
|
||||||
|
|
||||||
-- Check if this is allowed
|
-- Check if this is allowed
|
||||||
local allow_punching = projectile_def.allow_punching or true
|
local allow_punching = projectile_def.allow_punching or true
|
||||||
if type(allow_punching) == "function" then
|
if type(allow_punching) == "function" then
|
||||||
allow_punching = allow_punching(self, entity_def, projectile_def, object)
|
allow_punching = allow_punching(self, entity_def, projectile_def, object)
|
||||||
end
|
end
|
||||||
if self._in_player then allow_punching = false end
|
|
||||||
|
|
||||||
if not allow_punching then return end
|
if not allow_punching then return end
|
||||||
|
|
||||||
|
local pos = self.object:get_pos()
|
||||||
|
local dir = vector.normalize(self.object:get_velocity())
|
||||||
local object_lua = object:get_luaentity()
|
local object_lua = object:get_luaentity()
|
||||||
|
|
||||||
-- Normally objects should be removed on collision with entities
|
-- Normally objects should be removed on collision with entities
|
||||||
|
Loading…
Reference in New Issue
Block a user