forked from MineClone5/MineClone5
Try to merge Mineclonia/Send FOV packets only when necessary
This commit is contained in:
parent
a7c3154a22
commit
b43d0af4a5
|
@ -67,36 +67,32 @@ end
|
|||
local function setSprinting(playerName, sprinting) --Sets the state of a player (0=stopped/moving, 1=sprinting)
|
||||
local player = minetest.get_player_by_name(playerName)
|
||||
local controls = player:get_player_control()
|
||||
if players[playerName] then
|
||||
players[playerName].sprinting = sprinting
|
||||
if sprinting == true
|
||||
or controls.RMB
|
||||
and string.find(player:get_wielded_item():get_name(), "mcl_bows:bow")
|
||||
and player:get_wielded_item():get_name() ~= "mcl_bows:bow" then
|
||||
if sprinting == true then
|
||||
players[playerName].fov = math.min(players[playerName].fov + 0.05, 1.2)
|
||||
players[playerName].fade_time = .15
|
||||
else
|
||||
players[playerName].fov = .7
|
||||
players[playerName].fade_time = .3
|
||||
end
|
||||
player:set_fov(players[playerName].fov, true, players[playerName].fade_time)
|
||||
if sprinting == true then
|
||||
playerphysics.add_physics_factor(player, "speed", "mcl_sprint:sprint", mcl_sprint.SPEED)
|
||||
end
|
||||
elseif sprinting == false
|
||||
and player:get_wielded_item():get_name() ~= "mcl_bows:bow_0"
|
||||
and player:get_wielded_item():get_name() ~= "mcl_bows:bow_1"
|
||||
and player:get_wielded_item():get_name() ~= "mcl_bows:bow_2" then
|
||||
players[playerName].fov = math.max(players[playerName].fov - 0.05, 1.0)
|
||||
player:set_fov(players[playerName].fov, true, 0.15)
|
||||
if sprinting == false then
|
||||
playerphysics.remove_physics_factor(player, "speed", "mcl_sprint:sprint")
|
||||
end
|
||||
end
|
||||
return true
|
||||
if not players[playerName] then
|
||||
return false
|
||||
end
|
||||
return false
|
||||
local player_data = players[playerName]
|
||||
local fov, fov_new, fade_time = player_data.fov
|
||||
local wielded_item_name = player:get_wielded_item():get_name()
|
||||
player_data.sprinting = sprinting
|
||||
if sprinting == true or controls.RMB and string.find(wielded_item_name, "mcl_bows:bow") and wielded_item_name ~= "mcl_bows:bow" then
|
||||
if sprinting == true then
|
||||
fov_new, fade_time = math.min(fov + 0.05, 1.2), .15
|
||||
playerphysics.add_physics_factor(player, "speed", "mcl_sprint:sprint", mcl_sprint.SPEED)
|
||||
else
|
||||
fov_new, fade_time = .7, .3
|
||||
end
|
||||
elseif sprinting == false and wielded_item_name ~= "mcl_bows:bow_0" and wielded_item_name ~= "mcl_bows:bow_1" and wielded_item_name ~= "mcl_bows:bow_2" then
|
||||
fov_new = math.max(fov - 0.05, 1.0)
|
||||
fade_time = 0.15
|
||||
if sprinting == false then
|
||||
playerphysics.remove_physics_factor(player, "speed", "mcl_sprint:sprint")
|
||||
end
|
||||
end
|
||||
if fov_new and fov_new ~= fov then
|
||||
player:set_fov(fov_new, true, fade_time)
|
||||
player_data.fov = fov_new
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
-- Given the param2 and paramtype2 of a node, returns the tile that is facing upwards
|
||||
|
|
Loading…
Reference in New Issue