Skip to content

Commit

Permalink
isHeadObstructed: Throw an IllegalArgumentException on margin < 0.
Browse files Browse the repository at this point in the history
(Shouldn't fix anything.)
  • Loading branch information
asofold committed Feb 9, 2016
1 parent 14e4620 commit 8d6b930
Showing 1 changed file with 8 additions and 1 deletion.
Expand Up @@ -709,14 +709,21 @@ public boolean isHeadObstructed(double marginAboveEyeHeight) {
* above the eye height of the player.
*
* @param marginAboveEyeHeight
* Must be greater than or equal zero.
* @param stepCorrection
* If set to true, a correction method is used for leniency.
* @return
* @throws IllegalArgumentException
* If marginAboveEyeHeight is smaller than 0.
*/
public boolean isHeadObstructed(double marginAboveEyeHeight, boolean stepCorrection) {
if (marginAboveEyeHeight < 0.0) {
throw new IllegalArgumentException("marginAboveEyeHeight must be greater than 0.");
}
// TODO: Add test for this bit of code.
if (stepCorrection) {
double ref = maxY + marginAboveEyeHeight;
ref = ref - Location.locToBlock(ref) + 0.35;
ref = ref - (double) Location.locToBlock(ref) + 0.35;
for (double bound = 1.0; bound > 0.0; bound -= 0.25) {
if (ref >= bound) {
// Use this level for correction.
Expand Down

0 comments on commit 8d6b930

Please sign in to comment.