Merge branch 'master' into damage

This commit is contained in:
Elias Fleckenstein 2021-04-18 14:51:45 +02:00
commit f0d7715080
7 changed files with 104 additions and 143 deletions

@ -1030,6 +1030,14 @@ local node_ok = function(pos, fallback)
return minetest.registered_nodes[fallback] return minetest.registered_nodes[fallback]
end end
local function get_light(pos, tod)
if math.abs(pos.x) < 31000 and math.abs(pos.y) < 31000 and math.abs(pos.z) < 31000 then
local lightfunc = minetest.get_natural_light or minetest.get_node_light
return lightfunc(pos, tod)
else
return 0
end
end
-- environmental damage (water, lava, fire, light etc.) -- environmental damage (water, lava, fire, light etc.)
local do_env_damage = function(self) local do_env_damage = function(self)
@ -1075,7 +1083,6 @@ local do_env_damage = function(self)
-- Use get_node_light for Minetest version 5.3 where get_natural_light -- Use get_node_light for Minetest version 5.3 where get_natural_light
-- does not exist yet. -- does not exist yet.
local get_light = minetest.get_natural_light or minetest.get_node_light
local sunlight = get_light(pos, self.time_of_day) local sunlight = get_light(pos, self.time_of_day)
-- bright light harms mob -- bright light harms mob

