Slab detection

This commit is contained in:
Guy Liner 2022-01-07 00:04:17 -05:00
parent 48f6699a6a
commit 531b17c5bd
1 changed files with 6 additions and 0 deletions

View File

@ -42,6 +42,7 @@ function mcl_playerinfo:collision_detect(pos,player)
} }
--Your distance from a block is < 1.1 if you're touching it. --Your distance from a block is < 1.1 if you're touching it.
local too_close = 1.1 local too_close = 1.1
local slab_too_close = 1.42
--[[ --[[
Takes the current degree angle that the player is facing Takes the current degree angle that the player is facing
Degrees in minetest are determined counter clock wise Degrees in minetest are determined counter clock wise
@ -89,8 +90,13 @@ function mcl_playerinfo:collision_detect(pos,player)
local node = minetest.get_node(coord) local node = minetest.get_node(coord)
-- How far is the player from the block in the given direction and -- How far is the player from the block in the given direction and
-- if the block is not air the player is colliding with it -- if the block is not air the player is colliding with it
print(node.name)
print(vector.distance(pos, coord))
if vector.distance(pos, coord) < too_close and node.name ~= "air" then if vector.distance(pos, coord) < too_close and node.name ~= "air" then
return false return false
--Should be able to detect when you head is touching a slab
elseif vector.distance(pos, coord) < slab_too_close and vector.distance(pos, coord) > too_close and placement == "front_ofplayerplus" and node.name ~= "air" then
return false
end end
end end
return true return true