1
0
Fork 0

broke elytra

This commit is contained in:
Sumyjkl 2022-08-01 20:12:53 +10:00
parent 8f4388c4c8
commit 696cc150b4
1 changed files with 22 additions and 14 deletions

View File

@ -263,8 +263,16 @@ minetest.register_globalstep(function(dtime)
local elytra = mcl_playerplus.elytra[player] local elytra = mcl_playerplus.elytra[player]
local function get_overall_velocity(vector) local function get_overall_velocity(vector)
local v = sqrt(vector.x^2 + vector.y^2 + vector.z^2) local v = math.sqrt(vector.x^2 + vector.y^2 + vector.z^2)
return 0 return v
end
local function clamp(num, min, max)
return math.min(max, math.max(num, min))
end
if not elytra.active then
elytra.speed = 10
end end
elytra.active = player:get_inventory():get_stack("armor", 3):get_name() == "mcl_armor:elytra" elytra.active = player:get_inventory():get_stack("armor", 3):get_name() == "mcl_armor:elytra"
@ -274,18 +282,18 @@ minetest.register_globalstep(function(dtime)
if elytra.active then if elytra.active then
mcl_player.player_set_animation(player, "fly") mcl_player.player_set_animation(player, "fly")
if player_velocity.y < -1.5 then local max_speed = 10000
player:add_velocity({x=0, y=0.17, z=0}) local direction = player:get_look_dir()
end -- local vel = player:get_velocity()
if math.abs(player_velocity.x) + math.abs(player_velocity.z) < 20 then local speed_mult = clamp(elytra.speed - direction.y * dtime, -max_speed, max_speed)
local dir = minetest.yaw_to_dir(player:get_look_horizontal()) elytra.speed = speed_mult
if degrees(player:get_look_vertical()) * -.01 < .1 then vel = direction
look_pitch = degrees(player:get_look_vertical()) * -.01 vel = vector.multiply(vel, speed_mult*100)
else vel = {
look_pitch = .1 x = clamp(vel.x, -max_speed, max_speed),
end y = clamp(vel.y, -max_speed, max_speed),
player:add_velocity({x=dir.x, y=look_pitch, z=dir.z}) z = clamp(vel.z, -max_speed, max_speed)}
end player:set_velocity(vel)
playerphysics.add_physics_factor(player, "gravity", "mcl_playerplus:elytra", 0.1) playerphysics.add_physics_factor(player, "gravity", "mcl_playerplus:elytra", 0.1)
if elytra.rocketing > 0 then if elytra.rocketing > 0 then