Add specialized convenience methods for isOnGround and standsOnEntity.

This commit is contained in:
asofold 2013-02-02 17:25:37 +01:00
parent 57202f81c5
commit 351fbfd79f

View File

@ -394,6 +394,38 @@ public class PlayerLocation {
return onGround;
}
/**
* Simple block-on-ground check for given margin (no entities). Meant for checking bigger margin than the normal yOnGround.
* @param yOnGround Margin below the player.
* @return
*/
public boolean isOnGround(final double yOnGround){
return isOnGround(yOnGround, 0D, 0D);
}
/**
* Simple block-on-ground check for given margin (no entities). Meant for checking bigger margin than the normal yOnGround.
* @param yOnGround Margin below the player.
* @param xzMargin
* @param yMargin Extra margin added below and above.
* @return
*/
public boolean isOnGround(final double yOnGround, final double xzMargin, final double yMargin) {
return BlockProperties.isOnGround(blockCache, minX - xzMargin, minY - yOnGround - yMargin, minZ - xzMargin, maxX + xzMargin, minY + yMargin, maxZ + xzMargin);
}
/**
* Simple check with custom margins (Boat, Minecart).
* @param yOnGround Margin below the player.
* @param xzMargin
* @param yMargin Extra margin added below and above.
* @return
*/
public boolean standsOnEntity(final double yOnGround, final double xzMargin, final double yMargin){
return blockCache.standsOnEntity(player, minX - xzMargin, minY - yOnGround - yMargin, minZ - xzMargin, maxX + xzMargin, minY + yMargin, maxZ + xzMargin);
}
/**
* Reset condition for flying checks (sf + nofall): fluids, web, ladder (not on-ground, though).
* @return