From da8ecc1d6824a601649d66ccd526aa69f4e93320 Mon Sep 17 00:00:00 2001 From: sfan5 Date: Mon, 16 Mar 2020 22:29:44 +0100 Subject: [PATCH] player_api: Prevent knockback when player is set as attached This is not directly related to player models but fits well as a convenience feature in player_api. --- api.lua | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/api.lua b/api.lua index 0afd679..4cb3944 100644 --- a/api.lua +++ b/api.lua @@ -96,6 +96,15 @@ end) local player_set_animation = player_api.set_animation local player_attached = player_api.player_attached +-- Prevent knockback for attached players +local old_calculate_knockback = minetest.calculate_knockback +function minetest.calculate_knockback(player, ...) + if player_attached[player:get_player_name()] then + return 0 + end + return old_calculate_knockback(player, ...) +end + -- Check each player and apply animations minetest.register_globalstep(function(dtime) for _, player in pairs(minetest.get_connected_players()) do