mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-12-23 00:19:32 +01:00
add node_head_top to check to make sure you won't clip through blocks before going out of swim / fly mode
This commit is contained in:
parent
a41cbb7ebf
commit
9062a6e22e
2 changed files with 17 additions and 6 deletions
|
@ -33,11 +33,14 @@ local function get_player_nodes(player_pos)
|
|||
|
||||
work_pos.y = work_pos.y + 1.5 -- head level
|
||||
local node_head = node_ok(work_pos)
|
||||
work_pos.y = work_pos.y + 0.5 -- top of head level, at collision box height
|
||||
local node_head_top = node_ok(work_pos)
|
||||
work_pos.y = work_pos.y - 0.5
|
||||
|
||||
work_pos.y = work_pos.y - 1.2 -- feet level
|
||||
local node_feet = node_ok(work_pos)
|
||||
|
||||
return node_stand, node_stand_below, node_head, node_feet
|
||||
return node_stand, node_stand_below, node_head, node_feet, node_head_top
|
||||
end
|
||||
|
||||
minetest.register_globalstep(function(dtime)
|
||||
|
@ -62,11 +65,12 @@ minetest.register_globalstep(function(dtime)
|
|||
local pos = player:get_pos()
|
||||
|
||||
-- what is around me?
|
||||
local node_stand, node_stand_below, node_head, node_feet = get_player_nodes(pos)
|
||||
local node_stand, node_stand_below, node_head, node_feet, node_head_top = get_player_nodes(pos)
|
||||
mcl_playerinfo[name].node_stand = node_stand
|
||||
mcl_playerinfo[name].node_stand_below = node_stand_below
|
||||
mcl_playerinfo[name].node_head = node_head
|
||||
mcl_playerinfo[name].node_feet = node_feet
|
||||
mcl_playerinfo[name].node_head_top = node_head_top
|
||||
|
||||
end
|
||||
|
||||
|
@ -81,6 +85,7 @@ minetest.register_on_joinplayer(function(player)
|
|||
node_feet = "",
|
||||
node_stand = "",
|
||||
node_stand_below = "",
|
||||
node_head_top = "",
|
||||
}
|
||||
|
||||
end)
|
||||
|
|
|
@ -118,7 +118,7 @@ function limit_vel_yaw(player_vel_yaw, yaw)
|
|||
return player_vel_yaw
|
||||
end
|
||||
|
||||
local node_stand, node_stand_below, node_head, node_feet
|
||||
local node_stand, node_stand_below, node_head, node_feet, node_head_top
|
||||
local is_swimming
|
||||
|
||||
-- This following part is 2 wrapper functions for player:set_bones
|
||||
|
@ -377,7 +377,10 @@ minetest.register_globalstep(function(dtime)
|
|||
set_properties_conditional(player,{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
|
||||
set_bone_position_conditional(player,"Body_Control", vector.new(0,6.3,0), vector.new(degrees(dir_to_pitch(player_velocity)) - 90,-player_vel_yaw + yaw + 180,0))
|
||||
elseif mcl_playerinfo[name].node_head == "air" or get_item_group(mcl_playerinfo[name].node_head, "water") ~= 0 then
|
||||
elseif (mcl_playerinfo[name].node_head_top == "air" -- make sure the collision box is not going to clip through the ceiling
|
||||
or get_item_group(mcl_playerinfo[name].node_head_top, "water") ~= 0)
|
||||
and (mcl_playerinfo[name].node_head == "air"
|
||||
or get_item_group(mcl_playerinfo[name].node_head, "water") ~= 0) then
|
||||
-- sets eye height, and nametag color accordingly
|
||||
is_swimming = false
|
||||
set_properties_conditional(player,{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 }})
|
||||
|
@ -401,13 +404,15 @@ minetest.register_globalstep(function(dtime)
|
|||
node_stand_below = mcl_playerinfo[name].node_stand_below
|
||||
node_head = mcl_playerinfo[name].node_head
|
||||
node_feet = mcl_playerinfo[name].node_feet
|
||||
node_head_top = mcl_playerinfo[name].node_head_top
|
||||
if not node_stand or not node_stand_below or not node_head or not node_feet then
|
||||
return
|
||||
end
|
||||
if (not minetest.registered_nodes[node_stand]
|
||||
or not minetest.registered_nodes[node_stand_below]
|
||||
or not minetest.registered_nodes[node_head]
|
||||
or not minetest.registered_nodes[node_feet]) then
|
||||
or not minetest.registered_nodes[node_feet]
|
||||
or not minetest.registered_nodes[node_head_top]) then
|
||||
return
|
||||
end
|
||||
|
||||
|
@ -466,7 +471,8 @@ minetest.register_globalstep(function(dtime)
|
|||
local node_stand_below = mcl_playerinfo[name].node_stand_below
|
||||
local node_head = mcl_playerinfo[name].node_head
|
||||
local node_feet = mcl_playerinfo[name].node_feet
|
||||
if not node_stand or not node_stand_below or not node_head or not node_feet then
|
||||
local node_head_top = mcl_playerinfo[name].node_head_top
|
||||
if not node_stand or not node_stand_below or not node_head or not node_feet or not node_head_top then
|
||||
return
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue