mirror of
https://git.minetest.land/MineClone2/MineClone2.git
synced 2024-12-04 16:53:46 +01:00
Fix controls.register_on_press being called for every player in a globalstep
parent
f79e12c8ae
commit
f8b54db392
@ -199,22 +199,7 @@ minetest.register_globalstep(function(dtime)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if elytra[player] == true and ~= nil then
|
||||||
controls.register_on_press(function(player, key)
|
|
||||||
if key~="jump" and key~="RMB" then return end
|
|
||||||
if key=="jump" then
|
|
||||||
if player:get_inventory():get_stack("armor", 3):get_name() == "mcl_armor:elytra" and player_velocity.y < -6 and elytra[player] ~= true then
|
|
||||||
elytra[player] = true
|
|
||||||
elseif key=="RMB" then
|
|
||||||
if wielded:get_name() == "mcl_tools:rocket" then
|
|
||||||
wielded:take_item()
|
|
||||||
player:set_wielded_item(wielded)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
if elytra[player] == true and node_stand_return ~= "air" or elytra[player] == true and player:get_inventory():get_stack("armor", 3):get_name() ~= "mcl_armor:elytra" or player:get_attach() ~= nil then
|
|
||||||
elytra[player] = false
|
elytra[player] = false
|
||||||
end
|
end
|
||||||
--[[
|
--[[
|
||||||
@ -224,21 +209,29 @@ minetest.register_globalstep(function(dtime)
|
|||||||
elytra[player] = false
|
elytra[player] = false
|
||||||
end]]
|
end]]
|
||||||
|
|
||||||
if elytra[player] == true then
|
local wearing_elytra = player:get_inventory():get_stack("armor", 3):get_name() == "mcl_armor:elytra"
|
||||||
mcl_player.player_set_animation(player, "fly")
|
|
||||||
playerphysics.add_physics_factor(player, "gravity", "mcl_playerplus:elytra", 0.1)
|
if elytra[player] then
|
||||||
if player_velocity.y < -1.5 then
|
if node_stand_return ~= "air" or not wearing_elytra or player:get_attach() then
|
||||||
player:add_velocity({x=0, y=0.17, z=0})
|
elytra[player] = false
|
||||||
end
|
else
|
||||||
if math.abs(player_velocity.x) + math.abs(player_velocity.z) < 20 then
|
mcl_player.player_set_animation(player, "fly")
|
||||||
local dir = minetest.yaw_to_dir(player:get_look_horizontal())
|
playerphysics.add_physics_factor(player, "gravity", "mcl_playerplus:elytra", 0.1)
|
||||||
if degrees(player:get_look_vertical()) * -.01 < .1 then
|
if player_velocity.y < -1.5 then
|
||||||
look_pitch = degrees(player:get_look_vertical()) * -.01
|
player:add_velocity({x=0, y=0.17, z=0})
|
||||||
else
|
end
|
||||||
look_pitch = .1
|
if math.abs(player_velocity.x) + math.abs(player_velocity.z) < 20 then
|
||||||
|
local dir = minetest.yaw_to_dir(player:get_look_horizontal())
|
||||||
|
if degrees(player:get_look_vertical()) * -.01 < .1 then
|
||||||
|
look_pitch = degrees(player:get_look_vertical()) * -.01
|
||||||
|
else
|
||||||
|
look_pitch = .1
|
||||||
|
end
|
||||||
|
player:add_velocity({x=dir.x, y=look_pitch, z=dir.z})
|
||||||
end
|
end
|
||||||
player:add_velocity({x=dir.x, y=look_pitch, z=dir.z})
|
|
||||||
end
|
end
|
||||||
|
elseif wearing_elytra and player_velocity.y < -6 and controls.jump then
|
||||||
|
elytra[player] = true
|
||||||
else
|
else
|
||||||
playerphysics.remove_physics_factor(player, "gravity", "mcl_playerplus:elytra")
|
playerphysics.remove_physics_factor(player, "gravity", "mcl_playerplus:elytra")
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user