Posted February 24, 20223 yr How to check if player is stuck in a block (in a server)? I use getblock from current player coords and check but it don't seem to work. idk if it's because it is happening server side and I need to use sth else to detect it???? someone pls help
February 24, 20223 yr Bear in mind that players are 2 blocks tall, and I believe that the position is where their feet are. You need to either check whether or not the player's AABB is inside a block (i.e. loop through all blockpos which the AABB intersects with and check the block), or you need to use the position of the player's eyes. It depends what you are trying to achieve
February 25, 20223 yr Author Well I am trying to check if the player's lower body is stuck in a block. If I use check intersect I need to check it 8 times (all blocks around the player). Any better way to implement this?
February 28, 20223 yr Get the x and z positions of the bounding box, and only check the blocks that those positions are in (e.g if AABB is x = -0.2 to 0.8, and z = 1.6 - 2.6 then you need to check the blocks at: (-1, y, 1), (0, y, 1), (-1, y, 2) & (0, y, 2) (use floor to find the integers to get the blockPos)). That way you only check the 4 blocks that you know the player is standing in.
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.