/// <summary> /// Gets the safe pathing Y position for the entity depending on if it can path swim or not /// </summary> private int GetPathableYPos() { if (!TheEntity.IsInWater() || !CanSwim) { return((int)(TheEntity.BoundingBox.MinY + 0.5D)); } int i = (int)TheEntity.BoundingBox.MinY; int j = WorldObj.GetBlockId(MathHelper2.Floor_double(TheEntity.PosX), i, MathHelper2.Floor_double(TheEntity.PosZ)); int k = 0; while (j == Block.WaterMoving.BlockID || j == Block.WaterStill.BlockID) { i++; j = WorldObj.GetBlockId(MathHelper2.Floor_double(TheEntity.PosX), i, MathHelper2.Floor_double(TheEntity.PosZ)); if (++k > 16) { return((int)TheEntity.BoundingBox.MinY); } } return(i); }