1
0
Fork 0

Make flying w elytra use pitch and not sneak

This commit is contained in:
epCode 2021-04-13 16:14:37 -07:00
parent 67c1bc973a
commit 399ed85717
1 changed files with 21 additions and 10 deletions

View File

@ -24,6 +24,7 @@ local mcl_playerplus_internal = {}
local def = {} local def = {}
local time = 0 local time = 0
local look_pitch = 0
local player_collision = function(player) local player_collision = function(player)
@ -194,18 +195,27 @@ minetest.register_globalstep(function(dtime)
player_vel_yaws[name] = player_vel_yaw player_vel_yaws[name] = player_vel_yaw
if minetest.get_node_or_nil({x=player:get_pos().x, y=player:get_pos().y - 0.5, z=player:get_pos().z}) then if minetest.get_node_or_nil({x=player:get_pos().x, y=player:get_pos().y - 0.5, z=player:get_pos().z}) then
node_stand_return = minetest.get_node_or_nil({x=player:get_pos().x, y=player:get_pos().y - 0.5, z=player:get_pos().z}).name node_stand_return = minetest.get_node_or_nil({x=player:get_pos().x, y=player:get_pos().y - 0.1, z=player:get_pos().z}).name
else else
minetest.log("action", "somehow player got of loaded areas") minetest.log("action", "somehow player got of loaded areas")
end end
controls.register_on_press(function(player, key) controls.register_on_press(function(player, key)
if key~="jump" then return end 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 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 elytra[player] = true
elseif key=="RMB" then
if wielded:get_name() == "mcl_tools:rocket" then
local item = wielded:take_item()
player:set_wielded_item(wielded)
end
end
end end
end) end)
local chestplate = player:get_inventory():get_stack("armor", 3)
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 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
@ -216,6 +226,8 @@ minetest.register_globalstep(function(dtime)
elytra[player] = false elytra[player] = false
end]] end]]
minetest.chat_send_all(degrees(player:get_look_vertical()) * -.01)
if elytra[player] == true then if elytra[player] == true then
mcl_player.player_set_animation(player, "fly") mcl_player.player_set_animation(player, "fly")
playerphysics.add_physics_factor(player, "gravity", "mcl_playerplus:elytra", 0.1) playerphysics.add_physics_factor(player, "gravity", "mcl_playerplus:elytra", 0.1)
@ -224,13 +236,12 @@ minetest.register_globalstep(function(dtime)
end end
if math.abs(player_velocity.x) + math.abs(player_velocity.z) < 20 then if math.abs(player_velocity.x) + math.abs(player_velocity.z) < 20 then
local dir = minetest.yaw_to_dir(player:get_look_horizontal()) local dir = minetest.yaw_to_dir(player:get_look_horizontal())
local pitch = 1 * player:get_look_vertical() * -.1 if degrees(player:get_look_vertical()) * -.01 < .1 then
player:add_velocity({x=dir.x, y=pitch, z=dir.z}) look_pitch = degrees(player:get_look_vertical()) * -.01
end else
if control.sneak then look_pitch = .1
if player_velocity.y > -5 then
player:add_velocity({x=0, y=-2, z=0})
end end
player:add_velocity({x=dir.x, y=look_pitch, z=dir.z})
end end
else else
playerphysics.remove_physics_factor(player, "gravity", "mcl_playerplus:elytra") playerphysics.remove_physics_factor(player, "gravity", "mcl_playerplus:elytra")