Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add extra checks to make sure we don't accidentally suffocate player #12

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

zford
Copy link
Contributor

@zford zford commented Jul 24, 2013

If blocks directly above the mine are not air, we could potentially suffocate the player. This checks the two top blocks to make sure they are air, and if they're not, TPs them to the highest spot (surface?) on the X, Z coordinate.

This additionally fixes an edge case where standing in one of the corners may not TP you out of the mine.

@jjkoletar
Copy link
Owner

Sorry for being super late to the PR.

For the first chunk, was it necessary to switch from getY() to getBlockY(), etc?

@zford
Copy link
Contributor Author

zford commented Aug 28, 2013

This additionally fixes an edge case where standing in one of the corners may not TP you out of the mine.

You have to remember a block fills a space, and isn't a single point. You need to check if the player is within the space between the block edges, which expands beyond the boundries set by min[XYZ] max[XYZ]

While a block's cordinates might be 50,50,50, it fills the space between 50,50,50 and 51,51,51. So if you're standing on a block in the mine with coordinates of max[XYZ], you'll you need to check an additional block out.

You could probably use getX() and expand the max[XYZ] borders by one, but then you're doing a floating point check instead of an integer check.. in addition to an addition operation. Casting to int is probably faster, and in this case is less ambiguous, since all i really care about is the block location that the player is standing on, not the space between the blocks he is standing on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants