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 more useful entity extensions #46

Merged
merged 3 commits into from
Apr 12, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Add Entity.isStandingInMidAir
  • Loading branch information
mooziii committed Apr 12, 2022
commit f3dba9467b1e240db7c1615dc102445ada5b17f2
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ val Entity.groundMaterial get() = this.location.add(0.0, -0.01, 0.0).block.type
val Entity.isStandingOnBlock: Boolean
get() = groundMaterial.isSolid

/**
* @returns true if the entity is standing in mid air.
*/
val Entity.isStandingInMidAir: Boolean
get() = !isStandingOnBlock && vehicle == null && !location.clone().add(0.0, 0.1, 0.0).block.type.isSolid && !location.block.type.isSolid

/**
* @return The max health of the entity
* @throws NullPointerException if the entity doesn't have a max health value
Expand Down