Jump to content

How to check if player is stuck in a block (in a server)?


Jelly298

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.