@ -619,12 +619,17 @@ mcl_enchanting.enchantments.unbreaking = {
description = S("Increases item durability."), description = S("Increases item durability."),
curse = false, curse = false,
on_enchant = function(itemstack, level) on_enchant = function(itemstack, level)
local tool_capabilities = itemstack:get_tool_capabilities() local name = itemstack:get_name()
for group, capability in pairs(tool_capabilities.groupcaps) do if not minetest.registered_tools[name].tool_capabilities then
capability.uses = capability.uses * (1 + level) return
end end
local tool_capabilities = itemstack:get_tool_capabilities()
tool_capabilities.punch_attack_uses = tool_capabilities.punch_attack_uses * (1 + level) tool_capabilities.punch_attack_uses = tool_capabilities.punch_attack_uses * (1 + level)
itemstack:get_meta():set_tool_capabilities(tool_capabilities) itemstack:get_meta():set_tool_capabilities(tool_capabilities)
-- Unbreaking for groupcaps is handled in this function.
mcl_enchanting.update_groupcaps(itemstack)
end, end,
requires_tool = true, requires_tool = true,
treasure = false, treasure = false,

@ -12,11 +12,12 @@ end
function mcl_enchanting.unload_enchantments(itemstack) function mcl_enchanting.unload_enchantments(itemstack)
local itemdef = itemstack:get_definition() local itemdef = itemstack:get_definition()
if itemdef.tool_capabilities then if itemdef.tool_capabilities then
itemstack:get_meta():set_tool_capabilities(itemdef.tool_capabilities) itemstack:get_meta():set_tool_capabilities(nil)
end end
local meta = itemstack:get_meta() local meta = itemstack:get_meta()
if meta:get_string("name") == "" then if meta:get_string("name") == "" then
meta:set_string("description", "") meta:set_string("description", "")
meta:set_string("groupcaps_hash", "")
end end
end end

@ -45,18 +45,30 @@ end
-- To make it more efficient it will first check a hash value to determine if -- To make it more efficient it will first check a hash value to determine if
-- the tool needs to be updated. -- the tool needs to be updated.
function mcl_enchanting.update_groupcaps(itemstack) function mcl_enchanting.update_groupcaps(itemstack)
if not itemstack:get_meta():get("tool_capabilities") then local name = itemstack:get_name()
if not minetest.registered_tools[name].tool_capabilities then
return return
end end
local name = itemstack:get_name() local efficiency = mcl_enchanting.get_enchantment(itemstack, "efficiency")
local level = mcl_enchanting.get_enchantment(itemstack, "efficiency") local unbreaking = mcl_enchanting.get_enchantment(itemstack, "unbreaking")
local groupcaps = get_efficiency_groupcaps(name, level) if unbreaking == 0 and efficiency == 0 then
return
end
local groupcaps = get_efficiency_groupcaps(name, efficiency)
local hash = itemstack:get_meta():get_string("groupcaps_hash") local hash = itemstack:get_meta():get_string("groupcaps_hash")
if not hash or hash ~= groupcaps.hash then if not hash or hash ~= groupcaps.hash then
local tool_capabilities = itemstack:get_tool_capabilities() local tool_capabilities = itemstack:get_tool_capabilities()
tool_capabilities.groupcaps = groupcaps.values tool_capabilities.groupcaps = groupcaps.values
-- Increase the number of uses depending on the unbreaking level
-- of the tool.
for group, capability in pairs(tool_capabilities.groupcaps) do
capability.uses = capability.uses * (1 + unbreaking)
end
itemstack:get_meta():set_tool_capabilities(tool_capabilities) itemstack:get_meta():set_tool_capabilities(tool_capabilities)
itemstack:get_meta():set_string("groupcaps_hash", groupcaps.hash) itemstack:get_meta():set_string("groupcaps_hash", groupcaps.hash)
end end

@ -1,69 +1,28 @@
local S = minetest.get_translator("mcl_fireworks") local S = minetest.get_translator("mcl_fireworks")
player_rocketing = {} local player_rocketing = {}
local help = S("Flight Duration:") local tt_help = S("Flight Duration:")
local description = S("Firework Rocket") local description = S("Firework Rocket")
local rocket_sound = function()
minetest.sound_play("mcl_fireworks_rocket") local function register_rocket(n, duration, force)
minetest.register_craftitem("mcl_fireworks:rocket_" .. n, {
description = description,
_tt_help = tt_help .. " " .. duration,
inventory_image = "mcl_fireworks_rocket.png",
stack_max = 64,
on_use = function(itemstack, user, pointed_thing)
local elytra = mcl_playerplus.elytra[user]
if elytra.active and elytra.rocketing <= 0 then
elytra.rocketing = duration
itemstack:take_item()
minetest.sound_play("mcl_fireworks_rocket", {pos = user:get_pos()})
end
return itemstack
end,
})
end end
minetest.register_craftitem("mcl_fireworks:rocket_1", { register_rocket(1, 2.2, 10)
description = description, register_rocket(2, 4.5, 20)
_tt_help = help.." 1", register_rocket(3, 6, 30)
inventory_image = "mcl_fireworks_rocket.png",
stack_max = 64,
on_use = function(itemstack, user, pointed_thing)
local torso = user:get_inventory():get_stack("armor", 3)
if torso and torso:get_name() == "mcl_armor:elytra" and player_rocketing[user] ~= true then
player_rocketing[user] = true
minetest.after(2.2, function()
player_rocketing[user] = false
end)
itemstack:take_item()
--user:add_player_velocity(vector.multiply(user:get_look_dir(), 20))
rocket_sound()
end
return itemstack
end,
})
minetest.register_craftitem("mcl_fireworks:rocket_2", {
description = description,
_tt_help = help.." 2",
inventory_image = "mcl_fireworks_rocket.png",
stack_max = 64,
on_use = function(itemstack, user, pointed_thing)
local torso = user:get_inventory():get_stack("armor", 3)
if torso and torso:get_name() == "mcl_armor:elytra" and player_rocketing[user] ~= true then
player_rocketing[user] = true
minetest.after(4.5, function()
player_rocketing[user] = false
end)
itemstack:take_item()
--user:add_player_velocity(vector.multiply(user:get_look_dir(), 20))
rocket_sound()
end
return itemstack
end,
})
minetest.register_craftitem("mcl_fireworks:rocket_3", {
description = description,
_tt_help = help.." 3",
inventory_image = "mcl_fireworks_rocket.png",
stack_max = 64,
on_use = function(itemstack, user, pointed_thing)
local torso = user:get_inventory():get_stack("armor", 3)
if torso and torso:get_name() == "mcl_armor:elytra" and player_rocketing[user] ~= true then
player_rocketing[user] = true
minetest.after(6, function()
player_rocketing[user] = false
end)
itemstack:take_item()
--user:add_player_velocity(vector.multiply(user:get_look_dir(), 20))
rocket_sound()
end
return itemstack
end,
})

@ -27,9 +27,8 @@ local DELAY = 3 -- seconds before teleporting in Nether portal in Survival mo
local DISTANCE_MAX = 128 local DISTANCE_MAX = 128
local PORTAL = "mcl_portals:portal" local PORTAL = "mcl_portals:portal"
local OBSIDIAN = "mcl_core:obsidian" local OBSIDIAN = "mcl_core:obsidian"
local O_Y_MIN, O_Y_MAX = max(mcl_vars.mg_overworld_min, -31), min(mcl_vars.mg_overworld_max_official, 2048) local O_Y_MIN, O_Y_MAX = max(mcl_vars.mg_overworld_min, -31), min(mcl_vars.mg_overworld_max, 2048)
local N_Y_MIN, N_Y_MAX = mcl_vars.mg_bedrock_nether_bottom_min, mcl_vars.mg_bedrock_nether_top_max - H_MIN local N_Y_MIN, N_Y_MAX = mcl_vars.mg_bedrock_nether_bottom_min, mcl_vars.mg_bedrock_nether_top_min - H_MIN
local O_DY, N_DY = O_Y_MAX - O_Y_MIN + 1, N_Y_MAX - N_Y_MIN + 1
-- Alpha and particles -- Alpha and particles
local node_particles_allowed = minetest.settings:get("mcl_node_particles") or "none" local node_particles_allowed = minetest.settings:get("mcl_node_particles") or "none"
@ -78,6 +77,8 @@ local pos_to_string = minetest.pos_to_string
local is_area_protected = minetest.is_area_protected local is_area_protected = minetest.is_area_protected
local get_us_time = minetest.get_us_time local get_us_time = minetest.get_us_time
local dimension_to_teleport = { nether = "overworld", overworld = "nether" }
local limits = { local limits = {
nether = { nether = {
pmin = {x=LIM_MIN, y = N_Y_MIN, z = LIM_MIN}, pmin = {x=LIM_MIN, y = N_Y_MIN, z = LIM_MIN},
@ -181,10 +182,10 @@ local function get_target(p)
x, o1 = ping_pong(x, TRAVEL_X, LIM_MIN, LIM_MAX) x, o1 = ping_pong(x, TRAVEL_X, LIM_MIN, LIM_MAX)
z, o2 = ping_pong(z, TRAVEL_Z, LIM_MIN, LIM_MAX) z, o2 = ping_pong(z, TRAVEL_Z, LIM_MIN, LIM_MAX)
y = floor(y * TRAVEL_Y + (o1+o2) / 16 * LIM_MAX) y = floor(y * TRAVEL_Y + (o1+o2) / 16 * LIM_MAX)
y = min(max(y + mcl_vars.mg_overworld_min, mcl_vars.mg_overworld_min), mcl_vars.mg_overworld_max) y = min(max(y + O_Y_MIN, O_Y_MIN), O_Y_MAX)
elseif d=="overworld" then elseif d=="overworld" then
x, y, z = floor(x / TRAVEL_X + 0.5), floor(y / TRAVEL_Y + 0.5), floor(z / TRAVEL_Z + 0.5) x, y, z = floor(x / TRAVEL_X + 0.5), floor(y / TRAVEL_Y + 0.5), floor(z / TRAVEL_Z + 0.5)
y = min(max(y + mcl_vars.mg_nether_min, mcl_vars.mg_nether_min), mcl_vars.mg_nether_max) y = min(max(y + N_Y_MIN, N_Y_MIN), N_Y_MAX)
end end
return {x=x, y=y, z=z}, d return {x=x, y=y, z=z}, d
end end
@ -457,8 +458,8 @@ local function ecb_scan_area_2(blockpos, action, calls_remaining, param)
local nodes = find_nodes_in_area_under_air(pos1, pos2, {"group:building_block"}) local nodes = find_nodes_in_area_under_air(pos1, pos2, {"group:building_block"})
if nodes then if nodes then
local nc = #nodes local nc = #nodes
log("action", "[mcl_portals] Area for destination Nether portal emerged! Found " .. tostring(nc) .. " nodes under the air around "..pos_to_string(pos))
if nc > 0 then if nc > 0 then
log("action", "[mcl_portals] Area for destination Nether portal emerged! Found " .. tostring(nc) .. " nodes under the air around "..pos_to_string(pos))
for i=1,nc do for i=1,nc do
local node = nodes[i] local node = nodes[i]
local node1 = {x=node.x, y=node.y+1, z=node.z } local node1 = {x=node.x, y=node.y+1, z=node.z }
@ -474,7 +475,7 @@ local function ecb_scan_area_2(blockpos, action, calls_remaining, param)
return return
end end
if not distance or (distance0 < distance) or (distance0 < distance-1 and node.y > lava and pos0.y < lava) then if not distance or (distance0 < distance) or (distance0 < distance-1 and node.y > lava and pos0.y < lava) then
log("action", "[mcl_portals] found distance "..tostring(distance0).." at pos "..pos_to_string(node)) log("verbose", "[mcl_portals] found distance "..tostring(distance0).." at pos "..pos_to_string(node))
distance = distance0 distance = distance0
pos0 = {x=node1.x, y=node1.y, z=node1.z} pos0 = {x=node1.x, y=node1.y, z=node1.z}
end end
@ -626,7 +627,7 @@ end
-- Pos can be any of the inner part. -- Pos can be any of the inner part.
-- The frame MUST be filled only with air or any fire, which will be replaced with Nether portal blocks. -- The frame MUST be filled only with air or any fire, which will be replaced with Nether portal blocks.
-- If no Nether portal can be lit, nothing happens. -- If no Nether portal can be lit, nothing happens.
-- Returns number of portals created (0, 1 or 2) -- Returns true if portal created
function mcl_portals.light_nether_portal(pos) function mcl_portals.light_nether_portal(pos)
-- Only allow to make portals in Overworld and Nether -- Only allow to make portals in Overworld and Nether
local dim = mcl_worlds.pos_to_dimension(pos) local dim = mcl_worlds.pos_to_dimension(pos)
@ -636,11 +637,6 @@ function mcl_portals.light_nether_portal(pos)
local orientation = random(0, 1) local orientation = random(0, 1)
for orientation_iteration = 1, 2 do for orientation_iteration = 1, 2 do
if check_and_light_shape(pos, orientation) then if check_and_light_shape(pos, orientation) then
minetest.after(0.2, function(pos) -- generate target map chunk
local pos1 = add(mul(mcl_vars.pos_to_chunk(pos), mcl_vars.chunk_size_in_nodes), mcl_vars.central_chunk_offset_in_nodes)
local pos2 = add(pos1, mcl_vars.chunk_size_in_nodes - 1)
minetest.emerge_area(pos1, pos2)
end, vector.new(pos))
return true return true
end end
orientation = 1 - orientation orientation = 1 - orientation
@ -672,6 +668,7 @@ local function teleport_no_delay(obj, pos)
if exit then if exit then
finalize_teleport(obj, exit) finalize_teleport(obj, exit)
else else
dim = dimension_to_teleport[dim]
-- need to create arrival portal -- need to create arrival portal
create_portal(target, limits[dim].pmin, limits[dim].pmax, name, obj) create_portal(target, limits[dim].pmin, limits[dim].pmax, name, obj)
end end

@ -1,8 +1,9 @@
local S = minetest.get_translator("mcl_playerplus") local S = minetest.get_translator("mcl_playerplus")
elytra = {} mcl_playerplus = {
elytra = {},
}
local node_stand_return = ":air"
local get_connected_players = minetest.get_connected_players local get_connected_players = minetest.get_connected_players
local dir_to_yaw = minetest.dir_to_yaw local dir_to_yaw = minetest.dir_to_yaw
local get_item_group = minetest.get_item_group local get_item_group = minetest.get_item_group
@ -149,13 +150,6 @@ minetest.register_globalstep(function(dtime)
for _,player in pairs(get_connected_players()) do for _,player in pairs(get_connected_players()) do
local c_x, c_y = unpack(player_collision(player))
if player:get_velocity().x + player:get_velocity().y < .5 and c_x + c_y > 0 then
--minetest.chat_send_player(player:get_player_name(), "pushed at " .. c_x + c_y .. " parsecs.")
player:add_velocity({x=c_x, y=0, z=c_y})
end
--[[ --[[
_ _ _ _ _ _
__ _ _ __ (_)_ __ ___ __ _| |_(_) ___ _ __ ___ __ _ _ __ (_)_ __ ___ __ _| |_(_) ___ _ __ ___
@ -171,9 +165,16 @@ minetest.register_globalstep(function(dtime)
local parent = player:get_attach() local parent = player:get_attach()
local wielded = player:get_wielded_item() local wielded = player:get_wielded_item()
local player_velocity = player:get_velocity() or player:get_player_velocity() local player_velocity = player:get_velocity() or player:get_player_velocity()
local wielded_def = wielded:get_definition() local wielded_def = wielded:get_definition()
local c_x, c_y = unpack(player_collision(player))
if player_velocity.x + player_velocity.y < .5 and c_x + c_y > 0 then
local add_velocity = player.add_player_velocity or player.add_velocity
add_velocity(player, {x = c_x, y = 0, z = c_y})
player_velocity = player:get_velocity() or player:get_player_velocity()
end
-- control head bone -- control head bone
local pitch = - degrees(player:get_look_vertical()) local pitch = - degrees(player:get_look_vertical())
local yaw = degrees(player:get_look_horizontal()) local yaw = degrees(player:get_look_horizontal())
@ -185,50 +186,17 @@ minetest.register_globalstep(function(dtime)
player_vel_yaw = limit_vel_yaw(player_vel_yaw, yaw) player_vel_yaw = limit_vel_yaw(player_vel_yaw, yaw)
player_vel_yaws[name] = player_vel_yaw player_vel_yaws[name] = player_vel_yaw
local pos = player:get_pos() local fly_pos = player:get_pos()
local node = minetest.get_node_or_nil({x = pos.x, y = pos.y - 0.5, z = pos.z}) local fly_node = minetest.get_node({x = fly_pos.x, y = fly_pos.y - 0.5, z = fly_pos.z}).name
local elytra = mcl_playerplus.elytra[player]
if node then elytra.active = player:get_inventory():get_stack("armor", 3):get_name() == "mcl_armor:elytra"
node_stand_return = node.name and not player:get_attach()
end and (elytra.active or control.jump and player_velocity.y < -6)
and (fly_node == "air" or fly_node == "ignore")
local chestplate = player:get_inventory():get_stack("armor", 3) if elytra.active then
if player_rocketing[player] and player_rocketing[player] == true and chestplate:get_name() == "mcl_armor:elytra" then
if math.abs(player_velocity.x) + math.abs(player_velocity.y) + math.abs(player_velocity.z) < 40 then
player:add_player_velocity(vector.multiply(player:get_look_dir(), 4))
elytra[player] = true
end
end
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
end
--[[
if player:get_inventory():get_stack("armor", 3):get_name() == "mcl_armor:elytra" and player_velocity.y < -6 and elytra[player] ~= true and is_sprinting(name) then
elytra[player] = true
elseif 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
end]]
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)
if player_velocity.y < -1.5 then if player_velocity.y < -1.5 then
player:add_velocity({x=0, y=0.17, z=0}) player:add_velocity({x=0, y=0.17, z=0})
end end
@ -241,7 +209,17 @@ minetest.register_globalstep(function(dtime)
end end
player:add_velocity({x=dir.x, y=look_pitch, z=dir.z}) player:add_velocity({x=dir.x, y=look_pitch, z=dir.z})
end end
playerphysics.add_physics_factor(player, "gravity", "mcl_playerplus:elytra", 0.1)
if elytra.rocketing > 0 then
elytra.rocketing = elytra.rocketing - dtime
if vector.length(player_velocity) < 40 then
local add_velocity = player.add_velocity or player.add_player_velocity
add_velocity(player, vector.multiply(player:get_look_dir(), 4))
end
end
else else
elytra.rocketing = 0
playerphysics.remove_physics_factor(player, "gravity", "mcl_playerplus:elytra") playerphysics.remove_physics_factor(player, "gravity", "mcl_playerplus:elytra")
end end
@ -271,16 +249,16 @@ minetest.register_globalstep(function(dtime)
player:set_bone_position("Arm_Right_Pitch_Control", vector.new(-3,5.785,0), vector.new(0,0,0)) player:set_bone_position("Arm_Right_Pitch_Control", vector.new(-3,5.785,0), vector.new(0,0,0))
end end
if elytra[player] == true then if elytra.active then
-- set head pitch and yaw when swimming -- set head pitch and yaw when flying
player:set_bone_position("Head", vector.new(0,6.3,0), vector.new(pitch+90-degrees(dir_to_pitch(player_velocity)),player_vel_yaw - yaw,0)) player:set_bone_position("Head", vector.new(0,6.3,0), vector.new(pitch+90-degrees(dir_to_pitch(player_velocity)),player_vel_yaw - yaw,0))
-- sets eye height, and nametag color accordingly -- sets eye height, and nametag color accordingly
player:set_properties({collisionbox = {-0.35,0,-0.35,0.35,0.8,0.35}, eye_height = 0.5, nametag_color = { r = 225, b = 225, a = 0, g = 225 }}) player:set_properties({collisionbox = {-0.35,0,-0.35,0.35,0.8,0.35}, eye_height = 0.5, nametag_color = { r = 225, b = 225, a = 225, g = 225 }})
-- control body bone when swimming -- control body bone when flying
player:set_bone_position("Body_Control", vector.new(0,6.3,0), vector.new(degrees(dir_to_pitch(player_velocity)) - 90,-player_vel_yaw + yaw + 180,0)) player:set_bone_position("Body_Control", vector.new(0,6.3,0), vector.new(degrees(dir_to_pitch(player_velocity)) - 90,-player_vel_yaw + yaw + 180,0))
elseif parent then elseif parent then
local parent_yaw = degrees(parent:get_yaw()) local parent_yaw = degrees(parent:get_yaw())
player:set_properties({collisionbox = {-0.312,0,-0.312,0.312,1.8,0.312}, eye_height = 1.5, nametag_color = { r = 225, b = 225, a = 0, g = 225 }}) player:set_properties({collisionbox = {-0.312,0,-0.312,0.312,1.8,0.312}, eye_height = 1.5, nametag_color = { r = 225, b = 225, a = 225, g = 225 }})
player:set_bone_position("Head", vector.new(0,6.3,0), vector.new(pitch, -limit_vel_yaw(yaw, parent_yaw) + parent_yaw, 0)) player:set_bone_position("Head", vector.new(0,6.3,0), vector.new(pitch, -limit_vel_yaw(yaw, parent_yaw) + parent_yaw, 0))
player:set_bone_position("Body_Control", vector.new(0,6.3,0), vector.new(0,0,0)) player:set_bone_position("Body_Control", vector.new(0,6.3,0), vector.new(0,0,0))
elseif control.sneak then elseif control.sneak then
@ -294,12 +272,12 @@ minetest.register_globalstep(function(dtime)
-- set head pitch and yaw when swimming -- set head pitch and yaw when swimming
player:set_bone_position("Head", vector.new(0,6.3,0), vector.new(pitch+90-degrees(dir_to_pitch(player_velocity)),player_vel_yaw - yaw,0)) player:set_bone_position("Head", vector.new(0,6.3,0), vector.new(pitch+90-degrees(dir_to_pitch(player_velocity)),player_vel_yaw - yaw,0))
-- sets eye height, and nametag color accordingly -- sets eye height, and nametag color accordingly
player:set_properties({collisionbox = {-0.312,0,-0.312,0.312,0.8,0.312}, eye_height = 0.5, nametag_color = { r = 225, b = 225, a = 0, g = 225 }}) player:set_properties({collisionbox = {-0.312,0,-0.312,0.312,0.8,0.312}, eye_height = 0.5, nametag_color = { r = 225, b = 225, a = 225, g = 225 }})
-- control body bone when swimming -- control body bone when swimming
player:set_bone_position("Body_Control", vector.new(0,6.3,0), vector.new(degrees(dir_to_pitch(player_velocity)) - 90,-player_vel_yaw + yaw + 180,0)) player:set_bone_position("Body_Control", vector.new(0,6.3,0), vector.new(degrees(dir_to_pitch(player_velocity)) - 90,-player_vel_yaw + yaw + 180,0))
else else
-- sets eye height, and nametag color accordingly -- sets eye height, and nametag color accordingly
player:set_properties({collisionbox = {-0.312,0,-0.312,0.312,1.8,0.312}, eye_height = 1.5, nametag_color = { r = 225, b = 225, a = 0, g = 225 }}) player:set_properties({collisionbox = {-0.312,0,-0.312,0.312,1.8,0.312}, eye_height = 1.5, nametag_color = { r = 225, b = 225, a = 225, g = 225 }})
player:set_bone_position("Head", vector.new(0,6.3,0), vector.new(pitch, player_vel_yaw - yaw, 0)) player:set_bone_position("Head", vector.new(0,6.3,0), vector.new(pitch, player_vel_yaw - yaw, 0))
player:set_bone_position("Body_Control", vector.new(0,6.3,0), vector.new(0, -player_vel_yaw + yaw, 0)) player:set_bone_position("Body_Control", vector.new(0,6.3,0), vector.new(0, -player_vel_yaw + yaw, 0))
@ -540,6 +518,7 @@ minetest.register_on_joinplayer(function(player)
swimDistance = 0, swimDistance = 0,
jump_cooldown = -1, -- Cooldown timer for jumping, we need this to prevent the jump exhaustion to increase rapidly jump_cooldown = -1, -- Cooldown timer for jumping, we need this to prevent the jump exhaustion to increase rapidly
} }
mcl_playerplus.elytra[player] = {active = false, rocketing = 0}
end) end)
-- clear when player leaves -- clear when player leaves
@ -547,4 +526,5 @@ minetest.register_on_leaveplayer(function(player)
local name = player:get_player_name() local name = player:get_player_name()
mcl_playerplus_internal[name] = nil mcl_playerplus_internal[name] = nil
mcl_playerplus.elytra[player] = nil
end) end)